Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cdd 2285 - Addition of About Tab and dropdown functionality on mobile #588

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1761f36
CDD-2285: add in an about tab and move description into field
luketowell Jan 28, 2025
c88d9a6
CDD-2285: Updated the tests to handle the new about tab
luketowell Jan 28, 2025
e49e9d8
Merge branch 'main' into feature/CDD-2285
luketowell Jan 29, 2025
29b2ddc
feature/CDD-2285: created a new dropdown tab component
luketowell Jan 30, 2025
6ce1867
feature/CDD-2285: Added tests to test the functionality of the dropdo…
luketowell Feb 4, 2025
9472cbb
Merge branch 'main' into feature/CDD-2285
luketowell Feb 4, 2025
9b968e7
feature/CDD-2285: updated after reviewing sonar suggestions
luketowell Feb 4, 2025
baa7262
feature/CDD-2285: Updated the e2e tests for playwright
luketowell Feb 4, 2025
301f401
feature/CDD-2285: Updated the e2e tests for playwright
luketowell Feb 4, 2025
987dc7d
feature/CDD-2285: updated the desktop tests to use desktop functionality
luketowell Feb 5, 2025
22001e1
feature/CDD-2285: updated the desktop tests to use desktop and tablet…
luketowell Feb 5, 2025
74ca0f7
feature/CDD-2285: added mobile specific tests for the download functi…
luketowell Feb 5, 2025
dddf8ce
feature/CDD-2285: updated tests and removed the dropdownTab testId
luketowell Feb 10, 2025
2f5fa84
feature/CDD-2285: updated tests and removed the dropdownTab testId
luketowell Feb 10, 2025
05a5f37
Merge branch 'main' into feature/CDD-2285
luketowell Feb 10, 2025
5b15427
feature/CDD-2285: Updated the dropdownTab css to align text
luketowell Feb 11, 2025
89b9293
feature/CDD-2285: handle selected view by state management
luketowell Feb 12, 2025
f093fa7
feature/CDD-2285: Updated the functionality to manage state through a…
luketowell Feb 12, 2025
a80fd60
feature/CDD-2285: Updated the test functionality
luketowell Feb 12, 2025
c088e90
feature/CDD-2285: Updated the chart title and the aria-label for the …
luketowell Feb 13, 2025
1fbbb99
feature/CDD-2285: Updated the id of dropdown tab and removed the drop…
luketowell Feb 13, 2025
7c9eb32
feature/CDD-2285: Moved the onChangeFunction inline
luketowell Feb 13, 2025
59060ed
feature/CDD-2285: fix responsive chart issue
luketowell Feb 13, 2025
5ee1225
feature/CDD-2285: fix e2e test with updated name
luketowell Feb 13, 2025
1d535d8
feature/CDD-2285: Updated hard coded strings to be fetched from il8n …
luketowell Feb 14, 2025
af697d7
feature/CDD-2285: repair functionality so that space bar also updates…
luketowell Feb 14, 2025
a508099
feature/CDD-2285: resolved issue with the selection of tabs using spa…
luketowell Feb 14, 2025
dc42b58
CDD-2285: Reverted the transparent right border on the select feature
luketowell Feb 17, 2025
b7cebfc
Merge branch 'main' into feature/CDD-2285
luketowell Feb 18, 2025
e4a483c
feature/CDD-2285: update to add new sub-title field
luketowell Feb 20, 2025
5050649
feature/CDD-2285: tidy up
luketowell Feb 20, 2025
41921fc
feature/CDD-2285: revert changes to tests to remove description, upda…
luketowell Feb 20, 2025
36e170a
feature/CDD-2285: revert changes to chartRowHeader
luketowell Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 38 additions & 5 deletions e2e/fixtures/app.fixture.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AxeBuilder from '@axe-core/playwright'
import { expect, Locator, Page, test as base } from '@playwright/test'
import * as fs from 'fs'
import { kebabCase } from 'lodash'
import { kebabCase, lowerCase } from 'lodash'

