Skip to content

Commit ac02b6e

Browse files
test: reject invalid status payloads in validation view
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 698dc45 commit ac02b6e

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

src/tests/views/Validation.spec.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,4 +985,67 @@ describe('Validation.vue - Business Logic', () => {
985985
})
986986
})
987987
})
988+
989+
describe('status contract guards', () => {
990+
const createLoadedValidationDocument = (patch: Record<string, unknown> = {}) => ({
991+
id: 100,
992+
uuid: '550e8400-e29b-41d4-a716-446655440000',
993+
name: 'contract.pdf',
994+
statusText: 'Pending',
995+
nodeId: 100,
996+
nodeType: 'file',
997+
signatureFlow: 0,
998+
docmdpLevel: 0,
999+
filesCount: 1,
1000+
files: [{
1001+
id: 100,
1002+
uuid: '550e8400-e29b-41d4-a716-446655440000',
1003+
name: 'contract.pdf',
1004+
status: 1,
1005+
statusText: 'Pending',
1006+
nodeId: 100,
1007+
totalPages: 1,
1008+
size: 10,
1009+
pdfVersion: '1.7',
1010+
signers: [],
1011+
file: '/apps/libresign/p/pdf/550e8400-e29b-41d4-a716-446655440000',
1012+
metadata: { extension: 'pdf', p: 1 },
1013+
}],
1014+
totalPages: 1,
1015+
size: 10,
1016+
pdfVersion: '1.7',
1017+
created_at: '2026-01-01T00:00:00Z',
1018+
requested_by: { userId: 'creator-user', displayName: 'Creator User' },
1019+
status: 1,
1020+
signers: [],
1021+
...patch,
1022+
})
1023+
1024+
it('rejects document payload when status is null', () => {
1025+
wrapper.vm.handleValidationSuccess(createLoadedValidationDocument({ status: null }))
1026+
1027+
expect(wrapper.vm.document).toBe(null)
1028+
expect(wrapper.vm.validationErrorMessage).toBe('Failed to validate document')
1029+
})
1030+
1031+
it('rejects document payload when signer status is out of range', () => {
1032+
wrapper.vm.handleValidationSuccess(createLoadedValidationDocument({
1033+
signers: [{
1034+
signRequestId: 1,
1035+
displayName: 'Signer',
1036+
email: 'signer@example.com',
1037+
signed: null,
1038+
status: 99,
1039+
statusText: 'Invalid',
1040+
description: null,
1041+
request_sign_date: '2026-01-01T00:00:00Z',
1042+
me: false,
1043+
visibleElements: [],
1044+
}],
1045+
}))
1046+
1047+
expect(wrapper.vm.document).toBe(null)
1048+
expect(wrapper.vm.validationErrorMessage).toBe('Failed to validate document')
1049+
})
1050+
})
9881051
})

0 commit comments

Comments
 (0)