|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +import { expect, test } from '@playwright/test' |
| 7 | +import { login } from '../support/nc-login' |
| 8 | +import { configureOpenSsl, setAppConfig } from '../support/nc-provisioning' |
| 9 | + |
| 10 | +test('new signature request opens LibreSign tab and does not duplicate file row', async ({ page }) => { |
| 11 | + await login( |
| 12 | + page.request, |
| 13 | + process.env.NEXTCLOUD_ADMIN_USER ?? 'admin', |
| 14 | + process.env.NEXTCLOUD_ADMIN_PASSWORD ?? 'admin', |
| 15 | + ) |
| 16 | + |
| 17 | + await configureOpenSsl(page.request, 'LibreSign Test', { |
| 18 | + C: 'BR', |
| 19 | + OU: ['Organization Unit'], |
| 20 | + ST: 'Rio de Janeiro', |
| 21 | + O: 'LibreSign', |
| 22 | + L: 'Rio de Janeiro', |
| 23 | + }) |
| 24 | + |
| 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 | + |
| 35 | + const uniqueName = `libresign-upload-${Date.now()}.pdf` |
| 36 | + const pdfResponse = await page.request.get('https://raw.githubusercontent.com/LibreSign/libresign/main/tests/php/fixtures/pdfs/small_valid.pdf', { |
| 37 | + failOnStatusCode: true, |
| 38 | + }) |
| 39 | + const pdfBuffer = Buffer.from(await pdfResponse.body()) |
| 40 | + |
| 41 | + await page.goto('./apps/files') |
| 42 | + |
| 43 | + await page.getByRole('button', { name: 'New' }).click() |
| 44 | + const newSignatureRequest = page.getByText('New signature request', { exact: true }) |
| 45 | + await expect(newSignatureRequest).toBeVisible() |
| 46 | + const fileChooserPromise = page.waitForEvent('filechooser') |
| 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 | + ) |
| 52 | + const chooser = await fileChooserPromise |
| 53 | + await chooser.setFiles({ |
| 54 | + name: uniqueName, |
| 55 | + mimeType: 'application/pdf', |
| 56 | + buffer: pdfBuffer, |
| 57 | + }) |
| 58 | + const libresignCreateResponse = await libresignCreateResponsePromise |
| 59 | + const libresignCreateBody = await libresignCreateResponse.json() as { ocs: { data: { nodeId: number } } } |
| 60 | + |
| 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() |
| 64 | + |
| 65 | + const filesTable = page.getByRole('table', { |
| 66 | + name: /List of your files and folders/i, |
| 67 | + }) |
| 68 | + const matchingRequestRows = filesTable.locator( |
| 69 | + `[data-cy-files-list-row][data-cy-files-list-row-fileid="${libresignCreateBody.ocs.data.nodeId}"]`, |
| 70 | + ) |
| 71 | + |
| 72 | + await expect(matchingRequestRows).toHaveCount(1, { timeout: 15000 }) |
| 73 | +}) |
0 commit comments