Skip to content

Commit 1f8152b

Browse files
committed
chore: add-logout-to-test
1 parent a1e5cb9 commit 1f8152b

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

.husky/install.mjs

-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,5 @@
22
if (process.env.NODE_ENV === 'production' || process.env.CI === 'true') {
33
process.exit(0);
44
}
5-
<<<<<<< HEAD
6-
const husky = (await import('husky')).default;
7-
husky();
8-
=======
95
const husky = (await import('husky')).default
106
console.log(husky())
11-
>>>>>>> aeefdd88 (chore: fix-logic-add-tests)

e2e/davinci-app/main.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const config = {
3232
clientId,
3333
redirectUri: `${window.location.origin}/`,
3434
scope: 'openid profile email name revoke',
35+
timeout: 3000,
3536
serverConfig: {
3637
wellknown:
3738
'https://auth.pingone.ca/02fb4743-189a-4bc7-9d6c-a919edfe6447/as/.well-known/openid-configuration',
@@ -96,9 +97,9 @@ const config = {
9697

9798
const loginBtn = document.getElementById('logoutButton') as HTMLButtonElement;
9899
loginBtn.addEventListener('click', async () => {
99-
await FRUser.logout({ logoutRedirectUri: window.location.origin });
100+
await FRUser.logout({ logoutRedirectUri: `${window.location.origin}/` });
100101

101-
window.location.reload();
102+
//window.location.reload();
102103
});
103104
}
104105

e2e/davinci-suites/src/basic.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ test('Test happy paths on test page', async ({ page }) => {
2525

2626
const accessToken = await page.locator('#accessTokenValue').innerText();
2727
await expect(accessToken).toBeTruthy();
28+
29+
const logoutButton = page.getByRole('button', { name: 'Logout' });
30+
await expect(logoutButton).toBeVisible();
31+
const revokeCall = page.waitForResponse((response) => {
32+
if (response.url().includes('/revoke') && response.status() === 200) {
33+
return true;
34+
}
35+
});
36+
const signoff = page.waitForResponse((response) => {
37+
if (response.url().includes('/signoff') && response.status() === 302) {
38+
return true;
39+
}
40+
});
41+
await logoutButton.click();
42+
await revokeCall;
43+
await signoff;
44+
await expect(page.getByText('Username/Password Form')).toBeVisible();
2845
});
2946
test('ensure query params passed to start are sent off in authorize call', async ({ page }) => {
3047
const { navigate } = asyncEvents(page);

e2e/davinci-suites/src/form-fields.test.ts

+23
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,19 @@ test('Should render form fields', async ({ page }) => {
1717
const flowButton = page.getByRole('button', { name: 'Flow Button' });
1818
await flowButton.click();
1919

20+
const requestPromise = page.waitForRequest((request) => request.url().includes('/customForm'));
2021
await page.getByRole('button', { name: 'Submit' }).click();
22+
const request = await requestPromise;
23+
const parsedData = JSON.parse(request.postData());
24+
const data = parsedData.parameters.data;
25+
expect(data.actionKey).toBe('submit');
26+
expect(data.formData).toEqual({
27+
// leaving this here because it should be fixed and we would have a failing test when we do fix import { } from "// to remind us to update the test"
28+
['undefined']: '',
29+
['text-input-key']: 'This is some text',
30+
['dropdown-field-key']: '',
31+
['radio-group-key']: '',
32+
});
2133
});
2234

2335
test('should render form validation fields', async ({ page }) => {
@@ -40,5 +52,16 @@ test('should render form validation fields', async ({ page }) => {
4052
await expect(page.getByRole('textbox', { name: 'Email Address' })).toHaveValue(
4153
4254
);
55+
const requestPromise = page.waitForRequest((request) => request.url().includes('/customForm'));
4356
await page.getByRole('button', { name: 'Submit' }).click();
57+
const request = await requestPromise;
58+
const parsedData = JSON.parse(request.postData());
59+
const data = parsedData.parameters.data;
60+
expect(data.actionKey).toBe('submit');
61+
expect(data.formData).toEqual({
62+
['undefined']: '',
63+
'user.username': '',
64+
'user.password': '',
65+
'user.email': '',
66+
});
4467
});

packages/davinci-client/src/lib/collector.utils.ts

-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ export function returnSingleValueCollector<
133133
CollectorType extends SingleValueCollectorTypes = 'SingleValueCollector',
134134
>(field: Field, idx: number, collectorType: CollectorType, data?: string) {
135135
let error = '';
136-
console.log('the field ', field);
137136
if (!('key' in field)) {
138137
error = `${error}Key is not found in the field object. `;
139138
}

0 commit comments

Comments
 (0)