Skip to content

Commit 3fdc802

Browse files
authored
Update E2E tests for latest auth changes (#1361)
* Update E2E tests for latest auth changes * Update email field locator
1 parent b1b17fc commit 3fdc802

File tree

6 files changed

+42
-112
lines changed

6 files changed

+42
-112
lines changed

test/e2e/pages/availability-page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { expect, type Page, type Locator } from '@playwright/test';
22

33
import {
44
APPT_AVAILABILITY_PAGE,
5-
APPT_BOOKINGS_PAGE,
65
TIMEOUT_1_SECOND,
76
TIMEOUT_3_SECONDS,
87
APPT_TIMEZONE_SETTING_PRIMARY,
@@ -59,7 +58,8 @@ export class AvailabilityPage {
5958
this.calendarSelect = this.page.locator('select[name="calendar"]');
6059
this.autoConfirmBookingsCheckBox = this.page.getByTestId('availability-automatically-confirm-checkbox');
6160
this.customizePerDayCheckBox = this.page.getByRole('checkbox', { name: 'Set custom times for each day'});
62-
this.customizePerDayCheckBoxContainer = this.page.locator('#app div').filter({ hasText: 'Set custom times for each day' }).nth(4);
61+
this.customizePerDayCheckBoxContainer = this.page.locator('label').filter({ hasText: 'Set custom times for each day' }).locator('span').first();
62+
6363
this.allStartTimeInput = this.page.locator('#start_time');
6464
this.allEndTimeInput = this.page.locator('#end_time');
6565
this.customStartTime1Input = this.page.getByTestId('availability-start-time-1-0-input');

test/e2e/pages/landing-page.ts

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

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, type Page, type Locator } from '@playwright/test';
2-
import { TB_ACCTS_EMAIL, TB_ACCTS_PWORD, TIMEOUT_10_SECONDS, TIMEOUT_1_SECOND } from '../const/constants';
2+
import { TB_ACCTS_EMAIL, TB_ACCTS_PWORD, TIMEOUT_1_SECOND, TIMEOUT_10_SECONDS, TIMEOUT_30_SECONDS } from '../const/constants';
33

44
export class TBAcctsPage {
55
readonly page: Page;
@@ -8,6 +8,9 @@ export class TBAcctsPage {
88
readonly emailInput: Locator;
99
readonly passwordInput: Locator;
1010
readonly signInButton: Locator;
11+
readonly loginEmailInput: Locator;
12+
readonly localDevpasswordInput: Locator;
13+
readonly loginDialogContinueBtn: Locator;
1114

1215
constructor(page: Page) {
1316
this.page = page;
@@ -16,6 +19,9 @@ export class TBAcctsPage {
1619
this.emailInput = this.page.getByTestId('username-input');
1720
this.passwordInput = this.page.getByTestId('password-input');
1821
this.signInButton = this.page.getByRole('button', { name: 'Sign in' });
22+
this.loginEmailInput = this.page.getByLabel('Email');
23+
this.localDevpasswordInput = this.page.getByLabel('Password');
24+
this.loginDialogContinueBtn = this.page.getByTitle('Continue');
1925
}
2026

2127
/**
@@ -25,6 +31,7 @@ export class TBAcctsPage {
2531
console.log('signing in to TB Accounts');
2632
expect(TB_ACCTS_EMAIL, 'getting TB_ACCTS_EMAIL env var').toBeTruthy();
2733
expect(TB_ACCTS_PWORD, 'getting TB_ACCTS_PWORD env var').toBeTruthy();
34+
await expect(this.emailInput).toBeVisible({ timeout: TIMEOUT_30_SECONDS });
2835
await this.emailInput.fill(String(TB_ACCTS_EMAIL));
2936
await this.page.waitForTimeout(TIMEOUT_1_SECOND);
3037
await this.passwordInput.fill(String(TB_ACCTS_PWORD));
@@ -33,4 +40,19 @@ export class TBAcctsPage {
3340
await this.signInButton.click({ force: true });
3441
await this.page.waitForTimeout(TIMEOUT_10_SECONDS);
3542
}
43+
44+
/**
45+
* Sign in when running Appointment on the local dev stack; doesn't redirect to TB Accounts login; just local sign-in
46+
*/
47+
async localApptSignIn() {
48+
await expect(this.loginEmailInput).toBeVisible({ timeout: TIMEOUT_30_SECONDS });
49+
await expect(this.loginDialogContinueBtn).toBeVisible();
50+
expect(TB_ACCTS_EMAIL, 'getting TB_ACCTS_EMAIL env var').toBeTruthy();
51+
await this.loginEmailInput.fill(TB_ACCTS_EMAIL);
52+
await this.page.waitForTimeout(TIMEOUT_1_SECOND);
53+
await this.localDevpasswordInput.fill(TB_ACCTS_PWORD);
54+
await this.page.waitForTimeout(TIMEOUT_1_SECOND);
55+
await this.loginDialogContinueBtn.click();
56+
await this.page.waitForTimeout(TIMEOUT_10_SECONDS);
57+
}
3658
}

test/e2e/tests/desktop/access-booking-page.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test, expect, type Page } from '@playwright/test';
22
import { BookingPage } from '../../pages/booking-page';
33
import { DashboardPage } from '../../pages/dashboard-page';
44

@@ -8,13 +8,14 @@ import {
88
TIMEOUT_60_SECONDS,
99
APPT_TARGET_ENV,
1010
APPT_TIMEZONE_SETTING_PRIMARY,
11+
TIMEOUT_1_SECOND,
1112
} from '../../const/constants';
1213

1314
var bookingPage: BookingPage;
1415
var dashboardPage: DashboardPage;
1516

1617
// verify booking page loaded successfully
17-
const verifyBookingPageLoaded = async () => {
18+
const verifyBookingPageLoaded = async (page: Page) => {
1819
await expect(bookingPage.titleText).toBeVisible({ timeout: TIMEOUT_60_SECONDS });
1920
await expect(bookingPage.titleText).toContainText(APPT_DISPLAY_NAME);
2021
await expect(bookingPage.invitingText).toBeVisible();
@@ -39,6 +40,7 @@ const verifyBookingPageLoaded = async () => {
3940
expect(await bookingPage.bookingWeekPickerBtn.textContent()).toContain(monthName);
4041

4142
// also the confirm button is disabled by default until a slot is selected
43+
await page.waitForTimeout(TIMEOUT_1_SECOND);
4244
await expect(bookingPage.confirmBtn).toBeDisabled();
4345
}
4446

@@ -59,7 +61,7 @@ test.describe('access booking page on desktop browser', () => {
5961
tag: [PLAYWRIGHT_TAG_PROD_SANITY],
6062
}, async ({ page }) => {
6163
await bookingPage.gotoBookingPageShortUrl();
62-
await verifyBookingPageLoaded();
64+
await verifyBookingPageLoaded(page);
6365
});
6466

6567
test('able to access booking page via long link on desktop browser', {
@@ -68,7 +70,7 @@ test.describe('access booking page on desktop browser', () => {
6870
// not supported on local dev env
6971
if (APPT_TARGET_ENV != 'dev') {
7072
await bookingPage.gotoBookingPageLongUrl();
71-
await verifyBookingPageLoaded();
73+
await verifyBookingPageLoaded(page);
7274
}
7375
});
7476
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ test.describe('connected applications settings on desktop browser', {
3737
await settingsPage.addCaldavBtn.scrollIntoViewIfNeeded();
3838
await settingsPage.addCaldavBtn.click();
3939
await page.waitForTimeout(TIMEOUT_1_SECOND);
40-
await expect(settingsPage.addCaldavUsernameInput).toBeEditable();
41-
await expect(settingsPage.addCaldavLocationInput).toBeEditable();
42-
await expect(settingsPage.addCaldavPasswordInput).toBeEditable();
40+
await expect(settingsPage.addCaldavUsernameInput).toBeVisible();
41+
await expect(settingsPage.addCaldavLocationInput).toBeVisible();
42+
await expect(settingsPage.addCaldavPasswordInput).toBeVisible();
4343
await settingsPage.addCaldavCloseModalBtn.click();
4444
await page.waitForTimeout(TIMEOUT_1_SECOND);
4545

test/e2e/utils/utils.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// utility functions that may be used by any tests
2-
import { LandingPage } from "../pages/landing-page";
32
import { TBAcctsPage } from "../pages/tb-accts-page";
43
import { expect, type Page } from '@playwright/test';
54

@@ -17,7 +16,6 @@ import {
1716
APPT_BROWSER_STORE_START_WEEK_SUN,
1817
TIMEOUT_1_SECOND,
1918
TIMEOUT_2_SECONDS,
20-
TIMEOUT_3_SECONDS,
2119
TIMEOUT_60_SECONDS,
2220
} from "../const/constants";
2321

@@ -28,27 +26,17 @@ import {
2826
* signing in on the local dev environment you provide a username (email) and password directly
2927
* and are not redirected to sign in to TB Accounts.
3028
*/
31-
export const navigateToAppointmentAndSignIn = async (page: Page, mobile: boolean=false) => {
29+
export const navigateToAppointmentAndSignIn = async (page: Page) => {
3230
console.log(`navigating to appointment ${APPT_TARGET_ENV} (${APPT_URL}) and signing in`);
33-
const landingPage = new LandingPage(page);
3431
const TBAcctsSignInPage = new TBAcctsPage(page);
35-
32+
33+
await page.goto(`${APPT_URL}`);
34+
3635
if (APPT_TARGET_ENV == 'prod' || APPT_TARGET_ENV == 'stage') {
37-
await landingPage.gotoLandingPage();
38-
// check for the 'continue' button first in case sign-in was saved in local cookies
39-
if (await landingPage.homeContinueBtn.isVisible() && await landingPage.homeContinueBtn.isEnabled()) {
40-
console.log("already signed in; just need to click the Appointment home page 'continue' button");
41-
await landingPage.homeContinueBtn.click();
42-
await page.waitForTimeout(TIMEOUT_3_SECONDS);
43-
} else {
44-
await landingPage.getToTBAccts(mobile);
45-
await TBAcctsSignInPage.signIn();
46-
}
36+
await TBAcctsSignInPage.signIn();
4737
} else {
48-
// local dev env doesn't use tb accts; just signs into appt using username and pword; must add
49-
// '/login' to the APPT_URL since there is no landing / marketing page first when run local stack
50-
await page.goto(`${APPT_URL}login`);
51-
await landingPage.localApptSignIn();
38+
// local dev env doesn't use tb accts; just signs into appt using username and pword
39+
await TBAcctsSignInPage.localApptSignIn();
5240
}
5341

5442
// now that we're signed into the appointment dashboard give it time to load
@@ -108,7 +96,7 @@ export const setDefaultUserSettingsLocalStore = async (page: Page) => {
10896
export const mobileSignInAndSetup = async (page: Page) => {
10997
// playwright for mobile browsers doesn't support saving auth storage state, so unfortunately
11098
// we must sign into Appointment at the start of every test
111-
await navigateToAppointmentAndSignIn(page, true);
99+
await navigateToAppointmentAndSignIn(page);
112100

113101
// Wait until the page receives the cookies.
114102
// Sometimes login flow sets cookies in the process of several redirects.

0 commit comments

Comments
 (0)