Skip to content

Commit 6eea78c

Browse files
committed
test(sign): complete stable33 backport regressions
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 821ab31 commit 6eea78c

1 file changed

Lines changed: 123 additions & 56 deletions

File tree

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

Lines changed: 123 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -606,68 +606,135 @@ describe('Sign.vue - signWithTokenCode', () => {
606606
})
607607

608608
describe('Sign.vue - API error handling', () => {
609-
it('emits signed when envelope submit has mixed results and the final result is signed', async () => {
610-
const context = {
611-
loading: false,
612-
elements: [
613-
{ elementId: 101, signRequestId: 501, type: 'signature' },
614-
{ elementId: 102, signRequestId: 502, type: 'signature' },
615-
],
616-
canCreateSignature: false,
617-
signRequestUuid: 'fallback-uuid',
618-
signatureElementsStore: {
619-
signs: {},
620-
},
621-
actionHandler: {
622-
showModal: vi.fn(),
623-
closeModal: vi.fn(),
624-
},
625-
signMethodsStore: {
626-
certificateEngine: 'openssl',
609+
it('emits signed when envelope submit has mixed results and the final result is signed', async () => {
610+
const context = {
611+
loading: false,
612+
elements: [
613+
{ elementId: 101, signRequestId: 501, type: 'signature' },
614+
{ elementId: 102, signRequestId: 502, type: 'signature' },
615+
],
616+
canCreateSignature: false,
617+
signRequestUuid: 'fallback-uuid',
618+
signatureElementsStore: {
619+
signs: {},
620+
},
621+
actionHandler: {
622+
showModal: vi.fn(),
623+
closeModal: vi.fn(),
624+
},
625+
signMethodsStore: {
626+
certificateEngine: 'openssl',
627+
},
628+
signStore: {
629+
document: {
630+
id: 10,
631+
nodeType: 'envelope',
632+
signers: [
633+
{ me: true, signRequestId: 501, sign_request_uuid: 'uuid-file-a' },
634+
{ me: true, signRequestId: 502, sign_request_uuid: 'uuid-file-b' },
635+
],
627636
},
628-
signStore: {
629-
document: {
630-
id: 10,
631-
nodeType: 'envelope',
632-
signers: [
633-
{ me: true, signRequestId: 501, sign_request_uuid: 'uuid-file-a' },
634-
{ me: true, signRequestId: 502, sign_request_uuid: 'uuid-file-b' },
635-
],
636-
},
637-
clearSigningErrors: vi.fn(),
638-
setSigningErrors: vi.fn(),
639-
submitSignature: vi.fn()
640-
.mockResolvedValueOnce({
641-
status: 'signingInProgress',
642-
data: {},
643-
})
644-
.mockResolvedValueOnce({
645-
status: 'signed',
646-
data: {
647-
action: 3500,
637+
clearSigningErrors: vi.fn(),
638+
setSigningErrors: vi.fn(),
639+
submitSignature: vi.fn()
640+
.mockResolvedValueOnce({
641+
status: 'signingInProgress',
642+
data: {
643+
job: {
644+
file: { uuid: 'async-validation-uuid' },
648645
},
649-
}),
650-
},
651-
$emit: vi.fn(),
652-
sidebarStore: {
653-
hideSidebar: vi.fn(),
654-
},
655-
}
646+
},
647+
})
648+
.mockResolvedValueOnce({
649+
status: 'signed',
650+
data: {
651+
action: 3500,
652+
file: { uuid: 'validation-envelope-uuid' },
653+
},
654+
}),
655+
},
656+
$emit: vi.fn(),
657+
sidebarStore: {
658+
hideSidebar: vi.fn(),
659+
},
660+
}
656661

657-
await submitSignatureCompatMethod.call(context, {
658-
method: 'password',
659-
token: '123456',
660-
})
662+
await submitSignatureCompatMethod.call(context, {
663+
method: 'password',
664+
token: '123456',
665+
})
666+
667+
expect(context.signStore.submitSignature).toHaveBeenCalledTimes(2)
668+
expect(context.$emit).toHaveBeenCalledWith('signed', expect.objectContaining({
669+
action: 3500,
670+
signRequestUuid: 'validation-envelope-uuid',
671+
}))
672+
expect(context.$emit).not.toHaveBeenCalledWith('signing-started', expect.anything())
673+
expect(context.loading).toBe(false)
674+
})
661675

662-
expect(context.signStore.submitSignature).toHaveBeenCalledTimes(2)
663-
expect(context.$emit).toHaveBeenCalledWith('signed', expect.objectContaining({
664-
action: 3500,
665-
signRequestUuid: 'uuid-file-a',
666-
}))
667-
expect(context.$emit).not.toHaveBeenCalledWith('signing-started', expect.anything())
668-
expect(context.loading).toBe(false)
676+
it('emits signed when an earlier envelope submission is signed and a later one is unknown', async () => {
677+
const context = {
678+
loading: false,
679+
elements: [
680+
{ elementId: 101, signRequestId: 501, type: 'signature' },
681+
{ elementId: 102, signRequestId: 502, type: 'signature' },
682+
],
683+
canCreateSignature: false,
684+
signRequestUuid: 'fallback-uuid',
685+
signatureElementsStore: {
686+
signs: {},
687+
},
688+
actionHandler: {
689+
showModal: vi.fn(),
690+
closeModal: vi.fn(),
691+
},
692+
signMethodsStore: {
693+
certificateEngine: 'openssl',
694+
},
695+
signStore: {
696+
document: {
697+
id: 10,
698+
nodeType: 'envelope',
699+
signers: [
700+
{ me: true, signRequestId: 501, sign_request_uuid: 'uuid-file-a' },
701+
{ me: true, signRequestId: 502, sign_request_uuid: 'uuid-file-b' },
702+
],
703+
},
704+
clearSigningErrors: vi.fn(),
705+
setSigningErrors: vi.fn(),
706+
submitSignature: vi.fn()
707+
.mockResolvedValueOnce({
708+
status: 'signed',
709+
data: {
710+
action: 3500,
711+
file: { uuid: 'validation-envelope-uuid' },
712+
},
713+
})
714+
.mockResolvedValueOnce({
715+
status: 'unknown',
716+
data: {},
717+
}),
718+
},
719+
$emit: vi.fn(),
720+
sidebarStore: {
721+
hideSidebar: vi.fn(),
722+
},
723+
}
724+
725+
await submitSignatureCompatMethod.call(context, {
726+
method: 'password',
727+
token: '123456',
669728
})
670729

730+
expect(context.signStore.submitSignature).toHaveBeenCalledTimes(2)
731+
expect(context.$emit).toHaveBeenCalledWith('signed', expect.objectContaining({
732+
action: 3500,
733+
signRequestUuid: 'validation-envelope-uuid',
734+
}))
735+
expect(context.$emit).not.toHaveBeenCalledWith('signing-started', expect.anything())
736+
})
737+
671738
it('keeps certificate validation errors in signStore and does not open certificate modal', async () => {
672739
const apiErrors = [{ message: 'Certificate has been revoked', code: 422 }]
673740
const context = {

0 commit comments

Comments
 (0)