Skip to content

Commit

Permalink
Merge branch 'main' into task/block-deployments-over-change-freeze-pe…
Browse files Browse the repository at this point in the history
…riod/CDD-2369
  • Loading branch information
A-Ashiq authored Dec 13, 2024
2 parents c57c969 + ee6642b commit 94bcf4d
Show file tree
Hide file tree
Showing 68 changed files with 1,105 additions and 1,837 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ yarn-error.log*

# typescript
*.tsbuildinfo
next-env.d.ts
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
"typescript.enablePromptUseWorkspaceTsdk": true,
"cSpell.words": ["Colour"]
}
8 changes: 4 additions & 4 deletions e2e/fixtures/app.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
ErrorPage,
FeedbackConfirmationPage,
FeedbackPage,
HomePage,
InfluenzaPage,
LandingPage,
MetricsChildPage,
MetricsParentPage,
NotFoundPage,
Expand All @@ -39,7 +39,7 @@ type Fixtures = {
app: App
switchboardPage: SwitchboardPage
sitemapPage: SitemapPage
homePage: HomePage
landingPage: LandingPage
aboutPage: AboutPage
archiveDataPage: ArchiveDataPage
bulkDownloadsPage: BulkDownloadsPage
Expand Down Expand Up @@ -510,8 +510,8 @@ export const test = base.extend<Fixtures>({
switchboardPage: async ({ page }, use) => {
await use(new SwitchboardPage(page))
},
homePage: async ({ page }, use) => {
await use(new HomePage(page))
landingPage: async ({ page }, use) => {
await use(new LandingPage(page))
},
aboutPage: async ({ page }, use) => {
await use(new AboutPage(page))
Expand Down
2 changes: 1 addition & 1 deletion e2e/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export * from './pages/common/compliance.fixture'
export * from './pages/composite/archive-data.fixture'
export * from './pages/feedback/confirmation.fixture'
export * from './pages/feedback/feedback.fixture'
export * from './pages/home/home.fixture'
export * from './pages/landing/landing.fixture'
export * from './pages/metrics/metrics-child.fixture'
export * from './pages/metrics/metrics-parent.fixture'
export * from './pages/misc/browse.fixture'
Expand Down
386 changes: 0 additions & 386 deletions e2e/fixtures/pages/home/home.fixture.ts

This file was deleted.

122 changes: 122 additions & 0 deletions e2e/fixtures/pages/landing/landing.fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import type { Page } from '@playwright/test'
import { expect } from '@playwright/test'

export class LandingPage {
readonly page: Page

constructor(page: Page) {
this.page = page
}

async goto() {
await this.page.goto('/')
}

async hasMetadata() {
const title = await this.page.title()
await expect(title).toBe('UKHSA data dashboard')
await expect(this.page.locator('meta[name="description"]')).toHaveAttribute(
'content',
'Overall summary of the respiratory viruses in circulation within the UK'
)
}

async hasHeading() {
await expect(this.page.getByRole('heading', { name: /UKHSA data dashboard/, level: 1 })).toBeVisible()
}

async hasNotLastUpdated() {
await expect(this.page.getByText(/Last updated/)).toBeHidden()
}

async hasPageDescription() {
await expect(
this.page.getByText(
'The UKHSA data dashboard shows public health data across England. It builds on the success and is an iteration of the COVID-19 in the UK dashboard.'
)
).toBeVisible()
}

async hasSection(sections: string[]) {
for (const name of sections) {
await expect(this.page.getByRole('heading', { level: 2, name })).toBeVisible()
}
}

async hasCategories(categories: string[]) {
for (const name of categories) {
await expect(this.page.getByRole('region', { name })).toBeVisible()
}
}

async hasHealthTopicColumns(columns: string[]) {
const section = this.page.getByRole('region', { name: 'Respiratory viruses' })

await expect(await section.getByRole('heading', { level: 3 }).count()).toEqual(columns.length)

for (const name of columns) {
await expect(
section.getByTestId('chart-row-cards').getByRole('heading', { level: 3, name }).isVisible
).toBeTruthy()
}
}

async hasLandingPageCard({ title, sub_title }: { title: string; sub_title: string }) {
const section = this.page.getByRole('region', { name: 'Respiratory viruses' })
const card = section.getByRole('link', { name: title })

await expect(card.getByRole('heading', { level: 3, name: title })).toBeVisible()
await expect(card.getByText(sub_title)).toBeVisible()
}

async hasHealthTopicCard(
name: string,
{ tagline, trendPercent, trendDescription }: { tagline: string; trendPercent: string; trendDescription: string }
) {
const section = this.page.getByRole('region', { name: 'Respiratory viruses' })
const card = section.getByRole('link', { name })

await expect(card.getByRole('heading', { name })).toBeVisible()
await expect(card.getByText(tagline)).toBeVisible()
await expect(card.getByTestId('chart-image')).toBeVisible()
await expect(card.getByText(trendPercent, { exact: true })).toBeVisible()
await expect(card.getByText(trendDescription, { exact: true })).toBeVisible()
}

async hasWeatherHealthAlertsCard(name: string, { tagline, map = true }: { tagline: string; map?: boolean }) {
const section = this.page.getByRole('region', { name: 'Weather health alerts' })
const card = section.getByRole('link', { name })

await expect(section).toBeVisible()
await expect(card).toBeVisible()
await expect(card.getByRole('heading', { name, level: 3 })).toBeVisible()
await expect(card.getByText(tagline)).toBeVisible()

if (map) {
await expect(card.getByRole('application', { name: 'Map of weather health alerts' })).toBeVisible()
} else {
await expect(card.getByRole('application', { name: 'Map of weather health alerts' })).toBeHidden()
}

const regions = this.page.getByRole('list', { name: 'Weather health alerts by region' })
await expect(regions).toBeVisible()
await expect(await regions.getByRole('listitem').all()).toHaveLength(13)
await expect(card.getByRole('button', { name: 'Enter fullscreen' })).toBeVisible()
}

async clickMinimapCard(name: string) {
const section = this.page.getByRole('region', { name: 'Weather health alerts' })
const card = section.getByRole('link', { name })
await card.click()
}

async clickMinimapCardRegionByMap(name: string, regionId: string) {
const section = this.page.getByRole('region', { name: 'Weather health alerts' })
const card = section.getByRole('link', { name })
const map = card.getByRole('application', { name: 'Map of weather health alerts' })
await expect(map).toBeVisible()
const region = map.getByTestId(`feature-${regionId}`)
await expect(region).toBeVisible()
await region.click()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ export class WeatherHealthAlertsChildPage {
await expect(await regions.getByRole('listitem').all()).toHaveLength(9)

for (let i = 0; i < alertList.length; i++) {
const expectedStatus = alertList[i].status === 'Green' ? 'No alert' : `${alertList[i].status.toLowerCase()} alert`
const listItem = regions.getByRole('listitem').nth(i)
await expect(listItem).toBeVisible()

await expect(listItem.getByRole('heading', { level: 2, name: alertList[i].region })).toBeVisible()
await expect(listItem.getByText(alertList[i].updated)).toBeVisible()
await expect(listItem.getByText(alertList[i].status, { exact: true })).toBeVisible()
await expect(listItem.getByText(expectedStatus, { exact: true })).toBeVisible()

//TODO: Need to implement tags for mobile vs desktop tags CDD-2024
// if (this.isMobile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ export class WeatherHealthAlertsMapPage {
await expect(this.page.getByRole('button', { name: 'Exit map' })).toBeVisible()
}

async hasMapKey() {
await expect(this.page.getByTestId('map-key')).toBeVisible()
}

async hasUKHSALogo() {
await expect(this.page.getByTestId('logo-layer')).toBeVisible()
}

async hasDisplayKeyButton() {
await expect(this.page.getByRole('button', { name: 'Display key' })).toBeVisible()
}

async mapKeyCanBeMinimised() {
await expect(this.page.getByTestId('close-key-button')).toBeVisible()
await this.page.getByTestId('close-key-button').click()
}

async clickDisplayKeyButton() {
await expect(this.page.getByRole('button', { name: 'Display key' })).toBeVisible()
await this.page.getByRole('button', { name: 'Display key' }).click()
}

async hasButton(name: ButtonNames) {
await expect(this.page.getByRole('button', { name })).toBeVisible()
}
Expand Down Expand Up @@ -117,22 +139,35 @@ export class WeatherHealthAlertsMapPage {
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Enter')
}

async zoomInWithKeyboard() {
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Enter')
await this.page.keyboard.press('Enter')
}

async zoomOutWithKeyboard() {
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Enter')
await this.page.keyboard.press('Enter')
}

async closeKeyWithKeyboard() {
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Enter')
}

async openKeyWithKeyboard() {
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Enter')
}

async accessRegionWithKeyboard(regionNumber: number) {
await this.page.keyboard.press(`Digit${regionNumber}`)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ export class WeatherHealthAlertsRegionPage {
async hasAlertSummaryList({ type, status, start, end }: SummaryList) {
const wrapper = this.page.getByLabel('Alert details')

const expectedStatus = status === 'Green' ? 'No alert' : `${status.toLowerCase()} alert`

await expect(wrapper.getByText('Type')).toBeVisible()
await expect(wrapper.getByText(type)).toBeVisible()

await expect(wrapper.getByText('Colour')).toBeVisible()
await expect(wrapper.getByText(status)).toBeVisible()
await expect(wrapper.getByText('Alert', { exact: true })).toBeVisible()
await expect(wrapper.getByText(expectedStatus)).toBeVisible()

await expect(wrapper.getByText('Start')).toBeVisible()
await expect(wrapper.getByText(start)).toBeVisible()
Expand Down
Loading

0 comments on commit 94bcf4d

Please sign in to comment.