Skip to content

Commit 6da44a0

Browse files
committed
Update settings E2E tests for settings page UI overhaul
1 parent 5691cd6 commit 6da44a0

File tree

8 files changed

+58
-66
lines changed

8 files changed

+58
-66
lines changed

test/e2e/const/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export const APPT_THEME_SETTING_DARK = 'Dark';
4343
export const APPT_TIMEZONE_SETTING_PRIMARY = Intl.DateTimeFormat().resolvedOptions().timeZone;
4444
console.log(`using local timezone: ${APPT_TIMEZONE_SETTING_PRIMARY}`)
4545
export const APPT_TIMEZONE_SETTING_HALIFAX = 'America/Halifax'; // settings test changes to this tz temporarily
46-
export const APPT_START_OF_WEEK_SUN = 'S';
47-
export const APPT_START_OF_WEEK_MON = 'M';
46+
export const APPT_START_OF_WEEK_SUN = 'SUN';
47+
export const APPT_START_OF_WEEK_MON = 'MON';
4848
export const APPT_START_OF_WEEK_DASHBOARD_SUN = 'Sun';
4949
export const APPT_START_OF_WEEK_DASHBOARD_MON = 'Mon';
5050

test/e2e/pages/settings-page.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
TIMEOUT_5_SECONDS,
99
TIMEOUT_30_SECONDS,
1010
APPT_LANGUAGE_SETTING_EN,
11+
APPT_START_OF_WEEK_MON,
1112
} from '../const/constants';
1213

1314

