Skip to content

Commit 53372d3

Browse files
test(sign-view): keep certificate revocation errors in UI state
Add submitSignature test for API signError with revoked certificate response. Verify the certificate modal is not opened and signing errors are stored for user feedback. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 5c2c5fa commit 53372d3

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,53 @@ describe('Sign.vue - signWithTokenCode', () => {
400400
})
401401
})
402402

403+
describe('Sign.vue - API error handling', () => {
404+
it('keeps certificate validation errors in signStore and does not open certificate modal', async () => {
405+
const SignComponent = await import('../../../views/SignPDF/_partials/Sign.vue')
406+
const submitSignature = (SignComponent.default as any).methods.submitSignature
407+
408+
const apiErrors = [{ message: 'Certificate has been revoked', code: 422 }]
409+
const context = {
410+
loading: false,
411+
elements: [],
412+
canCreateSignature: false,
413+
signRequestUuid: 'test-sign-request-uuid',
414+
signMethodsStore: {
415+
certificateEngine: 'openssl',
416+
},
417+
signatureElementsStore: {
418+
signs: {},
419+
},
420+
actionHandler: {
421+
showModal: vi.fn(),
422+
closeModal: vi.fn(),
423+
},
424+
signStore: {
425+
document: { id: 10 },
426+
clearSigningErrors: vi.fn(),
427+
setSigningErrors: vi.fn(),
428+
submitSignature: vi.fn().mockRejectedValue({
429+
type: 'signError',
430+
errors: apiErrors,
431+
}),
432+
},
433+
$emit: vi.fn(),
434+
sidebarStore: {
435+
hideSidebar: vi.fn(),
436+
},
437+
}
438+
439+
await submitSignature.call(context, {
440+
method: 'password',
441+
token: '123456',
442+
})
443+
444+
expect(context.actionHandler.showModal).not.toHaveBeenCalled()
445+
expect(context.signStore.setSigningErrors).toHaveBeenCalledWith(apiErrors)
446+
expect(context.loading).toBe(false)
447+
})
448+
})
449+
403450
describe('proceedWithSigning - Full flow with WhatsApp token', () => {
404451
let proceedWithSigningLogic: ProceedWithSigningLogic
405452

0 commit comments

Comments
 (0)