-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlogging.test.ts
More file actions
70 lines (52 loc) · 2.16 KB
/
logging.test.ts
File metadata and controls
70 lines (52 loc) · 2.16 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
67
68
69
70
/*
* 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';
import { password, username } from './utils/demo-user.js';
test('Test debug log level and custom logger functions', async ({ page }) => {
const { navigate } = asyncEvents(page);
const messageArray: string[] = [];
// Listen for events on page
page.on('console', async (msg) => {
messageArray.push(msg.text());
return Promise.resolve(true);
});
await navigate('/?logFn=true');
expect(page.url()).toBe('http://localhost:5829/?logFn=true');
await expect(page.getByText('Username/Password Form')).toBeVisible();
await page.getByLabel('Username').fill(username);
await page.getByLabel('Password').fill(password);
await page.getByRole('button', { name: 'Sign On' }).click();
await expect(page.getByText('Complete')).toBeVisible();
// Just test if the custom debug function is called
expect(
messageArray.includes('[DEBUG] This is a custom logger function output.'),
'Custom debug function output string should be present',
).toBe(true);
});
test('Test log level without custom logger', async ({ page }) => {
const { navigate } = asyncEvents(page);
const messageArray: string[] = [];
// Listen for events on page
page.on('console', async (msg) => {
messageArray.push(msg.text());
return Promise.resolve(true);
});
await navigate('/');
expect(page.url()).toBe('http://localhost:5829/');
await expect(page.getByText('Username/Password Form')).toBeVisible();
await page.getByLabel('Username').fill(username);
await page.getByLabel('Password').fill(password);
await page.getByRole('button', { name: 'Sign On' }).click();
await expect(page.getByText('Complete')).toBeVisible();
messageArray.forEach((msg) => {
// Ensure a debug message is present, but don't check the whole contents
if (msg.includes('DaVinci API Request')) {
expect(msg).toContain('DaVinci API Response');
}
});
});