-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
147 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
// appointment urls | ||
export const APPT_PROD_URL = process.env.APPT_PROD_URL; | ||
export const APPT_PROD_MY_SHARE_LINK = String(process.env.APPT_PROD_MY_SHARE_LINK); | ||
export const APPT_PROD_SHORT_SHARE_LINK_PREFIX = String(process.env.APPT_PROD_SHORT_SHARE_LINK_PREFIX); | ||
export const APPT_PROD_LONG_SHARE_LINK_PREFIX = String(process.env.APPT_PROD_LONG_SHARE_LINK_PREFIX); | ||
|
||
// page titles | ||
export const APPT_PAGE_TITLE = 'Thunderbird Appointment'; | ||
export const FXA_PAGE_TITLE = 'Mozilla accounts'; | ||
|
||
// production sign-in credentials | ||
// production sign-in credentials and corresponding account display name | ||
export const PROD_LOGIN_EMAIL = process.env.APPT_PROD_LOGIN_EMAIL; | ||
export const PROD_LOGIN_PWORD = process.env.APPT_PROD_LOGIN_PWORD; | ||
|
||
// appointment user display name (settings => account) for above user | ||
export const PROD_DISPLAY_NAME = String(process.env.APPT_PROD_DISPLAY_NAME); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { type Page, type Locator } from '@playwright/test'; | ||
|
||
export class BookingPage { | ||
readonly page: Page; | ||
readonly titleText: Locator; | ||
readonly invitingText: Locator; | ||
readonly confirmButton: Locator; | ||
readonly bookingCalendar: Locator; | ||
readonly calendarHeader: Locator; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.titleText = page.getByTestId('booking-view-title-text'); | ||
this.invitingText = page.getByTestId('booking-view-inviting-you-text'); | ||
this.bookingCalendar = page.getByTestId('booking-view-calendar-div'); | ||
this.confirmButton = page.getByTestId('booking-view-confirm-selection-button'); | ||
this.calendarHeader = page.locator('.calendar-header__period-name'); | ||
} | ||
|
||
async gotoBookingPage(bookingPageURL: string) { | ||
await this.page.goto(bookingPageURL); | ||
await this.page.waitForLoadState('domcontentloaded'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { BookingPage } from '../pages/booking-page'; | ||
import { PROD_DISPLAY_NAME, APPT_PROD_MY_SHARE_LINK } from '../const/constants'; | ||
import { APPT_PROD_SHORT_SHARE_LINK_PREFIX, APPT_PROD_LONG_SHARE_LINK_PREFIX } from '../const/constants'; | ||
|
||
let bookingPage: BookingPage; | ||
|
||
// verify booking page loaded successfully | ||
const verifyBookingPageLoaded = async () => { | ||
await expect(bookingPage.titleText).toBeVisible({ timeout: 30_000 }); | ||
await expect(bookingPage.titleText).toContainText(PROD_DISPLAY_NAME); | ||
await expect(bookingPage.invitingText).toBeVisible(); | ||
await expect(bookingPage.invitingText).toContainText(PROD_DISPLAY_NAME); | ||
await expect(bookingPage.bookingCalendar).toBeVisible(); | ||
// calendar header should contain current MMM YYYY | ||
let today = new Date(); | ||
let curMonth = today.toLocaleString('default', { month: 'short' }); | ||
var curYear = String(today.getFullYear()); | ||
await expect(bookingPage.calendarHeader).toHaveText(`${curMonth} ${curYear}`); | ||
// confirm button is disabled by default until a slot is selected | ||
await expect(bookingPage.confirmButton).toBeDisabled(); | ||
} | ||
|
||
test.beforeEach(async ({ page }) => { | ||
bookingPage = new BookingPage(page); | ||
}); | ||
|
||
// verify we are able to book an appointment using existing user's share link | ||
test.describe('book an appointment', { | ||
tag: '@prod-sanity' | ||
}, () => { | ||
test('able to access booking page via short link', async ({ page }) => { | ||
await bookingPage.gotoBookingPage(APPT_PROD_MY_SHARE_LINK); | ||
await verifyBookingPageLoaded(); | ||
}); | ||
|
||
test('able to access booking page via long link', async ({ page }) => { | ||
// the share link is short by default; build the corresponding long link first | ||
let prodShareLinkUser: string = APPT_PROD_MY_SHARE_LINK.split(APPT_PROD_SHORT_SHARE_LINK_PREFIX)[1]; | ||
let prodShareLinkLong: string = `${APPT_PROD_LONG_SHARE_LINK_PREFIX}${prodShareLinkUser}`; | ||
await bookingPage.gotoBookingPage(prodShareLinkLong); | ||
await verifyBookingPageLoaded(); | ||
}); | ||
|
||
test('able to request a booking', async ({ page }) => { | ||
await bookingPage.gotoBookingPage(APPT_PROD_MY_SHARE_LINK); | ||
|
||
// by default we arrive on month view; if it happens to be the end of the month there may not | ||
// be any available appointment slots and we may need to go forward to the next month, but | ||
// let's first check for a specific slot (?) | ||
// this fails and says multi available | ||
//await expect(page.getByText('9:00 AM - 09:30 AM')).toBeVisible(); | ||
// these work - and result is the specific time slot is selected | ||
await expect(page.locator('[id="calendar-month__event-2025-01-08\\ 09\\:002025-01-08"]').getByText('9:00 AM - 09:30 AM')) | ||
.toBeVisible(); | ||
await page.locator('[id="calendar-month__event-2025-01-08\\ 09\\:002025-01-08"]').getByText('9:00 AM - 09:30 AM') | ||
.click(); | ||
// move above into bookingPage also; may need to get current date and then get next upcoming weekday? and get that slot? | ||
|
||
await bookingPage.confirmButton.click(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { SplashscreenPage } from '../pages/splashscreen-page'; | ||
import { FxAPage } from '../pages/fxa-page'; | ||
import { FXA_PAGE_TITLE, APPT_PAGE_TITLE } from '../const/constants'; | ||
import { APPT_PAGE_TITLE } from '../const/constants'; | ||
import { DashboardPage } from '../pages/dashboard-page'; | ||
|
||
let splashscreen: SplashscreenPage; | ||
let fxa_sign_in: FxAPage; | ||
let dashboard_page: DashboardPage; | ||
let splashscreenPage: SplashscreenPage; | ||
let signInPage: FxAPage; | ||
let dashboardPage: DashboardPage; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
// navigate to the main appointment page (splashscreen) | ||
splashscreen = new SplashscreenPage(page); | ||
fxa_sign_in = new FxAPage(page); | ||
dashboard_page = new DashboardPage(page); | ||
await splashscreen.gotoProd(); | ||
splashscreenPage = new SplashscreenPage(page); | ||
signInPage = new FxAPage(page); | ||
dashboardPage = new DashboardPage(page); | ||
await splashscreenPage.gotoProd(); | ||
}); | ||
|
||
// verify we are able to sign-in | ||
test.describe('sign-in', { | ||
tag: '@prod-sanity' | ||
}, () => { | ||
test('able to sign-in', async ({ page }) => { | ||
await splashscreen.getToFxA(); | ||
await splashscreenPage.getToFxA(); | ||
|
||
await expect(fxa_sign_in.signInHeaderText).toBeVisible({ timeout: 30_000 }); // generous time for fxa to appear | ||
await expect(fxa_sign_in.userAvatar).toBeVisible({ timeout: 30_000}); | ||
await expect(fxa_sign_in.signInButton).toBeVisible(); | ||
await expect(signInPage.signInHeaderText).toBeVisible({ timeout: 30_000 }); // generous time for fxa to appear | ||
await expect(signInPage.userAvatar).toBeVisible({ timeout: 30_000}); | ||
await expect(signInPage.signInButton).toBeVisible(); | ||
|
||
await fxa_sign_in.signIn(); | ||
await signInPage.signIn(); | ||
|
||
await page.waitForLoadState('domcontentloaded'); | ||
|
||
await expect(page).toHaveTitle(APPT_PAGE_TITLE, { timeout: 30_000 }); // give generous time for fxa sign-in | ||
await expect(dashboard_page.userMenuAvatar).toBeVisible({ timeout: 30_000 }); | ||
await expect(dashboard_page.navBarDashboardBtn).toBeVisible({ timeout: 30_000 }); | ||
await expect(dashboard_page.shareMyLink).toBeVisible({ timeout: 30_000 }); | ||
await expect(dashboardPage.userMenuAvatar).toBeVisible({ timeout: 30_000 }); | ||
await expect(dashboardPage.navBarDashboardBtn).toBeVisible({ timeout: 30_000 }); | ||
await expect(dashboardPage.shareMyLink).toBeVisible({ timeout: 30_000 }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters