Skip to content

Commit 413a66d

Browse files
committed
test(Sign): cover envelope validation uuid aggregation
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 061a0e0 commit 413a66d

1 file changed

Lines changed: 69 additions & 2 deletions

File tree

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

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,12 +502,17 @@ describe('Sign.vue - signWithTokenCode', () => {
502502
submitSignature: vi.fn()
503503
.mockResolvedValueOnce({
504504
status: 'signingInProgress',
505-
data: {},
505+
data: {
506+
job: {
507+
file: { uuid: 'async-validation-uuid' },
508+
},
509+
},
506510
})
507511
.mockResolvedValueOnce({
508512
status: 'signed',
509513
data: {
510514
action: 3500,
515+
file: { uuid: 'validation-envelope-uuid' },
511516
},
512517
}),
513518
},
@@ -525,12 +530,74 @@ describe('Sign.vue - signWithTokenCode', () => {
525530
expect(context.signStore.submitSignature).toHaveBeenCalledTimes(2)
526531
expect(context.$emit).toHaveBeenCalledWith('signed', expect.objectContaining({
527532
action: 3500,
528-
signRequestUuid: 'uuid-file-a',
533+
signRequestUuid: 'validation-envelope-uuid',
529534
}))
530535
expect(context.$emit).not.toHaveBeenCalledWith('signing-started', expect.anything())
531536
expect(context.loading).toBe(false)
532537
})
533538

539+
it('emits signed when an earlier envelope submission is signed and a later one is unknown', async () => {
540+
const context = {
541+
loading: false,
542+
elements: [
543+
{ elementId: 101, signRequestId: 501, type: 'signature' },
544+
{ elementId: 102, signRequestId: 502, type: 'signature' },
545+
],
546+
canCreateSignature: false,
547+
signRequestUuid: 'fallback-uuid',
548+
signatureElementsStore: {
549+
signs: {},
550+
},
551+
actionHandler: {
552+
showModal: vi.fn(),
553+
closeModal: vi.fn(),
554+
},
555+
signMethodsStore: {
556+
certificateEngine: 'openssl',
557+
},
558+
signStore: {
559+
document: {
560+
id: 10,
561+
nodeType: 'envelope',
562+
signers: [
563+
{ me: true, signRequestId: 501, sign_request_uuid: 'uuid-file-a' },
564+
{ me: true, signRequestId: 502, sign_request_uuid: 'uuid-file-b' },
565+
],
566+
},
567+
clearSigningErrors: vi.fn(),
568+
setSigningErrors: vi.fn(),
569+
submitSignature: vi.fn()
570+
.mockResolvedValueOnce({
571+
status: 'signed',
572+
data: {
573+
action: 3500,
574+
file: { uuid: 'validation-envelope-uuid' },
575+
},
576+
})
577+
.mockResolvedValueOnce({
578+
status: 'unknown',
579+
data: {},
580+
}),
581+
},
582+
$emit: vi.fn(),
583+
sidebarStore: {
584+
hideSidebar: vi.fn(),
585+
},
586+
}
587+
588+
await submitSignatureCompatMethod.call(context, {
589+
method: 'password',
590+
token: '123456',
591+
})
592+
593+
expect(context.signStore.submitSignature).toHaveBeenCalledTimes(2)
594+
expect(context.$emit).toHaveBeenCalledWith('signed', expect.objectContaining({
595+
action: 3500,
596+
signRequestUuid: 'validation-envelope-uuid',
597+
}))
598+
expect(context.$emit).not.toHaveBeenCalledWith('signing-started', expect.anything())
599+
})
600+
534601
it('keeps certificate validation errors in signStore and does not open certificate modal', async () => {
535602
const apiErrors = [{ message: 'Certificate has been revoked', code: 422 }]
536603
const context = {

0 commit comments

Comments
 (0)