@@ -232,8 +232,13 @@ describe('Sign.vue - signWithTokenCode', () => {
232232 throw new Error ( 'No active token method found' )
233233 }
234234
235+ const identifyMethod = this . signMethodsStore . settings [ activeMethod ] ?. identifyMethod
236+ if ( ! identifyMethod ) {
237+ throw new Error ( 'No identify method found for active token method' )
238+ }
239+
235240 await this . submitSignature ( {
236- method : activeMethod ,
241+ method : identifyMethod ,
237242 token,
238243 } )
239244 } ,
@@ -251,7 +256,7 @@ describe('Sign.vue - signWithTokenCode', () => {
251256 describe ( 'signWithTokenCode' , ( ) => {
252257 it ( 'detects SMS token method' , async ( ) => {
253258 signMethodsStore . settings = {
254- smsToken : { needCode : true } ,
259+ smsToken : { needCode : true , identifyMethod : 'sms' } ,
255260 }
256261
257262 const instance = {
@@ -262,14 +267,14 @@ describe('Sign.vue - signWithTokenCode', () => {
262267 await instance . signWithTokenCode ( '123456' )
263268
264269 expect ( submitSignatureSpy ) . toHaveBeenCalledWith ( {
265- method : 'smsToken ' ,
270+ method : 'sms ' ,
266271 token : '123456' ,
267272 } )
268273 } )
269274
270275 it ( 'detects WhatsApp token method' , async ( ) => {
271276 signMethodsStore . settings = {
272- whatsappToken : { needCode : true } ,
277+ whatsappToken : { needCode : true , identifyMethod : 'whatsapp' } ,
273278 }
274279
275280 const instance = {
@@ -280,14 +285,14 @@ describe('Sign.vue - signWithTokenCode', () => {
280285 await instance . signWithTokenCode ( '789012' )
281286
282287 expect ( submitSignatureSpy ) . toHaveBeenCalledWith ( {
283- method : 'whatsappToken ' ,
288+ method : 'whatsapp ' ,
284289 token : '789012' ,
285290 } )
286291 } )
287292
288293 it ( 'successfully processes WhatsApp token signing' , async ( ) => {
289294 signMethodsStore . settings = {
290- whatsappToken : { needCode : true } ,
295+ whatsappToken : { needCode : true , identifyMethod : 'whatsapp' } ,
291296 }
292297
293298 const instance = {
@@ -298,14 +303,14 @@ describe('Sign.vue - signWithTokenCode', () => {
298303 await instance . signWithTokenCode ( '654321' )
299304
300305 expect ( submitSignatureSpy ) . toHaveBeenCalledWith ( {
301- method : 'whatsappToken ' ,
306+ method : 'whatsapp ' ,
302307 token : '654321' ,
303308 } )
304309 } )
305310
306311 it ( 'detects Signal token method' , async ( ) => {
307312 signMethodsStore . settings = {
308- signalToken : { needCode : true } ,
313+ signalToken : { needCode : true , identifyMethod : 'signal' } ,
309314 }
310315
311316 const instance = {
@@ -316,14 +321,14 @@ describe('Sign.vue - signWithTokenCode', () => {
316321 await instance . signWithTokenCode ( '456789' )
317322
318323 expect ( submitSignatureSpy ) . toHaveBeenCalledWith ( {
319- method : 'signalToken ' ,
324+ method : 'signal ' ,
320325 token : '456789' ,
321326 } )
322327 } )
323328
324329 it ( 'detects Telegram token method' , async ( ) => {
325330 signMethodsStore . settings = {
326- telegramToken : { needCode : true } ,
331+ telegramToken : { needCode : true , identifyMethod : 'telegram' } ,
327332 }
328333
329334 const instance = {
@@ -334,14 +339,14 @@ describe('Sign.vue - signWithTokenCode', () => {
334339 await instance . signWithTokenCode ( '012345' )
335340
336341 expect ( submitSignatureSpy ) . toHaveBeenCalledWith ( {
337- method : 'telegramToken ' ,
342+ method : 'telegram ' ,
338343 token : '012345' ,
339344 } )
340345 } )
341346
342347 it ( 'detects XMPP token method' , async ( ) => {
343348 signMethodsStore . settings = {
344- xmppToken : { needCode : true } ,
349+ xmppToken : { needCode : true , identifyMethod : 'xmpp' } ,
345350 }
346351
347352 const instance = {
@@ -352,16 +357,16 @@ describe('Sign.vue - signWithTokenCode', () => {
352357 await instance . signWithTokenCode ( '678901' )
353358
354359 expect ( submitSignatureSpy ) . toHaveBeenCalledWith ( {
355- method : 'xmppToken ' ,
360+ method : 'xmpp ' ,
356361 token : '678901' ,
357362 } )
358363 } )
359364
360365 it ( 'prefers first token method when multiple are present' , async ( ) => {
361366 signMethodsStore . settings = {
362- smsToken : { needCode : true } ,
363- whatsappToken : { needCode : true } ,
364- signalToken : { needCode : true } ,
367+ smsToken : { needCode : true , identifyMethod : 'sms' } ,
368+ whatsappToken : { needCode : true , identifyMethod : 'whatsapp' } ,
369+ signalToken : { needCode : true , identifyMethod : 'signal' } ,
365370 }
366371
367372 const instance = {
@@ -372,7 +377,7 @@ describe('Sign.vue - signWithTokenCode', () => {
372377 await instance . signWithTokenCode ( '111111' )
373378
374379 expect ( submitSignatureSpy ) . toHaveBeenCalledWith ( {
375- method : 'smsToken ' ,
380+ method : 'sms ' ,
376381 token : '111111' ,
377382 } )
378383 } )
@@ -408,7 +413,7 @@ describe('Sign.vue - signWithTokenCode', () => {
408413
409414 it ( 'passes token correctly to submitSignature' , async ( ) => {
410415 signMethodsStore . settings = {
411- smsToken : { needCode : true } ,
416+ smsToken : { needCode : true , identifyMethod : 'sms' } ,
412417 }
413418
414419 const instance = {
@@ -420,7 +425,7 @@ describe('Sign.vue - signWithTokenCode', () => {
420425 await instance . signWithTokenCode ( testToken )
421426
422427 expect ( submitSignatureSpy ) . toHaveBeenCalledWith ( {
423- method : 'smsToken ' ,
428+ method : 'sms ' ,
424429 token : testToken ,
425430 } )
426431 } )
@@ -430,7 +435,7 @@ describe('Sign.vue - signWithTokenCode', () => {
430435 clickToSign : { } ,
431436 emailToken : { needCode : true } ,
432437 password : { hasSignatureFile : true } ,
433- smsToken : { needCode : true } ,
438+ smsToken : { needCode : true , identifyMethod : 'sms' } ,
434439 }
435440
436441 const instance = {
@@ -441,10 +446,25 @@ describe('Sign.vue - signWithTokenCode', () => {
441446 await instance . signWithTokenCode ( '123456' )
442447
443448 expect ( submitSignatureSpy ) . toHaveBeenCalledWith ( {
444- method : 'smsToken ' ,
449+ method : 'sms ' ,
445450 token : '123456' ,
446451 } )
447452 } )
453+
454+ it ( 'throws error when active token method has no identify method' , async ( ) => {
455+ signMethodsStore . settings = {
456+ smsToken : { needCode : true } ,
457+ }
458+
459+ const instance = {
460+ ...Sign . data ( ) ,
461+ ...Sign . methods ,
462+ }
463+
464+ await expect ( instance . signWithTokenCode ( '123456' ) ) . rejects . toThrow ( 'No identify method found for active token method' )
465+
466+ expect ( submitSignatureSpy ) . not . toHaveBeenCalled ( )
467+ } )
448468 } )
449469
450470 describe ( 'Sign.vue - API error handling' , ( ) => {
@@ -614,8 +634,13 @@ describe('Sign.vue - signWithTokenCode', () => {
614634 throw new Error ( 'No active token method found' )
615635 }
616636
637+ const identifyMethod = this . signMethodsStore . settings [ activeMethod ] ?. identifyMethod
638+ if ( ! identifyMethod ) {
639+ throw new Error ( 'No identify method found for active token method' )
640+ }
641+
617642 await this . submitSignature ( {
618- method : activeMethod ,
643+ method : identifyMethod ,
619644 token,
620645 } )
621646 } ,
@@ -640,7 +665,7 @@ describe('Sign.vue - signWithTokenCode', () => {
640665
641666 it ( 'complete flow: click sign button -> token modal opens -> submit token' , async ( ) => {
642667 signMethodsStore . settings = {
643- whatsappToken : { needCode : true } ,
668+ whatsappToken : { needCode : true , identifyMethod : 'whatsapp' } ,
644669 }
645670
646671 const instance = {
@@ -658,16 +683,16 @@ describe('Sign.vue - signWithTokenCode', () => {
658683
659684 // Verify the submission happened
660685 expect ( submitSignatureSpy ) . toHaveBeenCalledWith ( {
661- method : 'whatsappToken ' ,
686+ method : 'whatsapp ' ,
662687 token : '123456' ,
663688 } )
664689 } )
665690
666691 it ( 'complete flow: click sign with multiple token methods enables first available' , async ( ) => {
667692 signMethodsStore . settings = {
668- smsToken : { needCode : true } ,
669- whatsappToken : { needCode : true } ,
670- telegramToken : { needCode : true } ,
693+ smsToken : { needCode : true , identifyMethod : 'sms' } ,
694+ whatsappToken : { needCode : true , identifyMethod : 'whatsapp' } ,
695+ telegramToken : { needCode : true , identifyMethod : 'telegram' } ,
671696 }
672697
673698 const instance = {
@@ -684,7 +709,7 @@ describe('Sign.vue - signWithTokenCode', () => {
684709
685710 // Verify the submission happened with SMS token
686711 expect ( submitSignatureSpy ) . toHaveBeenCalledWith ( {
687- method : 'smsToken ' ,
712+ method : 'sms ' ,
688713 token : '999999' ,
689714 } )
690715 } )
@@ -883,6 +908,7 @@ describe('Sign.vue - signWithTokenCode', () => {
883908
884909 describe ( 'signWithTokenCode - REAL component integration test' , ( ) => {
885910 it ( 'INTEGRATION: extracts and sends correct identify method from signature methods data' , async ( ) => {
911+ const { useSignStore } = await import ( '../../../store/sign.js' )
886912 const testCases = [
887913 {
888914 name : 'WhatsApp token' ,
@@ -912,6 +938,7 @@ describe('Sign.vue - signWithTokenCode', () => {
912938 const realSign = SignComponent . default
913939
914940 const signMethodsStore = useSignMethodsStore ( )
941+ const signStore = useSignStore ( )
915942
916943 // Set up signature method with identify method info
917944 signMethodsStore . settings = {
@@ -922,7 +949,13 @@ describe('Sign.vue - signWithTokenCode', () => {
922949 } ,
923950 }
924951
952+ signStore . document = createSignDocument ( {
953+ id : 99 ,
954+ signRequestUuid : 'test-sign-request-uuid' ,
955+ } )
956+
925957 const submitSignatureMock = vi . fn ( ) . mockResolvedValue ( { status : 'signed' } )
958+ signStore . submitSignature = submitSignatureMock as SignStore [ 'submitSignature' ]
926959
927960 // Mount REAL component
928961 const wrapper = mount ( realSign , {
@@ -951,22 +984,20 @@ describe('Sign.vue - signWithTokenCode', () => {
951984 props : { } ,
952985 } )
953986
954- wrapper . vm . submitSignature = submitSignatureMock
955-
956987 // Call real signWithTokenCode method
957988 await wrapper . vm . signWithTokenCode ( testCase . token )
958989
959990 // VERIFY: Must send identify method, NOT signature method name
960991 expect ( submitSignatureMock ) . toHaveBeenCalledWith ( {
961- method : testCase . expectedIdentifyMethod , // 'whatsapp', 'sms', 'signal'
962- modalCode : 'token' ,
992+ method : testCase . expectedIdentifyMethod ,
963993 token : testCase . token ,
994+ } , 'test-sign-request-uuid' , {
995+ documentId : 99 ,
964996 } )
965997
966998 // Double-check: Should NOT send the signature method key name
967999 expect ( submitSignatureMock ) . not . toHaveBeenCalledWith ( {
968- method : testCase . signatureMethodKey , // NOT 'whatsappToken', 'smsToken', etc
969- modalCode : 'token' ,
1000+ method : testCase . signatureMethodKey ,
9701001 token : testCase . token ,
9711002 } )
9721003 }
@@ -1235,6 +1266,9 @@ describe('Sign.vue - signWithTokenCode', () => {
12351266 const SignComponent = await import ( '../../../views/SignPDF/_partials/Sign.vue' )
12361267 const realSign = SignComponent . default
12371268 const signMethodsStore = useSignMethodsStore ( )
1269+ const { useSignStore } = await import ( '../../../store/sign.js' )
1270+ const signStore = useSignStore ( )
1271+ signStore . document = createSignDocument ( )
12381272 signMethodsStore . showModal ( 'createSignature' )
12391273
12401274 const wrapper = mount ( realSign , {
0 commit comments