Skip to content

Commit bd7b017

Browse files
test(SigningRequirementValidator): add failing test for createSignature without placed elements
When admin sets GRAPHIC_ONLY render mode (canCreateSignature=true), the signer must draw their signature even if no visual element box was placed on the document. The previous check required visibleElements.some(...) which returned false for documents with no placed boxes, silently skipping the drawing prompt. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent ba1df88 commit bd7b017

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/tests/services/SigningRequirementValidator.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,29 @@ describe('SigningRequirementValidator', () => {
162162
expect(result).toBe(false)
163163
})
164164

165+
it('requires createSignature even when document has no placed elements but canCreateSignature is true and user is signer', () => {
166+
// When admin configures GRAPHIC_ONLY mode, canCreateSignature=true.
167+
// The signer must draw their signature even if no element box was placed on the document.
168+
const stores = createStores({
169+
signStore: {
170+
document: {
171+
signers: [{ me: true, signRequestId: 10 }],
172+
visibleElements: [],
173+
},
174+
},
175+
})
176+
const validator = new SigningRequirementValidator(
177+
stores.signStore,
178+
stores.signMethodsStore,
179+
stores.identificationDocumentStore,
180+
)
181+
182+
// With no placed element AND canCreateSignature=true, we still need to create the signature
183+
const result = validator.needsCreateSignature({ hasSignatures: false, canCreateSignature: true, signerHasSignRequest: true })
184+
185+
expect(result).toBe(true)
186+
})
187+
165188
it('returns createSignature before clickToSign when no signature exists', () => {
166189
const stores = createStores({
167190
signMethodsStore: {

0 commit comments

Comments
 (0)