|
| 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('delete pending signature request', 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 | + await page.goto('./apps/libresign') |
| 36 | + await page.getByRole('button', { name: 'Upload from URL' }).click() |
| 37 | + await page.getByRole('textbox', { name: 'URL of a PDF file' }).fill('https://raw.githubusercontent.com/LibreSign/libresign/main/tests/php/fixtures/pdfs/small_valid.pdf') |
| 38 | + await page.getByRole('button', { name: 'Send' }).click() |
| 39 | + await page.getByRole('button', { name: 'Add signer' }).click() |
| 40 | + await page.getByPlaceholder('Account').fill('a') |
| 41 | + await page.getByRole('option', { name: 'admin@email.tld' }).click() |
| 42 | + await page.getByRole('button', { name: 'Save' }).click() |
| 43 | + await page.getByRole('button', { name: 'Request signatures' }).click() |
| 44 | + await page.getByRole('button', { name: 'Send' }).click() |
| 45 | + |
| 46 | + // Navigate to the Files list and ensure it is sorted by Created at, newest first |
| 47 | + await page.locator('#fileslist').getByRole('link', { name: 'Files' }).click() |
| 48 | + const createdAtTh = page.getByRole('columnheader', { name: 'Created at' }) |
| 49 | + const sortDirection = await createdAtTh.evaluate((el: HTMLElement) => el.ariaSort) |
| 50 | + if (sortDirection !== 'descending') { |
| 51 | + await page.getByRole('button', { name: 'Created at' }).click() |
| 52 | + if (sortDirection === 'none') { |
| 53 | + // Column was sortable but not active: first click set it to ascending, one more for descending |
| 54 | + await page.getByRole('button', { name: 'Created at' }).click() |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + // The most recently uploaded document is first — rename it to a unique name |
| 59 | + // so it can be unambiguously identified regardless of other documents in the list. |
| 60 | + // NcActionButton inside NcActions renders as role="menuitem", not role="button". |
| 61 | + const uniqueName = `delete-pending-test-${Date.now()}` |
| 62 | + const firstRow = page.locator('[data-cy-files-list-tbody] tr.files-list__row') |
| 63 | + .filter({ hasText: 'small_valid' }) |
| 64 | + .first() |
| 65 | + await firstRow.getByRole('button', { name: 'Actions' }).click() |
| 66 | + await page.getByRole('menuitem', { name: 'Rename' }).click() |
| 67 | + await page.getByLabel('File name').fill(uniqueName) |
| 68 | + await page.getByLabel('File name').press('Enter') |
| 69 | + |
| 70 | + // Find the row by its unique name and assert the status |
| 71 | + const targetRow = page.locator('[data-cy-files-list-tbody] tr.files-list__row') |
| 72 | + .filter({ hasText: uniqueName }) |
| 73 | + await expect(targetRow.locator('.status-chip__text')).toHaveText('Ready to sign') |
| 74 | + |
| 75 | + // Delete it |
| 76 | + await targetRow.getByRole('button', { name: 'Actions' }).click() |
| 77 | + await page.getByRole('menuitem', { name: 'Delete' }).click() |
| 78 | + |
| 79 | + // Confirm the deletion in the dialog |
| 80 | + await expect(page.getByRole('dialog', { name: 'Confirm' })).toBeVisible() |
| 81 | + await expect(page.getByText('The signature request will be deleted. Do you confirm this action?')).toBeVisible() |
| 82 | + await page.getByRole('button', { name: 'Ok' }).click() |
| 83 | + |
| 84 | + // The specific row we deleted must disappear from the list |
| 85 | + await expect(targetRow).toBeHidden() |
| 86 | +}) |
| 87 | + |
0 commit comments