Skip to content

Commit 8a37c99

Browse files
test(e2e): sign document with email token as unauthenticated signer
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 612b75c commit 8a37c99

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { test, expect } from '@playwright/test';
2+
import { login } from '../support/nc-login'
3+
import { configureOpenSsl, setAppConfig } from '../support/nc-provisioning'
4+
import { createMailpitClient, waitForEmailTo, extractSignLink, extractTokenFromEmail } from '../support/mailpit'
5+
6+
test('sign document with email token as unauthenticated signer', async ({ page }) => {
7+
await login(
8+
page.request,
9+
process.env.NEXTCLOUD_ADMIN_USER ?? 'admin',
10+
process.env.NEXTCLOUD_ADMIN_PASSWORD ?? 'admin',
11+
)
12+
13+
await configureOpenSsl(page.request, 'LibreSign Test', {
14+
C: 'BR',
15+
OU: ['Organization Unit'],
16+
ST: 'Rio de Janeiro',
17+
O: 'LibreSign',
18+
L: 'Rio de Janeiro',
19+
})
20+
21+
await setAppConfig(
22+
page.request,
23+
'libresign',
24+
'identify_methods',
25+
JSON.stringify([
26+
{ name: 'account', enabled: true, mandatory: false },
27+
{ name: 'email', enabled: true, mandatory: true, signatureMethods: { emailToken: { enabled: true } }, can_create_account: false },
28+
]),
29+
)
30+
31+
await page.goto('./apps/libresign')
32+
await page.getByRole('button', { name: 'Upload from URL' }).click();
33+
await page.getByRole('textbox', { name: 'URL of a PDF file' }).click();
34+
await page.getByRole('textbox', { name: 'URL of a PDF file' }).fill('http://raw.githubusercontent.com/LibreSign/libresign/main/tests/php/fixtures/pdfs/small_valid.pdf');
35+
await page.getByRole('button', { name: 'Send' }).click();
36+
await page.getByRole('button', { name: 'Add signer' }).click();
37+
await page.getByRole('tab', { name: 'Email' }).click();
38+
await page.getByPlaceholder('Email').click();
39+
await page.getByPlaceholder('Email').fill('signer01@libresign.coop');
40+
await page.getByRole('option', { name: 'signer01@libresign.coop' }).click();
41+
await page.getByRole('textbox', { name: 'Signer name' }).click();
42+
await page.getByRole('textbox', { name: 'Signer name' }).press('ControlOrMeta+a');
43+
await page.getByRole('textbox', { name: 'Signer name' }).fill('Signer 01');
44+
await page.getByRole('button', { name: 'Save' }).click();
45+
46+
const mailpit = createMailpitClient()
47+
await mailpit.deleteMessages()
48+
49+
await page.getByRole('button', { name: 'Request signatures' }).click();
50+
await page.getByRole('button', { name: 'Send' }).click();
51+
52+
// Logout before accessing the sign link to avoid session-related issues.
53+
await page.getByRole('button', { name: 'Settings menu' }).click();
54+
await page.getByRole('link', { name: 'Log out' }).click();
55+
56+
const email = await waitForEmailTo(mailpit, 'signer01@libresign.coop', 'LibreSign: There is a file for you to sign')
57+
const signLink = extractSignLink(email.Text)
58+
if (!signLink) throw new Error('Sign link not found in email')
59+
await page.goto(signLink);
60+
await page.getByRole('button', { name: 'Sign the document.' }).click();
61+
await page.getByRole('textbox', { name: 'Email' }).click();
62+
await page.getByRole('textbox', { name: 'Email' }).fill('signer01@libresign.coop');
63+
await page.getByRole('button', { name: 'Send verification code' }).click();
64+
65+
const tokenEmail = await waitForEmailTo(mailpit, 'signer01@libresign.coop', 'LibreSign: Code to sign file')
66+
const token = extractTokenFromEmail(tokenEmail.Text)
67+
if (!token) throw new Error('Token not found in email')
68+
await page.getByRole('textbox', { name: 'Enter your code' }).click();
69+
await page.getByRole('textbox', { name: 'Enter your code' }).fill(token);
70+
await page.getByRole('button', { name: 'Validate code' }).click();
71+
72+
await expect(page.getByRole('heading', { name: 'Signature confirmation' })).toBeVisible();
73+
await expect(page.getByText('Step 3 of 3 - Signature')).toBeVisible();
74+
await expect(page.getByText('Your identity has been')).toBeVisible();
75+
await expect(page.getByText('You can now sign the document.')).toBeVisible();
76+
await page.getByRole('button', { name: 'Sign document' }).click();
77+
await page.waitForURL('**/validation/**');
78+
await expect(page.getByText('This document is valid')).toBeVisible();
79+
await expect(page.getByText('Congratulations you have')).toBeVisible();
80+
});

0 commit comments

Comments
 (0)