@@ -38,6 +38,7 @@ const filesStoreMock = {
3838 nodeId : 17 ,
3939 nodeType : 'file' ,
4040 signers : [ { me : true , sign_uuid : 'sign-uuid' } ] ,
41+ settings : { signerFileUuid : '' } ,
4142 } ) ) ,
4243 getAllFiles : vi . fn ( async ( ) => ( {
4344 1 : { id : 1 , uuid : 'file-uuid' } ,
@@ -48,6 +49,7 @@ const filesStoreMock = {
4849
4950const sidebarStoreMock = {
5051 hideSidebar : vi . fn ( ) ,
52+ activeSignTab : vi . fn ( ) ,
5153 activeRequestSignatureTab : vi . fn ( ) ,
5254}
5355
@@ -177,6 +179,7 @@ describe('FileEntryActions.vue', () => {
177179 filesStoreMock . delete . mockReset ( )
178180 filesStoreMock . rename . mockReset ( )
179181 sidebarStoreMock . hideSidebar . mockReset ( )
182+ sidebarStoreMock . activeSignTab . mockReset ( )
180183 sidebarStoreMock . activeRequestSignatureTab . mockReset ( )
181184 signStoreMock . setFileToSign . mockReset ( )
182185 routerPushMock . mockReset ( )
@@ -221,7 +224,7 @@ describe('FileEntryActions.vue', () => {
221224
222225 await wrapper . vm . onActionClick ( { id : 'sign' } )
223226
224- expect ( sidebarStoreMock . hideSidebar ) . toHaveBeenCalledTimes ( 1 )
227+ expect ( sidebarStoreMock . hideSidebar ) . not . toHaveBeenCalled ( )
225228 expect ( filesStoreMock . fetchFileDetail ) . toHaveBeenCalledWith ( {
226229 fileId : 1 ,
227230 force : true ,
@@ -236,7 +239,64 @@ describe('FileEntryActions.vue', () => {
236239 params : { uuid : 'sign-uuid' } ,
237240 } )
238241 expect ( filesStoreMock . selectFile ) . toHaveBeenCalledWith ( 1 )
239- expect ( sidebarStoreMock . activeRequestSignatureTab ) . toHaveBeenCalledTimes ( 1 )
242+ expect ( sidebarStoreMock . activeSignTab ) . toHaveBeenCalledTimes ( 1 )
243+ expect ( sidebarStoreMock . activeRequestSignatureTab ) . not . toHaveBeenCalled ( )
244+ } )
245+
246+ it ( 'closes the sidebar before routing to validation' , async ( ) => {
247+ const wrapper = createWrapper ( )
248+
249+ await wrapper . vm . onActionClick ( { id : 'validate' } )
250+
251+ expect ( sidebarStoreMock . hideSidebar ) . toHaveBeenCalledTimes ( 1 )
252+ expect ( routerPushMock ) . toHaveBeenCalledWith ( {
253+ name : 'ValidationFile' ,
254+ params : { uuid : 'file-uuid' } ,
255+ } )
256+ } )
257+
258+ it ( 'falls back to the current signer UUID when file detail has no signUuid' , async ( ) => {
259+ filesStoreMock . fetchFileDetail . mockResolvedValueOnce ( {
260+ id : 1 ,
261+ uuid : 'file-uuid' ,
262+ signUuid : '' ,
263+ name : 'contract.pdf' ,
264+ nodeId : 17 ,
265+ nodeType : 'file' ,
266+ signers : [ { me : true , sign_uuid : 'signer-uuid' } ] ,
267+ settings : { signerFileUuid : '' } ,
268+ } )
269+
270+ const wrapper = createWrapper ( )
271+
272+ await wrapper . vm . onActionClick ( { id : 'sign' } )
273+
274+ expect ( routerPushMock ) . toHaveBeenCalledWith ( {
275+ name : 'SignPDF' ,
276+ params : { uuid : 'signer-uuid' } ,
277+ } )
278+ } )
279+
280+ it ( 'falls back to signerFileUuid when file detail has no signUuid or signer UUID' , async ( ) => {
281+ filesStoreMock . fetchFileDetail . mockResolvedValueOnce ( {
282+ id : 1 ,
283+ uuid : 'file-uuid' ,
284+ signUuid : '' ,
285+ name : 'contract.pdf' ,
286+ nodeId : 17 ,
287+ nodeType : 'file' ,
288+ signers : [ ] ,
289+ settings : { signerFileUuid : 'signer-file-uuid' } ,
290+ } )
291+
292+ const wrapper = createWrapper ( )
293+
294+ await wrapper . vm . onActionClick ( { id : 'sign' } )
295+
296+ expect ( routerPushMock ) . toHaveBeenCalledWith ( {
297+ name : 'SignPDF' ,
298+ params : { uuid : 'signer-file-uuid' } ,
299+ } )
240300 } )
241301
242302 it ( 'routes validation, rename and open actions to the expected targets' , async ( ) => {
0 commit comments