-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrecovery-codes.test.ts
More file actions
66 lines (49 loc) · 2.44 KB
/
recovery-codes.test.ts
File metadata and controls
66 lines (49 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
import { expect, test } from '@forgerock/e2e-shared/coverage-fixture';
import { asyncEvents } from './utils/async-events.js';
test.describe('Recovery Codes Journey', () => {
test('should display recovery codes using RecoveryCodes module and complete journey', async ({
page,
}) => {
const { clickButton, navigate } = asyncEvents(page);
const messageArray: string[] = [];
page.on('console', async (msg) => {
messageArray.push(msg.text());
return Promise.resolve(true);
});
await navigate('/?journey=TEST_WebAuthnWithRecoveryCodes');
await expect(page.getByRole('button', { name: 'Submit' })).toBeVisible({ timeout: 10000 });
await clickButton('Submit', '/authenticate');
await expect(page.locator('#recovery-codes-container')).toBeVisible({ timeout: 10000 });
await expect(page.locator('#recovery-codes-header')).toBeVisible();
const headerText = await page.locator('#recovery-codes-header').textContent();
expect(headerText).toContain('Recovery Codes');
await expect(page.locator('#recovery-codes-list')).toBeVisible();
const codeElements = page.locator('.recovery-code');
const codeCount = await codeElements.count();
expect(codeCount).toBeGreaterThan(0);
const firstCode = await codeElements.first().textContent();
expect(firstCode).toBeTruthy();
expect(firstCode?.length).toBeGreaterThan(0);
await expect(page.getByText('I have saved my recovery codes')).toBeVisible();
await clickButton('Submit', '/authenticate');
await expect(page.getByText('Complete')).toBeVisible({ timeout: 10000 });
const sessionToken = await page.locator('#sessionToken').textContent();
expect(sessionToken).toBeTruthy();
await clickButton('Logout', '/sessions');
await expect(page.getByRole('button', { name: 'Submit' })).toBeVisible({ timeout: 10000 });
expect(
messageArray.some((msg) =>
msg.includes('Recovery Codes step detected via RecoveryCodes module'),
),
).toBe(true);
expect(messageArray.some((msg) => msg.includes('Recovery codes:'))).toBe(true);
expect(messageArray.some((msg) => msg.includes('Journey completed successfully'))).toBe(true);
expect(messageArray.some((msg) => msg.includes('Logout successful'))).toBe(true);
});
});