Skip to content

fix(sign): load envelope files with details on /f/sign (#9571) - #9699

Open
Buzepool wants to merge 2 commits into
LibreSign:mainfrom
Buzepool:fix/envelope-files-details-9571
Open

Buzepool wants to merge 2 commits into
LibreSign:mainfrom
Buzepool:fix/envelope-files-details-9571

Conversation

@Buzepool

Copy link
Copy Markdown

Resolves: #9571

📝 Summary

On /f/sign/{uuid}, SignPDF.vue loads envelope children through file/list without details=true. The summary payload has no PDF url for child files, so getFileUrl() finds nothing and the page shows "Failed to load envelope files" without requesting any PDF. The detailed payload adds the current signer's PDF url (the same call in VisibleElements.vue already passes details: true). /p/sign works because the files come from the initial state.

🧪 How to test

  1. User A creates an envelope with two or more PDFs and adds User B (Nextcloud account) as signer.
  2. User B opens /apps/libresign/f/sign/{uuid}/pdf with a full page load.
  3. Before: "Failed to load envelope files". After: the envelope PDFs load.

Validation evidence

  • Focused regression/acceptance test
  • Relevant lint/type/static-analysis checks
  • Broader suite required by the changed surface
  • CI reviewed

🎨 UI / Front-end changes

  • fetchEnvelopeFiles requests details=true
  • Component/unit (Vitest) and/or E2E (Playwright) tests added or updated

✅ Checklist

  • I have read and followed the contribution guide.
  • The diff does not contain unrelated refactors or generated changes.
  • Commits follow Conventional Commits where applicable.
  • All commits include the required DCO sign-off.

🤖 AI (if applicable)

  • The content of this PR was partially or fully generated using AI

Signed-off-by: Buzepool <pedrokenorhue@gmail.com>
@Buzepool
Buzepool requested a review from a team as a code owner November 24, 2026 18:06
@welcome

welcome Bot commented Nov 24, 2026

Copy link
Copy Markdown

Thanks for opening your first pull request in this repository! ✌️

@vitormattos vitormattos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the inline regression test feedback before merging.

Comment thread src/tests/views/SignPDF/SignPDF.spec.ts Outdated
expect(signStore.document!.files).toEqual(envelopeFiles)
})

it('requests detailed envelope files so child files carry a PDF url', async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you extend this regression test to verify the actual PDF loading behavior using Vitest's it.each, with the following datasets?

it.each([
    { nodeType: 'file', fileCount: 1 },
    { nodeType: 'envelope', fileCount: 2 },
])('loads all PDFs for $nodeType with $fileCount file(s)', ...)

You can reuse the existing mocks and the createSignDocument() helper in this test suite.

A suggested approach:

  1. Set mockRoute.name to SignPDF to exercise the internal signing flow.
  2. Mock filesStore.fetchFileDetail() to return the corresponding document or envelope.
  3. Mock loadState() to simulate a fresh page load without preloaded PDFs or envelope files.
  4. For the envelope scenario, make the axios.get() mock return the summary payload without PDF URLs when details=true is absent, and the detailed payload when it is present.
  5. Mock fetch() to return PDF blobs, following the existing envelope tests in this file.
  6. Mount the component after configuring the mocks and use flushPromises() to wait for asynchronous loading.

Then verify that:

  • Each expected PDF URL was fetched.
  • PdfEditor receives the expected number of files and their corresponding filenames.
  • No PDF loading error is reported.

Also, the existing generateOcsUrl mock should prepend only /ocs/v2.php, since the component already supplies /apps/libresign in the path.

Without this fix, the standalone document scenario should pass and the envelope scenario should fail. With this fix, both should pass.

This will protect the actual signing workflow rather than only the presence of a query parameter.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed guidance! Done in the latest commit:

  • Replaced the query-parameter check with it.each over { nodeType: 'file', fileCount: 1 } and { nodeType: 'envelope', fileCount: 2 }, mounting on the SignPDF route with fetchFileDetail() returning the document/envelope and loadState() simulating a fresh page load.
  • For the envelope, axios.get() returns the summary payload (no PDF URLs) unless details=true is present, then the detailed payload.
  • Asserts each PDF URL is fetched, PdfEditor receives the expected number of files and file names, and no PDF load error is reported.
  • Fixed the generateOcsUrl mock to prepend only /ocs/v2.php (my previous assertion would have checked a duplicated path).

Local results (npx vitest run src/tests/views/SignPDF/SignPDF.spec.ts):

  • With the fix: 10/10 passing.
  • Without the fix (details: 'true' removed): the file scenario passes and the envelope scenario fails with expected "vi.fn()" to be called 2 times, but got 0 times.

ESLint is clean on both changed files.

)

Signed-off-by: Buzepool <pedrokenorhue@gmail.com>
@Buzepool
Buzepool requested a review from vitormattos November 25, 2026 12:30

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Envelope: "Failed to load envelope files" on /f/sign/{uuid} because file/list is called without details=true

2 participants