55
66import { expect , test } from '@playwright/test'
77import { login } from '../support/nc-login'
8- import { configureOpenSsl } from '../support/nc-provisioning'
8+ import { configureOpenSsl , setAppConfig } from '../support/nc-provisioning'
99
1010test ( 'new signature request opens LibreSign tab and does not duplicate file row' , async ( { page } ) => {
1111 await login (
@@ -22,6 +22,16 @@ test('new signature request opens LibreSign tab and does not duplicate file row'
2222 L : 'Rio de Janeiro' ,
2323 } )
2424
25+ await setAppConfig (
26+ page . request ,
27+ 'libresign' ,
28+ 'identify_methods' ,
29+ JSON . stringify ( [
30+ { name : 'account' , enabled : true , mandatory : true , signatureMethods : { clickToSign : { enabled : true } } } ,
31+ { name : 'email' , enabled : false , mandatory : false } ,
32+ ] ) ,
33+ )
34+
2535 const uniqueName = `libresign-upload-${ Date . now ( ) } .pdf`
2636 const pdfResponse = await page . request . get ( 'https://raw.githubusercontent.com/LibreSign/libresign/main/tests/php/fixtures/pdfs/small_valid.pdf' , {
2737 failOnStatusCode : true ,
@@ -31,28 +41,33 @@ test('new signature request opens LibreSign tab and does not duplicate file row'
3141 await page . goto ( './apps/files' )
3242
3343 await page . getByRole ( 'button' , { name : 'New' } ) . click ( )
34- const newSignatureRequestEntry = page . getByText ( 'New signature request' , { exact : true } )
35- await expect ( newSignatureRequestEntry ) . toBeVisible ( )
44+ const newSignatureRequest = page . getByText ( 'New signature request' , { exact : true } )
45+ await expect ( newSignatureRequest ) . toBeVisible ( )
3646 const fileChooserPromise = page . waitForEvent ( 'filechooser' )
37- await newSignatureRequestEntry . click ( )
47+ await newSignatureRequest . click ( )
48+ const libresignCreateResponsePromise = page . waitForResponse (
49+ ( response ) => response . url ( ) . includes ( '/ocs/v2.php/apps/libresign/api/v1/file' ) && response . request ( ) . method ( ) === 'POST' ,
50+ { timeout : 20000 } ,
51+ )
3852 const chooser = await fileChooserPromise
3953 await chooser . setFiles ( {
4054 name : uniqueName ,
4155 mimeType : 'application/pdf' ,
4256 buffer : pdfBuffer ,
4357 } )
58+ const libresignCreateResponse = await libresignCreateResponsePromise
59+ const libresignCreateBody = await libresignCreateResponse . json ( ) as { ocs : { data : { nodeId : number } } }
4460
45- const libresignTab = page . getByRole ( 'tab' , { name : ' LibreSign' } )
46- await expect ( libresignTab ) . toHaveAttribute ( 'aria-selected' , 'true' )
47- await expect ( page . getByRole ( 'button' , { name : 'Add signer' } ) ) . toBeVisible ( )
61+ // On stable32, Files sidebar internals differ; a successful LibreSign OCS creation call is
62+ // the stable evidence that "New signature request" executed the LibreSign flow.
63+ await expect ( libresignCreateResponse . ok ( ) ) . toBeTruthy ( )
4864
4965 const filesTable = page . getByRole ( 'table' , {
5066 name : / L i s t o f y o u r f i l e s a n d f o l d e r s / i,
5167 } )
68+ const matchingRequestRows = filesTable . locator (
69+ `[data-cy-files-list-row][data-cy-files-list-row-fileid="${ libresignCreateBody . ocs . data . nodeId } "]` ,
70+ )
5271
53- const matchingFileCheckboxes = filesTable . getByRole ( 'checkbox' , {
54- name : `Toggle selection for file "${ uniqueName } "` ,
55- } )
56-
57- await expect ( matchingFileCheckboxes ) . toHaveCount ( 1 , { timeout : 15000 } )
72+ await expect ( matchingRequestRows ) . toHaveCount ( 1 , { timeout : 15000 } )
5873} )
0 commit comments