@@ -503,4 +503,47 @@ public function testEnvelopeVisibleElementsIncludesChildFileElements(): void {
503503 $ this ->assertSame (200 , $ result ['visibleElements ' ][0 ]['signRequestId ' ]);
504504 $ this ->assertSame (20 , $ result ['visibleElements ' ][0 ]['fileId ' ]);
505505 }
506+
507+ public function testToArrayUsesSignerScopedSignRequestUuidForCurrentSignerUrl (): void {
508+ $ file = new \OCA \Libresign \Db \File ();
509+ $ file ->setId (1 );
510+ $ file ->setUuid ('file-uuid ' );
511+ $ file ->setName ('contract.pdf ' );
512+ $ file ->setStatus (1 );
513+ $ file ->setCreatedAt (new \DateTime ('2026-01-01T00:00:00Z ' ));
514+ $ file ->setNodeId (100 );
515+ $ file ->setSignatureFlow ('' );
516+ $ file ->setDocmdpLevel ('' );
517+ $ file ->setUserId ('creator-user ' );
518+
519+ $ creator = $ this ->createMock (\OCP \IUser::class);
520+ $ creator ->method ('getDisplayName ' )->willReturn ('Creator User ' );
521+
522+ $ this ->fileMapper ->method ('getTextOfStatus ' )->willReturn ('Status text ' );
523+ $ this ->fileMapper ->method ('getChildrenFiles ' )->willReturn ([]);
524+ $ this ->userManager ->method ('get ' )->with ('creator-user ' )->willReturn ($ creator );
525+ $ this ->urlGenerator ->method ('linkToRoute ' )->willReturnCallback (static function (string $ route , array $ params ): string {
526+ return sprintf ('%s:%s ' , $ route , $ params ['uuid ' ]);
527+ });
528+ $ this ->signersLoader ->expects ($ this ->once ())
529+ ->method ('loadLibreSignSigners ' )
530+ ->willReturnCallback (static function ($ fileEntity , \stdClass $ fileData ): void {
531+ $ fileData ->signers = [
532+ (object )[
533+ 'me ' => true ,
534+ 'sign_request_uuid ' => 'sign-request-uuid ' ,
535+ ],
536+ ];
537+ });
538+
539+ $ service = $ this ->createFileService ();
540+ $ result = $ service
541+ ->setFile ($ file )
542+ ->showSigners ()
543+ ->toArray ();
544+
545+ $ this ->assertSame ('libresign.page.getPdfFile:sign-request-uuid ' , $ result ['url ' ]);
546+ $ this ->assertArrayNotHasKey ('signUuid ' , $ result );
547+ $ this ->assertSame ('sign-request-uuid ' , $ result ['signers ' ][0 ]['sign_request_uuid ' ]);
548+ }
506549}
0 commit comments