|
| 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 } 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 | + const uniqueName = `libresign-upload-${Date.now()}.pdf` |
| 26 | + const pdfResponse = await page.request.get('https://raw.githubusercontent.com/LibreSign/libresign/main/tests/php/fixtures/pdfs/small_valid.pdf', { |
| 27 | + failOnStatusCode: true, |
| 28 | + }) |
| 29 | + const pdfBuffer = Buffer.from(await pdfResponse.body()) |
| 30 | + |
| 31 | + await page.goto('./apps/files') |
| 32 | + |
| 33 | + await page.getByRole('button', { name: 'New' }).click() |
| 34 | + const newSignatureRequestEntry = page.getByText('New signature request', { exact: true }) |
| 35 | + await expect(newSignatureRequestEntry).toBeVisible() |
| 36 | + const fileChooserPromise = page.waitForEvent('filechooser') |
| 37 | + await newSignatureRequestEntry.click() |
| 38 | + const chooser = await fileChooserPromise |
| 39 | + await chooser.setFiles({ |
| 40 | + name: uniqueName, |
| 41 | + mimeType: 'application/pdf', |
| 42 | + buffer: pdfBuffer, |
| 43 | + }) |
| 44 | + |
| 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() |
| 48 | + |
| 49 | + const filesTable = page.getByRole('table', { |
| 50 | + name: /List of your files and folders/i, |
| 51 | + }) |
| 52 | + |
| 53 | + const matchingFileCheckboxes = filesTable.getByRole('checkbox', { |
| 54 | + name: `Toggle selection for file "${uniqueName}"`, |
| 55 | + }) |
| 56 | + |
| 57 | + await expect(matchingFileCheckboxes).toHaveCount(1, { timeout: 15000 }) |
| 58 | +}) |
0 commit comments