@@ -1023,6 +1023,57 @@ describe('Sign.vue - signWithTokenCode', () => {
10231023 expect ( wrapper . vm . hasSignatures ) . toBe ( true )
10241024 expect ( wrapper . vm . needCreateSignature ) . toBe ( false )
10251025 } )
1026+
1027+ it ( 'returns false for needCreateSignature when signer has no placed visibleElements (clickToSign scenario)' , async ( ) => {
1028+ // Regression: commit e9ea79495 removed visibleElements.some() check, causing
1029+ // needCreateSignature to return true for clickToSign documents where no visual
1030+ // element box was placed — hiding the "Sign the document." button.
1031+ const { default : realSign } = await import ( '../../../views/SignPDF/_partials/Sign.vue' )
1032+ const { useSignStore } = await import ( '../../../store/sign.js' )
1033+
1034+ const signStore = useSignStore ( )
1035+
1036+ // Signer has signRequestId but NO placed visibleElements (typical clickToSign)
1037+ signStore . document = {
1038+ id : 1 ,
1039+ nodeType : 'file' ,
1040+ signers : [
1041+ { signRequestId : 501 , me : true } ,
1042+ ] ,
1043+ visibleElements : [ ] ,
1044+ }
1045+
1046+ const wrapper = mount ( realSign , {
1047+ global : {
1048+ stubs : {
1049+ NcButton : true ,
1050+ NcDialog : true ,
1051+ NcLoadingIcon : true ,
1052+ TokenManager : true ,
1053+ EmailManager : true ,
1054+ UploadCertificate : true ,
1055+ Documents : true ,
1056+ Signatures : true ,
1057+ Draw : true ,
1058+ ManagePassword : true ,
1059+ CreatePassword : true ,
1060+ NcNoteCard : true ,
1061+ NcPasswordField : true ,
1062+ NcRichText : true ,
1063+ } ,
1064+ mocks : {
1065+ $watch : vi . fn ( ) ,
1066+ } ,
1067+ } ,
1068+ } )
1069+
1070+ // canCreateSignature is true (mocked globally), but no element was placed for
1071+ // this signer, so we must NOT show "Define your signature" — the "Sign the
1072+ // document." button should be reachable.
1073+ expect ( wrapper . vm . canCreateSignature ) . toBe ( true )
1074+ expect ( wrapper . vm . hasSignatures ) . toBe ( false )
1075+ expect ( wrapper . vm . needCreateSignature ) . toBe ( false )
1076+ } )
10261077 } )
10271078
10281079 describe ( 'Sign.vue - create signature modal' , ( ) => {
0 commit comments