|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +import { expect, test, type Page } from '@playwright/test' |
| 7 | +import { login } from '../support/nc-login' |
| 8 | +import { configureOpenSsl, setAppConfig } from '../support/nc-provisioning' |
| 9 | + |
| 10 | +async function sortByCreatedAtDescending(page: Page) { |
| 11 | + const createdAtTh = page.getByRole('columnheader', { name: 'Created at' }) |
| 12 | + const sortDirection = await createdAtTh.evaluate((element: HTMLElement) => element.ariaSort) |
| 13 | + if (sortDirection !== 'descending') { |
| 14 | + await page.getByRole('button', { name: 'Created at' }).click() |
| 15 | + if (sortDirection === 'none') { |
| 16 | + await page.getByRole('button', { name: 'Created at' }).click() |
| 17 | + } |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +test('updates files list status after signing with native engine', async ({ page }) => { |
| 22 | + await login( |
| 23 | + page.request, |
| 24 | + process.env.NEXTCLOUD_ADMIN_USER ?? 'admin', |
| 25 | + process.env.NEXTCLOUD_ADMIN_PASSWORD ?? 'admin', |
| 26 | + ) |
| 27 | + |
| 28 | + await configureOpenSsl(page.request, 'LibreSign Test', { |
| 29 | + C: 'BR', |
| 30 | + OU: ['Organization Unit'], |
| 31 | + ST: 'Rio de Janeiro', |
| 32 | + O: 'LibreSign', |
| 33 | + L: 'Rio de Janeiro', |
| 34 | + }) |
| 35 | + |
| 36 | + await setAppConfig(page.request, 'libresign', 'signature_engine', 'PhpNative') |
| 37 | + await setAppConfig( |
| 38 | + page.request, |
| 39 | + 'libresign', |
| 40 | + 'identify_methods', |
| 41 | + JSON.stringify([ |
| 42 | + { name: 'account', enabled: true, mandatory: true, signatureMethods: { clickToSign: { enabled: true } } }, |
| 43 | + { name: 'email', enabled: false, mandatory: false }, |
| 44 | + ]), |
| 45 | + ) |
| 46 | + |
| 47 | + await page.goto('./apps/libresign') |
| 48 | + await page.getByRole('button', { name: 'Upload from URL' }).click() |
| 49 | + 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') |
| 50 | + await page.getByRole('button', { name: 'Send' }).click() |
| 51 | + await page.getByRole('button', { name: 'Add signer' }).click() |
| 52 | + await page.getByPlaceholder('Account').fill('admin') |
| 53 | + await page.getByText('admin@email.tld').click() |
| 54 | + await page.getByRole('button', { name: 'Save' }).click() |
| 55 | + await page.getByRole('button', { name: 'Request signatures' }).click() |
| 56 | + await page.getByRole('button', { name: 'Send' }).click() |
| 57 | + |
| 58 | + await page.locator('#fileslist').getByRole('link', { name: 'Files' }).click() |
| 59 | + await sortByCreatedAtDescending(page) |
| 60 | + |
| 61 | + const uniqueName = `native-status-sync-${Date.now()}.pdf` |
| 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 | + const targetRow = page.locator('[data-cy-files-list-tbody] tr.files-list__row') |
| 71 | + .filter({ hasText: uniqueName }) |
| 72 | + await expect(targetRow.locator('.status-chip__text')).toHaveText('Ready to sign') |
| 73 | + |
| 74 | + await targetRow.getByRole('button', { name: 'Actions' }).click() |
| 75 | + await page.getByRole('menuitem', { name: 'Sign' }).click() |
| 76 | + await page.getByRole('button', { name: 'Sign the document.' }).click() |
| 77 | + await page.getByRole('button', { name: 'Sign document' }).click() |
| 78 | + await page.waitForURL('**/validation/**') |
| 79 | + await expect(page.getByText('This document is valid')).toBeVisible() |
| 80 | + |
| 81 | + await page.locator('#fileslist').getByRole('link', { name: 'Files' }).click() |
| 82 | + await expect(targetRow.locator('.status-chip__text')).toHaveText('Signed') |
| 83 | +}) |
0 commit comments