Skip to content

Commit

Permalink
CDD-2363: Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Towell committed Dec 10, 2024
1 parent 7376a50 commit 3fe4d56
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
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 @@ -64,13 +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} Alert`
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('Alert', { exact: true })).toBeVisible()
await expect(wrapper.getByText(status)).toBeVisible()
await expect(wrapper.getByText(expectedStatus)).toBeVisible()

await expect(wrapper.getByText('Start')).toBeVisible()
await expect(wrapper.getByText(start)).toBeVisible()
Expand Down
19 changes: 8 additions & 11 deletions src/app/components/ui/ukhsa/List/ListItemStatus.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,15 @@ describe('renders correct tag', () => {
test('renders green tag', () => {
const { getByText } = render(<ListItemStatusTag type="heat" level="Green" region="East of England" />)

expect(getByText('Green')).toHaveClass('govuk-tag--green')
expect(getByText('Green')).toHaveAttribute(
'aria-label',
'There is currently a Green heat alert status for East of England'
)
expect(getByText('No alert')).toHaveClass('bg-green')
expect(getByText('No alert')).toHaveAttribute('aria-label', 'There are currently no alerts for East of England')
})

test('renders yellow tag', () => {
const { getByText } = render(<ListItemStatusTag type="heat" level="Yellow" region="South East" />)

expect(getByText('Yellow')).toHaveClass('govuk-tag--yellow')
expect(getByText('Yellow')).toHaveAttribute(
expect(getByText('yellow alert')).toHaveClass('bg-custard')
expect(getByText('yellow alert')).toHaveAttribute(
'aria-label',
'There is currently a Yellow heat alert status for South East'
)
Expand All @@ -104,8 +101,8 @@ describe('renders correct tag', () => {
test('renders amber tag', () => {
const { getByText } = render(<ListItemStatusTag type="cold" level="Amber" region="West Midlands" />)

expect(getByText('Amber')).toHaveClass('govuk-tag--orange')
expect(getByText('Amber')).toHaveAttribute(
expect(getByText('amber alert')).toHaveClass('bg-orange')
expect(getByText('amber alert')).toHaveAttribute(
'aria-label',
'There is currently an Amber cold alert status for West Midlands'
)
Expand All @@ -114,8 +111,8 @@ describe('renders correct tag', () => {
test('renders red tag', () => {
const { getByText } = render(<ListItemStatusTag type="cold" level="Red" region="East Midlands" />)

expect(getByText('Red')).toHaveClass('govuk-tag--red')
expect(getByText('Red')).toHaveAttribute(
expect(getByText('red alert')).toHaveClass('bg-red')
expect(getByText('red alert')).toHaveAttribute(
'aria-label',
'There is currently a Red cold alert status for East Midlands'
)
Expand Down

0 comments on commit 3fe4d56

Please sign in to comment.