From 1e98aac7b53b475e0ea4b926c6ed143724bea2b2 Mon Sep 17 00:00:00 2001 From: rwood-moz Date: Fri, 6 Dec 2024 16:15:25 -0500 Subject: [PATCH] Add test for splashscreen --- test/e2e/const/constants.ts | 5 +++++ test/e2e/pages/splashscreen-page.ts | 18 ++++++++++++++++++ test/e2e/playwright.config.ts | 2 +- test/e2e/tests/example.spec.ts | 18 ------------------ test/e2e/tests/splashscreen.spec.ts | 22 ++++++++++++++++++++++ 5 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 test/e2e/const/constants.ts create mode 100644 test/e2e/pages/splashscreen-page.ts delete mode 100644 test/e2e/tests/example.spec.ts create mode 100644 test/e2e/tests/splashscreen.spec.ts diff --git a/test/e2e/const/constants.ts b/test/e2e/const/constants.ts new file mode 100644 index 000000000..10e17924d --- /dev/null +++ b/test/e2e/const/constants.ts @@ -0,0 +1,5 @@ +// appointment urls +export const APPT_PROD_URL = 'https://appointment.day/'; + +// page titles +export const APPT_PAGE_TITLE = 'Thunderbird Appointment'; diff --git a/test/e2e/pages/splashscreen-page.ts b/test/e2e/pages/splashscreen-page.ts new file mode 100644 index 000000000..6ad2cffd3 --- /dev/null +++ b/test/e2e/pages/splashscreen-page.ts @@ -0,0 +1,18 @@ +import { type Page, type Locator } from '@playwright/test'; +import { APPT_PROD_URL } from '../const/constants'; + +export class SplashscreenPage { + readonly page: Page; + readonly loginBtn: Locator; + readonly signUpBetaBtn: Locator; + + constructor(page: Page) { + this.page = page; + this.loginBtn = this.page.getByTestId('home-login-btn'); + this.signUpBetaBtn = this.page.getByTestId('home-sign-up-beta-btn'); + } + + async gotoProd() { + await this.page.goto(APPT_PROD_URL); + } +} diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index a05d8b5a1..2f87197cd 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -22,7 +22,7 @@ export default defineConfig({ /* Opt out of parallel tests on CI. */ workers: process.env.CI ? 1 : undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', + reporter: [['html'], ['list']], /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ diff --git a/test/e2e/tests/example.spec.ts b/test/e2e/tests/example.spec.ts deleted file mode 100644 index 54a906a4e..000000000 --- a/test/e2e/tests/example.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { test, expect } from '@playwright/test'; - -test('has title', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Playwright/); -}); - -test('get started link', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Click the get started link. - await page.getByRole('link', { name: 'Get started' }).click(); - - // Expects page to have a heading with the name of Installation. - await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); -}); diff --git a/test/e2e/tests/splashscreen.spec.ts b/test/e2e/tests/splashscreen.spec.ts new file mode 100644 index 000000000..19b2230d4 --- /dev/null +++ b/test/e2e/tests/splashscreen.spec.ts @@ -0,0 +1,22 @@ +import { test, expect } from '@playwright/test'; +import { SplashscreenPage } from '../pages/splashscreen-page'; +import { APPT_PAGE_TITLE } from '../const/constants'; + +let splashscreen: any = {}; + +test.beforeEach(async ({ page }) => { + // navigate to the main appointment page (splashscreen) + splashscreen = new SplashscreenPage(page); + await splashscreen.gotoProd(); +}); + +// verify main appointment splash screen appears correctly +test.describe('splash screen', { + tag: '@prod-sanity' +}, () => { + test('has title, login button, and signup beta button', async ({ page }) => { + await expect(page).toHaveTitle(APPT_PAGE_TITLE); + await expect(splashscreen.loginBtn).toBeVisible(); + await expect(splashscreen.signUpBetaBtn).toBeVisible(); + }); +});