Skip to content

Commit 2b0c1f2

Browse files
test: cover file entry action UUID routing
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 3537492 commit 2b0c1f2

1 file changed

Lines changed: 31 additions & 15 deletions

File tree

src/tests/views/FilesList/FileEntryActions.spec.ts

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const filesStoreMock = {
2222
name: 'contract.pdf',
2323
nodeId: 17,
2424
nodeType: 'file',
25-
signers: [{ me: true, sign_uuid: 'sign-uuid' }],
25+
signers: [{ me: true, sign_request_uuid: 'sign-request-uuid' }],
2626
},
2727
},
2828
canSign: vi.fn(() => true),
@@ -33,12 +33,11 @@ const filesStoreMock = {
3333
fetchFileDetail: vi.fn(async () => ({
3434
id: 1,
3535
uuid: 'file-uuid',
36-
signUuid: 'sign-uuid',
3736
name: 'contract.pdf',
3837
nodeId: 17,
3938
nodeType: 'file',
40-
signers: [{ me: true, sign_uuid: 'sign-uuid' }],
41-
settings: { signerFileUuid: '' },
39+
signers: [{ me: true, sign_request_uuid: 'sign-request-uuid' }],
40+
settings: { isApprover: false },
4241
})),
4342
getAllFiles: vi.fn(async () => ({
4443
1: { id: 1, uuid: 'file-uuid' },
@@ -155,7 +154,8 @@ describe('FileEntryActions.vue', () => {
155154
nodeType: 'file',
156155
status: 1,
157156
statusText: 'Pending',
158-
signers: [{ me: true, sign_uuid: 'sign-uuid' }],
157+
signers: [{ me: true, sign_request_uuid: 'sign-request-uuid' }],
158+
settings: { isApprover: false },
159159
}
160160

161161
const createWrapper = () => mount(FileEntryActions, {
@@ -232,11 +232,10 @@ describe('FileEntryActions.vue', () => {
232232
expect(signStoreMock.setFileToSign).toHaveBeenCalledWith(expect.objectContaining({
233233
id: 1,
234234
uuid: 'file-uuid',
235-
signUuid: 'sign-uuid',
236235
}))
237236
expect(routerPushMock).toHaveBeenCalledWith({
238237
name: 'SignPDF',
239-
params: { uuid: 'sign-uuid' },
238+
params: { uuid: 'sign-request-uuid' },
240239
})
241240
expect(filesStoreMock.selectFile).toHaveBeenCalledWith(1)
242241
expect(sidebarStoreMock.activeSignTab).toHaveBeenCalledTimes(1)
@@ -255,16 +254,15 @@ describe('FileEntryActions.vue', () => {
255254
})
256255
})
257256

258-
it('falls back to the current signer UUID when file detail has no signUuid', async () => {
257+
it('uses the current signer sign_request_uuid from file detail', async () => {
259258
filesStoreMock.fetchFileDetail.mockResolvedValueOnce({
260259
id: 1,
261260
uuid: 'file-uuid',
262-
signUuid: '',
263261
name: 'contract.pdf',
264262
nodeId: 17,
265263
nodeType: 'file',
266-
signers: [{ me: true, sign_uuid: 'signer-uuid' }],
267-
settings: { signerFileUuid: '' },
264+
signers: [{ me: true, sign_request_uuid: 'signer-uuid' }],
265+
settings: { isApprover: false },
268266
})
269267

270268
const wrapper = createWrapper()
@@ -277,16 +275,15 @@ describe('FileEntryActions.vue', () => {
277275
})
278276
})
279277

280-
it('falls back to signerFileUuid when file detail has no signUuid or signer UUID', async () => {
278+
it('uses the file uuid for approver signing routes', async () => {
281279
filesStoreMock.fetchFileDetail.mockResolvedValueOnce({
282280
id: 1,
283281
uuid: 'file-uuid',
284-
signUuid: '',
285282
name: 'contract.pdf',
286283
nodeId: 17,
287284
nodeType: 'file',
288285
signers: [],
289-
settings: { signerFileUuid: 'signer-file-uuid' },
286+
settings: { isApprover: true },
290287
})
291288

292289
const wrapper = createWrapper()
@@ -295,8 +292,27 @@ describe('FileEntryActions.vue', () => {
295292

296293
expect(routerPushMock).toHaveBeenCalledWith({
297294
name: 'SignPDF',
298-
params: { uuid: 'signer-file-uuid' },
295+
params: { uuid: 'file-uuid' },
296+
})
297+
})
298+
299+
it('does not route when the detail has no current signer uuid and the viewer is not an approver', async () => {
300+
filesStoreMock.fetchFileDetail.mockResolvedValueOnce({
301+
id: 1,
302+
uuid: 'file-uuid',
303+
name: 'contract.pdf',
304+
nodeId: 17,
305+
nodeType: 'file',
306+
signers: [],
307+
settings: { isApprover: false },
299308
})
309+
310+
const wrapper = createWrapper()
311+
312+
await wrapper.vm.onActionClick({ id: 'sign' })
313+
314+
expect(routerPushMock).not.toHaveBeenCalled()
315+
expect(signStoreMock.setFileToSign).not.toHaveBeenCalled()
300316
})
301317

302318
it('routes validation, rename and open actions to the expected targets', async () => {

0 commit comments

Comments
 (0)