import { relatedLinksMock } from '@/mock-server/handlers/cms/pages/fixtures/elements'
import { downloadsCsvFixture } from '@/mock-server/handlers/downloads/fixtures/downloads-csv'
Expand Down Expand Up @@ -286,9 +286,8 @@ export class App {
}
}

async hasTopicCard({ name, description }: { name: string; description: string }) {
async hasTopicCard({ name }: { name: string }) {
const card = this.page.getByRole('article', { name, exact: true })
await expect(card.getByRole('paragraph')).toContainText(description)
await expect(card.getByAltText(`Mocked alt text - Refer to tabular data.`)).toBeVisible()
}

Expand Down Expand Up @@ -368,11 +367,17 @@ export class App {

// Chart downloads

async canDownloadChart(cards: string[], format: 'csv' | 'json') {
async canDownloadChart(cards: string[], format: 'csv' | 'json', device: 'desktop' | 'mobile' | 'tablet') {
for (const name of cards) {
const card = this.page.getByTestId(`chart-row-card-${name}`)

await card.getByRole('tab', { name: 'Download' }).click()
if (device === 'mobile') {
await card
.getByRole('combobox', { name: `Choose display option for '${lowerCase(name)}' data` })
.selectOption('Download')
} else {
await card.getByRole('tab', { name: 'Download' }).click()
}

await card.getByLabel(format.toUpperCase()).click()

Expand Down Expand Up @@ -401,6 +406,34 @@ export class App {
}
}

async navigateChartTabsByKeyboardAndSelectWithEnterKey(cards: string[]) {
for (const name of cards) {
const card = this.page.getByTestId(`chart-row-card-${name}`)

await card.getByRole('tab', { name: 'Chart' }).click()

await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Enter')

await expect(card.getByText(/Download data/)).toBeVisible()
}
}

async navigateChartTabsByKeyboardAndSelectWithSpaceKey(cards: string[]) {
for (const name of cards) {
const card = this.page.getByTestId(`chart-row-card-${name}`)

await card.getByRole('tab', { name: 'Chart' }).click()

await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Tab')
await this.page.keyboard.press('Space')

await expect(card.getByText(/Download data/)).toBeVisible()
}
}

// Pagination

async hasPagination() {
Expand Down
206 changes: 89 additions & 117 deletions e2e/tests/topics/respiratory-viruses/covid-19.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,78 +35,53 @@ test.describe('COVID-19 page', () => {
await test.step('displays chart cards for "Cases"', async () => {
await app.hasTopicCard({
name: 'Cases by specimen date',
description: 'Number of cases by specimen date. Data for the last 5 days, highlighted in grey, are incomplete.',
})
await app.hasTopicCard({
name: '7-day case rates by specimen date',
description: 'Rate of cases per 100,000 people in the rolling 7-day period ending on the dates shown.',
})
await app.hasTopicCard({
name: 'Case rates by age',
description: 'Rates per 100,000 people of the total number of cases since the start of the pandemic, by age.',
})
})
await test.step('displays chart cards for "Deaths"', async () => {
await app.hasTopicCard({
name: 'Daily deaths with COVID-19 on the death certificate by date of death',
description:
'Daily numbers of deaths of people whose death certificate mentioned COVID-19 as one of the causes, and 7-day rolling average. Because of the time it takes for deaths to be registered, there is a lag in reporting of at least 11 days, and data are not shown for the 14 days before the most recent reported date as they are considered incomplete. Data are shown by date of death.',
})
})
await test.step('displays chart cards for "Healthcare"', async () => {
await app.hasTopicCard({
name: 'Bar chart with overlaying line comparing patients admitted to hospital with COVID-19',
description:
'Daily and total numbers of COVID-19 patients admitted to hospital. The overlaying line shows the 7-day average.',
})
await app.hasTopicCard({
name: 'Patients in hospital',
description:
'Daily count of confirmed COVID-19 patients in hospital at 8am. The overlaying line shows the 7-day average.',
})
await app.hasTopicCard({
name: 'Admissions rate by age',
description:
'Age breakdown of people admitted to hospital, shown as the rate per 100,000 people, since the start of the pandemic. There are fewer people in the oldest age group so the rates show the relative impact on different age groups.',
})
await app.hasTopicCard({
name: 'Patients in mechanical ventilation beds',
description:
'Daily count of COVID-19 patients in mechanical ventilation beds, and 7-day rolling average. Data are not updated every day.',
})
})
await test.step('displays chart cards for "Testing"', async () => {
await app.hasTopicCard({
name: 'Total daily number of PCR tests reported',
description:
'The daily number of new polymerase chain reaction (PCR) tests reported. Data is shown by specimen date (the date the sample was collected from the person).',
})
await app.hasTopicCard({
name: 'Weekly positivity of people receiving a PCR test',
description:
'The percentage positivity of people who received a polymerase chain reaction (PCR) and had at least one positive COVID-19 PCR test result in the same 7 days. Data is shown by specimen date (the date the sample was collected). People tested more than once in the period are only counted once in the denominator. People with more than one positive result in the period are only included once in the numerator.',
})
})
await test.step('displays chart cards for "Vaccinations"', async () => {
await app.hasTopicCard({
name: 'People aged 50 and over who have received autumn booster vaccinations, by vaccination date',
description:
'The number of people aged 50 and over who have received an autumn booster COVID-19 vaccination. Data for the latest 2 days, marked in grey, are incomplete. Data are shown by date of vaccination.',
})
await app.hasTopicCard({
name: 'Autumn booster vaccination uptake (50+), by vaccination date',
description:
'The percentage of people aged 50 and over who have received an autumn booster COVID-19 vaccination. The denominator is the number of people aged 50 and over on the National Immunisation Management Service (NIMS) database.',
})
await app.hasTopicCard({
name: 'People aged 75 and over who have received spring booster vaccinations, by vaccination date',
description:
'The number of people aged 75 and over who have received a spring booster COVID-19 vaccination. Data for the latest 2 days, marked in grey, are incomplete. Data are shown by date of vaccination.',
})
await app.hasTopicCard({
name: 'Spring booster vaccination uptake (75+), by vaccination date',
description:
'The percentage of people aged 75 and over who have received a spring booster COVID-19 vaccination. The denominator is the number of people aged 75 and over on the National Immunisation Management Service (NIMS) database.',
})
})
await test.step('displays related links', async () => {
Expand All @@ -117,60 +92,6 @@ test.describe('COVID-19 page', () => {
})
})

test('Downloads a csv version of each chart', async ({ covid19Page, app }) => {
await test.step('loads the page', async () => {
await covid19Page.goto()
})
await test.step('downloads charts', async () => {
await app.canDownloadChart(
[
'cases-by-specimen-date',
'7-day-case-rates-by-specimen-date',
'case-rates-by-age',
'daily-deaths-with-covid-19-on-the-death-certificate-by-date-of-death',
'bar-chart-with-overlaying-line-comparing-patients-admitted-to-hospital-with-covid-19',
'patients-in-hospital',
'admissions-rate-by-age',
'patients-in-mechanical-ventilation-beds',
'total-daily-number-of-pcr-tests-reported',
'weekly-positivity-of-people-receiving-a-pcr-test',
'people-aged-50-and-over-who-have-received-autumn-booster-vaccinations-by-vaccination-date',
'autumn-booster-vaccination-uptake-50-by-vaccination-date',
'people-aged-75-and-over-who-have-received-spring-booster-vaccinations-by-vaccination-date',
'spring-booster-vaccination-uptake-75-by-vaccination-date',
],
'csv'
)
})
})

test('Downloads a json version of each chart', async ({ covid19Page, app }) => {
await test.step('loads the page', async () => {
await covid19Page.goto()
})
await test.step('downloads charts', async () => {
await app.canDownloadChart(
[
'cases-by-specimen-date',
'7-day-case-rates-by-specimen-date',
'case-rates-by-age',
'daily-deaths-with-covid-19-on-the-death-certificate-by-date-of-death',
'bar-chart-with-overlaying-line-comparing-patients-admitted-to-hospital-with-covid-19',
'patients-in-hospital',
'admissions-rate-by-age',
'patients-in-mechanical-ventilation-beds',
'total-daily-number-of-pcr-tests-reported',
'weekly-positivity-of-people-receiving-a-pcr-test',
'people-aged-50-and-over-who-have-received-autumn-booster-vaccinations-by-vaccination-date',
'autumn-booster-vaccination-uptake-50-by-vaccination-date',
'people-aged-75-and-over-who-have-received-spring-booster-vaccinations-by-vaccination-date',
'spring-booster-vaccination-uptake-75-by-vaccination-date',
],
'json'
)
})
})

test('Area selection already chosen upon visiting the page', async ({ covid19Page, app }) => {
await test.step('loads the page', async () => {
await app.goto('/topics/covid-19?areaType=Lower+Tier+Local+Authority&areaName=Southampton')
Expand Down Expand Up @@ -290,13 +211,48 @@ test.describe('COVID-19 page', () => {
})
})

const chartIdentifiers = [
'cases-by-specimen-date',
'7-day-case-rates-by-specimen-date',
'case-rates-by-age',
'daily-deaths-with-covid-19-on-the-death-certificate-by-date-of-death',
'bar-chart-with-overlaying-line-comparing-patients-admitted-to-hospital-with-covid-19',
'patients-in-hospital',
'admissions-rate-by-age',
'patients-in-mechanical-ventilation-beds',
'total-daily-number-of-pcr-tests-reported',
'weekly-positivity-of-people-receiving-a-pcr-test',
'people-aged-50-and-over-who-have-received-autumn-booster-vaccinations-by-vaccination-date',
'autumn-booster-vaccination-uptake-50-by-vaccination-date',
'people-aged-75-and-over-who-have-received-spring-booster-vaccinations-by-vaccination-date',
'spring-booster-vaccination-uptake-75-by-vaccination-date',
]

test.describe('COVID-19 page - mobile @mobileOnly', () => {
test.use({ viewport: viewports.mobile })

test('displays the navigation on mobile', async ({ covid19Page, app }) => {
await covid19Page.goto()
await app.hasNav()
})

test('Downloads a csv version of each chart', async ({ covid19Page, app }) => {
await test.step('loads the page', async () => {
await covid19Page.goto()
})
await test.step('downloads charts', async () => {
await app.canDownloadChart(chartIdentifiers, 'csv', 'mobile')
})
})

test('Downloads a json version of each chart', async ({ covid19Page, app }) => {
await test.step('loads the page', async () => {
await covid19Page.goto()
})
await test.step('downloads charts', async () => {
await app.canDownloadChart(chartIdentifiers, 'json', 'mobile')
})
})
})

test.describe('COVID-19 page - tablet @tabletOnly', () => {
Expand All @@ -306,6 +262,24 @@ test.describe('COVID-19 page - tablet @tabletOnly', () => {
await covid19Page.goto()
await app.hasNav()
})

test('Downloads a csv version of each chart', async ({ covid19Page, app }) => {
await test.step('loads the page', async () => {
await covid19Page.goto()
})
await test.step('downloads charts', async () => {
await app.canDownloadChart(chartIdentifiers, 'csv', 'tablet')
})
})

test('Downloads a json version of each chart', async ({ covid19Page, app }) => {
await test.step('loads the page', async () => {
await covid19Page.goto()
})
await test.step('downloads charts', async () => {
await app.canDownloadChart(chartIdentifiers, 'json', 'tablet')
})
})
})

test.describe('COVID-19 page - desktop @desktopOnly', () => {
Expand All @@ -315,6 +289,40 @@ test.describe('COVID-19 page - desktop @desktopOnly', () => {
await covid19Page.goto()
await app.hasNav()
})

test('Downloads a csv version of each chart', async ({ covid19Page, app }) => {
await test.step('loads the page', async () => {
await covid19Page.goto()
})
await test.step('downloads charts', async () => {
await app.canDownloadChart(chartIdentifiers, 'csv', 'desktop')
})
})

test('Downloads a json version of each chart', async ({ covid19Page, app }) => {
await test.step('loads the page', async () => {
await covid19Page.goto()
})
await test.step('downloads charts', async () => {
await app.canDownloadChart(chartIdentifiers, 'json', 'desktop')
})
})
test('Navigates through the chart tabs using Enter Key on keyboard', async ({ covid19Page, app }) => {
await test.step('loads the page', async () => {
await covid19Page.goto()
})
await test.step('tabs through the tabs and navigates to the download content with Enter Key on keyboard', async () => {
await app.navigateChartTabsByKeyboardAndSelectWithEnterKey(chartIdentifiers)
})
})
test('Navigates through the chart tabs using Space Key on keyboard', async ({ covid19Page, app }) => {
await test.step('loads the page', async () => {
await covid19Page.goto()
})
await test.step('tabs through the tabs and navigates to the download content with Space Key on keyboard', async () => {
await app.navigateChartTabsByKeyboardAndSelectWithSpaceKey(chartIdentifiers)
})
})
})

test.describe('COVID-19 page - no JS', () => {
Expand All @@ -325,25 +333,7 @@ test.describe('COVID-19 page - no JS', () => {
await covid19Page.goto()
})
await test.step('downloads a csv version of each chart', async () => {
await app.canDownloadChart(
[
'cases-by-specimen-date',
'7-day-case-rates-by-specimen-date',
'case-rates-by-age',
'daily-deaths-with-covid-19-on-the-death-certificate-by-date-of-death',
'bar-chart-with-overlaying-line-comparing-patients-admitted-to-hospital-with-covid-19',
'patients-in-hospital',
'admissions-rate-by-age',
'patients-in-mechanical-ventilation-beds',
'total-daily-number-of-pcr-tests-reported',
'weekly-positivity-of-people-receiving-a-pcr-test',
'people-aged-50-and-over-who-have-received-autumn-booster-vaccinations-by-vaccination-date',
'autumn-booster-vaccination-uptake-50-by-vaccination-date',
'people-aged-75-and-over-who-have-received-spring-booster-vaccinations-by-vaccination-date',
'spring-booster-vaccination-uptake-75-by-vaccination-date',
],
'csv'
)
await app.canDownloadChart(chartIdentifiers, 'csv', 'desktop')
})
})

Expand All @@ -352,25 +342,7 @@ test.describe('COVID-19 page - no JS', () => {
await covid19Page.goto()
})
await test.step('downloads a csv version of each chart', async () => {
await app.canDownloadChart(
[
'cases-by-specimen-date',
'7-day-case-rates-by-specimen-date',
'case-rates-by-age',
'daily-deaths-with-covid-19-on-the-death-certificate-by-date-of-death',
'bar-chart-with-overlaying-line-comparing-patients-admitted-to-hospital-with-covid-19',
'patients-in-hospital',
'admissions-rate-by-age',
'patients-in-mechanical-ventilation-beds',
'total-daily-number-of-pcr-tests-reported',
'weekly-positivity-of-people-receiving-a-pcr-test',
'people-aged-50-and-over-who-have-received-autumn-booster-vaccinations-by-vaccination-date',
'autumn-booster-vaccination-uptake-50-by-vaccination-date',
'people-aged-75-and-over-who-have-received-spring-booster-vaccinations-by-vaccination-date',
'spring-booster-vaccination-uptake-75-by-vaccination-date',
],
'json'
)
await app.canDownloadChart(chartIdentifiers, 'json', 'desktop')
})
})

Expand Down
Loading
Loading