@@ -31,9 +32,9 @@ export class SettingsPage {
3132
readonly bookingPageURLInput: Locator;
3233
readonly copyLinkBtn: Locator;
3334
readonly copyLinkToolTipText: Locator;
34-
readonly cancelServiceBtn: Locator;
35-
readonly cancelServiceConfirmCancelBtn: Locator;
36-
readonly bookingPageSettingsBtn: Locator;
35+
readonly deleteDataBtn: Locator;
36+
readonly deleteDataConfirmCancelBtn: Locator;
37+
readonly manageBookingLink: Locator;
3738
readonly downloadDataBtn: Locator;
3839
readonly connectedAppsHdr: Locator;
3940
readonly addCaldavBtn: Locator;
@@ -42,7 +43,7 @@ export class SettingsPage {
4243
readonly addCaldavPasswordInput: Locator;
4344
readonly addCaldavCloseModalBtn: Locator;
4445
readonly addGoogleBtn: Locator;
45-
readonly defaultCalendarConnectedCbox: Locator;
46+
readonly defaultCalendarBadge: Locator;
4647
readonly saveBtnEN: Locator;
4748
readonly savedSuccessfullyTextEN: Locator;
4849
readonly savedSuccessfullyTextDE: Locator;
@@ -57,10 +58,10 @@ export class SettingsPage {
5758
// main settings view
5859
this.settingsHeaderEN = this.page.getByRole('main').getByText('Settings', { exact: true });
5960
this.settingsHeaderDE = this.page.getByRole('heading', { name: 'Einstellungen' }).first();
60-
this.saveBtnEN = this.page.getByRole('button', { name: 'Save' });
61+
this.saveBtnEN = this.page.getByRole('button', { name: 'Save' }).nth(1); // save button at bottom, not in notice bar
6162
this.savedSuccessfullyTextEN = this.page.getByText('Settings saved successfully', { exact: true });
6263
this.savedSuccessfullyTextDE = this.page.getByText('Einstellungen erfolgreich gespeichert', { exact: true });
63-
this.saveBtnDE = this.page.getByRole('button', { name: 'Speichern' });
64+
this.saveBtnDE = this.page.getByRole('button', { name: 'Speichern' }).nth(1);
6465
this.revertBtn = this.page.getByRole('button', { name: 'Revert changes' });
6566

6667
// account settings section
@@ -70,9 +71,9 @@ export class SettingsPage {
7071
this.bookingPageURLInput = this.page.locator('#booking-page-url');
7172
this.copyLinkBtn = this.page.locator('#copy-booking-page-url-button');
7273
this.copyLinkToolTipText = this.page.locator('#tooltip-body');
73-
this.cancelServiceBtn = this.page.getByRole('button', { name: 'Cancel Service' });
74-
this.cancelServiceConfirmCancelBtn = this.page.getByRole('button', { name: 'Cancel', exact: true });
75-
this.bookingPageSettingsBtn = this.page.getByRole('button', { name: 'Booking Page Settings' });
74+
this.deleteDataBtn = this.page.getByRole('button', { name: 'Delete all Appointment data' });
75+
this.deleteDataConfirmCancelBtn = this.page.getByRole('button', { name: 'Cancel', exact: true });
76+
this.manageBookingLink = this.page.getByText('Manage booking link');
7677
this.downloadDataBtn = this.page.getByTestId('settings-account-download-data-btn');
7778

7879
// preferences section
@@ -82,8 +83,8 @@ export class SettingsPage {
8283
this.preferencesHeaderEN = this.page.getByRole('heading', { name: 'Preferences' })
8384
this.preferencesHeaderDE = this.page.locator('#preferences').getByRole('heading', { name: 'Einstellungen' });
8485
this.defaultTimeZoneSelect = this.page.getByTestId('settings-preferences-default-time-zone-select');
85-
this.startOfWeekMondayBtn = this.page.getByRole('button', { name: 'M', exact: true });
86-
this.startOfWeekSundayBtn = this.page.getByRole('button', { name: 'S', exact: true });
86+
this.startOfWeekMondayBtn = this.page.getByRole('button', { name: 'Mon', exact: true });
87+
this.startOfWeekSundayBtn = this.page.getByRole('button', { name: 'Sun', exact: true });
8788

8889
// connected apps section
8990
this.connectedAppsBtn = this.page.getByTestId('settings-connectedApplications-settings-btn');
@@ -94,7 +95,7 @@ export class SettingsPage {
9495
this.addCaldavPasswordInput = this.page.getByLabel('Password');
9596
this.addCaldavCloseModalBtn = this.page.getByRole('img', { name: 'Close' });
9697
this.addGoogleBtn = this.page.getByRole('button', { name: 'Add Google Calendar' });
97-
this.defaultCalendarConnectedCbox = this.page.locator('div').filter({ hasText: /^Default*/ }).getByTestId('checkbox-input');
98+
this.defaultCalendarBadge = this.page.getByTestId('badge');
9899
this.googleSignInHdr = this.page.getByText('Sign in with Google');
99100
}
100101

@@ -208,7 +209,7 @@ export class SettingsPage {
208209
async changeStartOfWeekSetting(startOfWeek: string) {
209210
await this.scrollIntoView(this.startOfWeekMondayBtn);
210211
await this.page.waitForTimeout(TIMEOUT_1_SECOND);
211-
if (startOfWeek == 'M') {
212+
if (startOfWeek == APPT_START_OF_WEEK_MON) {
212213
await this.startOfWeekMondayBtn.click({ timeout: TIMEOUT_30_SECONDS });
213214
} else {
214215
await this.startOfWeekSundayBtn.click({ timeout: TIMEOUT_30_SECONDS });

test/e2e/pages/tb-accts-page.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export class TBAcctsPage {
88
readonly emailInput: Locator;
99
readonly passwordInput: Locator;
1010
readonly signInButton: Locator;
11-
readonly loginEmailInput: Locator;
11+
readonly localDevEmailInput: Locator;
1212
readonly localDevpasswordInput: Locator;
13-
readonly loginDialogContinueBtn: Locator;
13+
readonly localDevLoginContinueBtn: Locator;
1414

1515
constructor(page: Page) {
1616
this.page = page;
@@ -19,9 +19,10 @@ export class TBAcctsPage {
1919
this.emailInput = this.page.getByTestId('username-input');
2020
this.passwordInput = this.page.getByTestId('password-input');
2121
this.signInButton = this.page.getByTestId('submit-btn');
22-
this.loginEmailInput = this.page.getByLabel('Email');
23-
this.localDevpasswordInput = this.page.getByLabel('Password');
24-
this.loginDialogContinueBtn = this.page.getByTitle('Continue');
22+
23+
this.localDevEmailInput = this.page.getByTestId('login-email-input');
24+
this.localDevpasswordInput = this.page.getByTestId('login-password-input');
25+
this.localDevLoginContinueBtn = this.page.getByTestId('login-continue-btn');
2526
}
2627

2728
/**
@@ -48,17 +49,17 @@ export class TBAcctsPage {
4849
}
4950

5051
/**
51-
* Sign in when running Appointment on the local dev stack; doesn't redirect to TB Accounts login; just local sign-in
52+
* Sign in when running Appointment on the local dev stack and not using TB Accounts OIDC; just local password
5253
*/
5354
async localApptSignIn() {
54-
await expect(this.loginEmailInput).toBeVisible({ timeout: TIMEOUT_30_SECONDS });
55-
await expect(this.loginDialogContinueBtn).toBeVisible();
55+
await expect(this.localDevEmailInput).toBeVisible({ timeout: TIMEOUT_30_SECONDS });
56+
await expect(this.localDevLoginContinueBtn).toBeVisible();
5657
expect(TB_ACCTS_EMAIL, 'getting TB_ACCTS_EMAIL env var').toBeTruthy();
57-
await this.loginEmailInput.fill(TB_ACCTS_EMAIL);
58+
await this.localDevEmailInput.fill(TB_ACCTS_EMAIL);
5859
await this.page.waitForTimeout(TIMEOUT_1_SECOND);
5960
await this.localDevpasswordInput.fill(TB_ACCTS_PWORD);
6061
await this.page.waitForTimeout(TIMEOUT_1_SECOND);
61-
await this.loginDialogContinueBtn.click();
62+
await this.localDevLoginContinueBtn.click();
6263
await this.page.waitForTimeout(TIMEOUT_10_SECONDS);
6364
}
6465
}

test/e2e/tests/desktop/settings-account.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ test.describe('account settings on desktop browser', {
5656
await expect(settingsPage.downloadDataBtn).toBeVisible();
5757
await expect(settingsPage.downloadDataBtn).toBeEnabled();
5858

59-
// cancel service button brings up confirmation dialog (just cancel out)
60-
await settingsPage.cancelServiceBtn.scrollIntoViewIfNeeded();
61-
await settingsPage.cancelServiceBtn.click();
59+
// delete all data button brings up confirmation dialog (just cancel out)
60+
await settingsPage.deleteDataBtn.scrollIntoViewIfNeeded();
61+
await settingsPage.deleteDataBtn.click();
6262
await page.waitForTimeout(TIMEOUT_1_SECOND);
63-
await settingsPage.cancelServiceConfirmCancelBtn.scrollIntoViewIfNeeded();
64-
await settingsPage.cancelServiceConfirmCancelBtn.click({ timeout: TIMEOUT_30_SECONDS });
63+
await settingsPage.deleteDataConfirmCancelBtn.scrollIntoViewIfNeeded();
64+
await settingsPage.deleteDataConfirmCancelBtn.click({ timeout: TIMEOUT_30_SECONDS });
6565
await page.waitForTimeout(TIMEOUT_1_SECOND);
6666

67-
// clicking 'booking page settings' button brings up availability page
68-
await settingsPage.bookingPageSettingsBtn.scrollIntoViewIfNeeded();
69-
await settingsPage.bookingPageSettingsBtn.click();
67+
// clicking 'manage booking' link brings up availability page
68+
await settingsPage.manageBookingLink.scrollIntoViewIfNeeded();
69+
await settingsPage.manageBookingLink.click();
7070
await page.waitForURL('**/availability');
7171
await expect(availabilityPage.setAvailabilityText).toBeVisible();
7272
});

test/e2e/tests/desktop/settings-connected-apps.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ test.describe('connected applications settings on desktop browser', {
3030
await expect(settingsPage.connectedAppsHdr).toBeVisible({ timeout: TIMEOUT_30_SECONDS });
3131
await settingsPage.connectedAppsHdr.scrollIntoViewIfNeeded();
3232

33-
// verify default calendar checkbox is on (test expects google cal already connected)
34-
await settingsPage.defaultCalendarConnectedCbox.scrollIntoViewIfNeeded();
35-
expect(await settingsPage.defaultCalendarConnectedCbox.isChecked()).toBeTruthy();
33+
// one of the calendars is marked with the default badge; if there is more than one badge found this will fail
34+
await expect(settingsPage.defaultCalendarBadge).toBeVisible();
35+
await settingsPage.defaultCalendarBadge.scrollIntoViewIfNeeded();
3636

3737
// verify that clicking the 'add caldav' button brings up the caldav connection dialog; just close it
3838
await settingsPage.addCaldavBtn.scrollIntoViewIfNeeded();
@@ -46,9 +46,7 @@ test.describe('connected applications settings on desktop browser', {
4646

4747
// verify clicking the 'add google calendar' button brings up the google sign-in url
4848
await settingsPage.addGoogleBtn.click();
49-
await page.waitForTimeout(TIMEOUT_3_SECONDS);
50-
// will go to moz sso auth or google auth depending on local/env setup
51-
expect(page.url().includes('auth.mozilla') || page.url().includes('accounts.google')).toBeTruthy();
49+
await expect(settingsPage.googleSignInHdr).toBeVisible({ timeout: TIMEOUT_30_SECONDS });
5250
await settingsPage.gotoConnectedAppSettings();
5351
});
5452
});

test/e2e/tests/mobile/settings-account.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ test.describe('account settings on mobile browser', {
6868
await settingsPage.scrollIntoView(settingsPage.downloadDataBtn);
6969
await expect(settingsPage.downloadDataBtn).toBeVisible();
7070

71-
// cancel service button brings up confirmation dialog (just cancel out)
72-
await settingsPage.scrollIntoView(settingsPage.cancelServiceBtn);
73-
await settingsPage.cancelServiceBtn.click();
71+
// delete all data button brings up confirmation dialog (just cancel out)
72+
await settingsPage.scrollIntoView(settingsPage.deleteDataBtn);
73+
await settingsPage.deleteDataBtn.click();
7474
await page.waitForTimeout(TIMEOUT_1_SECOND);
75-
await settingsPage.scrollIntoView(settingsPage.cancelServiceConfirmCancelBtn);
76-
await settingsPage.cancelServiceConfirmCancelBtn.click({ timeout: TIMEOUT_30_SECONDS });
75+
await settingsPage.scrollIntoView(settingsPage.deleteDataConfirmCancelBtn);
76+
await settingsPage.deleteDataConfirmCancelBtn.click({ timeout: TIMEOUT_30_SECONDS });
7777
await page.waitForTimeout(TIMEOUT_1_SECOND);
7878

79-
// clicking 'booking page settings' button brings up availability section
80-
await settingsPage.scrollIntoView(settingsPage.bookingPageSettingsBtn);
81-
await settingsPage.bookingPageSettingsBtn.click();
79+
// clicking 'manage booking' link brings up availability page
80+
await settingsPage.scrollIntoView(settingsPage.manageBookingLink);
81+
await settingsPage.manageBookingLink.click();
8282
await expect(availabilityPage.setAvailabilityText).toBeVisible();
8383
});
8484

test/e2e/tests/mobile/settings-connected-apps.spec.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ test.describe('settings - connected applications on mobile browser', {
4040
await expect(settingsPage.connectedAppsHdr).toBeVisible({ timeout: TIMEOUT_30_SECONDS });
4141
await settingsPage.scrollIntoView(settingsPage.connectedAppsHdr);
4242

43-
// verify default calendar checkbox is on (test expects google cal already connected)
44-
await settingsPage.scrollIntoView(settingsPage.defaultCalendarConnectedCbox);
45-
expect(await settingsPage.defaultCalendarConnectedCbox.isChecked()).toBeTruthy();
43+
// one of the calendars is marked with the default badge; if there is more than one badge found this will fail
44+
await expect(settingsPage.defaultCalendarBadge).toBeVisible();
45+
await settingsPage.scrollIntoView(settingsPage.defaultCalendarBadge);
4646

4747
// verify that clicking the 'add caldav' button brings up the caldav connection dialog; just close it
4848
await settingsPage.scrollIntoView(settingsPage.addCaldavBtn);
@@ -60,15 +60,7 @@ test.describe('settings - connected applications on mobile browser', {
6060

6161
// verify clicking the 'add google calendar' button brings up the google sign-in url
6262
await settingsPage.addGoogleBtn.click();
63-
await page.waitForTimeout(TIMEOUT_3_SECONDS);
64-
65-
// on ios the URL stays as the settings URL but displays connect to google page
66-
if (settingsPage.testPlatform.includes('ios')) {
67-
expect(settingsPage.googleSignInHdr).toBeVisible({ timeout: TIMEOUT_30_SECONDS });
68-
} else {
69-
expect(page.url().includes('auth.mozilla') || page.url().includes('accounts.google')).toBeTruthy();
70-
}
71-
await settingsPage.gotoConnectedAppSettings();
63+
await expect(settingsPage.googleSignInHdr).toBeVisible({ timeout: TIMEOUT_30_SECONDS });
7264
});
7365

7466
test.afterAll(async ({ browser }, testInfo) => {

test/e2e/utils/utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ export const navigateToAppointmentAndSignIn = async (page: Page, testProjectName
3636
await page.goto(`${APPT_URL}`);
3737
await page.waitForTimeout(TIMEOUT_5_SECONDS);
3838

39-
// if we are already signed in then we can skip this
39+
// local dev can use 'password' only or oidc; check if using password only
40+
if (APPT_TARGET_ENV == 'dev' && await tbAcctsSignInPage.localDevEmailInput.isVisible()) {
41+
await tbAcctsSignInPage.localApptSignIn();
42+
}
43+
44+
// using oidc/keyloak; if we are already signed in then we can skip this
4045
if (await tbAcctsSignInPage.signInHeaderText.isVisible() && await tbAcctsSignInPage.signInButton.isEnabled()) {
41-
if (APPT_TARGET_ENV == 'prod' || APPT_TARGET_ENV == 'stage') {
42-
await tbAcctsSignInPage.signIn(testProjectName);
43-
} else {
44-
// local dev env doesn't use tb accts; just signs into appt using username and pword
45-
await tbAcctsSignInPage.localApptSignIn();
46-
}
46+
await tbAcctsSignInPage.signIn(testProjectName);
4747
}
4848

4949
// now that we're signed into the appointment dashboard give it time to load

0 commit comments

Comments
 (0)