Skip to content

Commit 2750bcc

Browse files
committed
test(sign-pdf): canonical files[0].file URL takes priority over legacy url
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 1e02ed0 commit 2750bcc

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

src/tests/views/SignPDF/SignPDF.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,42 @@ describe('SignPDF.vue', () => {
297297
])
298298
})
299299

300+
it('prefers canonical files collection URL when loading single-file PDF', async () => {
301+
const SignPDF = (await import('../../../views/SignPDF/SignPDF.vue')).default
302+
const { useSignStore } = await import('../../../store/sign.js')
303+
const signStore = useSignStore()
304+
const fetchMock = vi.fn().mockResolvedValue({
305+
headers: {
306+
get: vi.fn(() => 'application/pdf'),
307+
},
308+
blob: vi.fn(async () => new Blob(['pdf'], { type: 'application/pdf' })),
309+
})
310+
vi.stubGlobal('fetch', fetchMock)
311+
312+
signStore.document = createSignDocument({
313+
nodeType: 'file',
314+
url: '/legacy-root-url.pdf',
315+
files: [
316+
{ id: 99, name: 'contract', file: '/canonical-file-url.pdf', metadata: { extension: 'pdf' } },
317+
],
318+
})
319+
320+
const wrapper = mount(SignPDF, {
321+
global: {
322+
stubs: {
323+
TopBar: true,
324+
NcNoteCard: true,
325+
NcButton: true,
326+
},
327+
mocks: {
328+
$route: { name: 'TestRoute', params: { uuid: 'uuid-123' }, query: {} },
329+
},
330+
},
331+
})
332+
await wrapper.vm.$nextTick()
333+
expect(fetchMock).toHaveBeenCalledWith('/canonical-file-url.pdf')
334+
})
335+
300336
it('loads the signing document from file validation when entering the internal sign route', async () => {
301337
const SignPDF = (await import('../../../views/SignPDF/SignPDF.vue')).default
302338
const { useFilesStore } = await import('../../../store/files.js')

0 commit comments

Comments
 (0)