Skip to content

Commit 7c821b6

Browse files
test(e2e): cover blocking and non-blocking signing outcomes
Refactor the non-retriable signing error spec to avoid ambiguous strict text matching and assert the current blocked-UI behavior explicitly (hidden sign CTA + retry button). Add a second scenario that returns success from the sign endpoint and verifies that the blocking warning is not shown when no non-retriable error is returned. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 4eeb266 commit 7c821b6

1 file changed

Lines changed: 122 additions & 0 deletions

File tree

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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, deleteUserPfx, setAppConfig } from '../support/nc-provisioning'
9+
10+
async function prepareSignFlow(page: Parameters<typeof test>[1] extends (args: infer T) => any ? T['page'] : never, adminUser: string) {
11+
await page.goto('./apps/libresign')
12+
13+
await page.getByRole('button', { name: 'Upload from URL' }).click()
14+
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')
15+
await page.getByRole('button', { name: 'Send' }).click()
16+
await page.getByRole('button', { name: 'Add signer' }).click()
17+
await page.getByPlaceholder('Account').fill(adminUser)
18+
await page.getByText('admin@email.tld').click()
19+
await page.getByRole('button', { name: 'Save' }).click()
20+
await page.getByRole('button', { name: 'Request signatures' }).click()
21+
await page.getByRole('button', { name: 'Send' }).click()
22+
await page.getByRole('button', { name: 'Sign document' }).click()
23+
await page.getByRole('button', { name: 'Define a password and sign the document.' }).click()
24+
await page.getByLabel('Enter a password').fill('Password1234')
25+
await page.getByRole('button', { name: 'Confirm' }).click()
26+
await page.getByRole('button', { name: 'Sign the document.' }).click()
27+
await page.getByLabel('Signature password').fill('Password1234')
28+
}
29+
30+
async function bootstrapAdminCertificate(page: Parameters<typeof test>[1] extends (args: infer T) => any ? T['page'] : never) {
31+
const adminUser = process.env.NEXTCLOUD_ADMIN_USER ?? 'admin'
32+
const adminPassword = process.env.NEXTCLOUD_ADMIN_PASSWORD ?? 'admin'
33+
34+
await login(page.request, adminUser, adminPassword)
35+
36+
await configureOpenSsl(page.request, 'LibreSign Test', {
37+
C: 'BR',
38+
OU: ['Organization Unit'],
39+
ST: 'Rio de Janeiro',
40+
O: 'LibreSign',
41+
L: 'Rio de Janeiro',
42+
})
43+
44+
await setAppConfig(
45+
page.request,
46+
'libresign',
47+
'identify_methods',
48+
JSON.stringify([
49+
{ name: 'account', enabled: true, mandatory: true, signatureMethods: { password: { enabled: true } } },
50+
{ name: 'email', enabled: false, mandatory: false },
51+
]),
52+
)
53+
54+
await deleteUserPfx(page.request, adminUser, adminPassword)
55+
56+
return { adminUser }
57+
}
58+
59+
test('closes password modal on non-retriable signing error', async ({ page }) => {
60+
const { adminUser } = await bootstrapAdminCertificate(page)
61+
await prepareSignFlow(page, adminUser)
62+
63+
await page.route('**/ocs/v2.php/apps/libresign/api/v1/sign/**', async (route) => {
64+
await route.fulfill({
65+
status: 422,
66+
contentType: 'application/json',
67+
body: JSON.stringify({
68+
ocs: {
69+
meta: {
70+
status: 'failure',
71+
statuscode: 422,
72+
message: 'Certificate revocation status could not be verified',
73+
},
74+
data: {
75+
action: 0,
76+
errors: [{
77+
code: 422,
78+
message: 'Certificate revocation status could not be verified',
79+
}],
80+
},
81+
},
82+
}),
83+
})
84+
})
85+
86+
await page.getByRole('button', { name: 'Sign document' }).click()
87+
88+
await expect(page.getByLabel('Signature password')).toBeHidden()
89+
await expect(page.getByRole('button', { name: 'Sign the document.' })).toBeHidden()
90+
await expect(page.getByRole('button', { name: 'Try signing again' })).toBeVisible()
91+
await expect(page.locator('.button-wrapper').getByText('Certificate revocation status could not be verified').first()).toBeVisible()
92+
})
93+
94+
test('keeps normal sign UI when no non-retriable error is returned', async ({ page }) => {
95+
const { adminUser } = await bootstrapAdminCertificate(page)
96+
await prepareSignFlow(page, adminUser)
97+
98+
await page.route('**/ocs/v2.php/apps/libresign/api/v1/sign/**', async (route) => {
99+
await route.fulfill({
100+
status: 200,
101+
contentType: 'application/json',
102+
body: JSON.stringify({
103+
ocs: {
104+
meta: {
105+
status: 'ok',
106+
statuscode: 200,
107+
message: null,
108+
},
109+
data: {
110+
action: 0,
111+
status: 'signed',
112+
},
113+
},
114+
}),
115+
})
116+
})
117+
118+
await page.getByRole('button', { name: 'Sign document' }).click()
119+
120+
await expect(page.getByText('Signing is blocked until the certificate validation issue is resolved.')).toBeHidden()
121+
await expect(page.getByRole('button', { name: 'Try signing again' })).toBeHidden()
122+
})

0 commit comments

Comments
 (0)