Skip to content

Commit 9d900df

Browse files
test(e2e): fold nullable-email guard into existing sign flow
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 9b6abc1 commit 9d900df

2 files changed

Lines changed: 25 additions & 122 deletions

File tree

playwright/e2e/sign-email-token-unauthenticated.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,30 @@ test('sign document with email token as unauthenticated signer', async ({ page }
6464
const email = await waitForEmailTo(mailpit, 'signer01@libresign.coop', 'LibreSign: There is a file for you to sign')
6565
const signLink = extractSignLink(email.Text)
6666
if (!signLink) throw new Error('Sign link not found in email')
67+
68+
// Regression guard: validation payload can contain signer without email.
69+
// Reuse this existing E2E flow and force `email = null` in the validate response.
70+
await page.route('**/ocs/v2.php/apps/libresign/api/v1/file/validate/uuid/**', async (route) => {
71+
const response = await route.fetch()
72+
const payload = await response.json() as Record<string, unknown>
73+
const ocs = payload.ocs as Record<string, unknown> | undefined
74+
const data = ocs?.data as Record<string, unknown> | undefined
75+
76+
if (data && Array.isArray(data.signers) && data.signers.length > 0) {
77+
const firstSigner = data.signers[0] as Record<string, unknown>
78+
firstSigner.email = null
79+
}
80+
81+
await route.fulfill({
82+
status: response.status(),
83+
headers: {
84+
...response.headers(),
85+
'content-type': 'application/json',
86+
},
87+
body: JSON.stringify(payload),
88+
})
89+
})
90+
6791
await page.goto(signLink);
6892
await page.getByRole('button', { name: 'Sign the document.' }).click();
6993
await page.getByRole('textbox', { name: 'Email' }).click();
@@ -84,6 +108,7 @@ test('sign document with email token as unauthenticated signer', async ({ page }
84108
await page.getByRole('button', { name: 'Sign document' }).click();
85109
await page.waitForURL('**/validation/**');
86110
await expect(page.getByText('This document is valid')).toBeVisible();
111+
await expect(page.getByText('Failed to validate document')).not.toBeVisible();
87112
await expect(page.getByText('Congratulations you have')).toBeVisible();
88113
await expect(page.getByRole('button', { name: 'Sign the document.' })).not.toBeVisible();
89114
});

playwright/e2e/validation-nullable-signer-email.spec.ts

Lines changed: 0 additions & 122 deletions
This file was deleted.

0 commit comments

Comments
 (0)