Skip to content

Commit

Permalink
Regression fix rebranch (#281)
Browse files Browse the repository at this point in the history
* Added ok button to DateTimePicker and updated tests

* Refactored code

* Save point

* Moved the validation for the forecast base date into that control

* Save point

* Refactored and fixed tests

* Refactored code

* Refactored code

* Date picker ok button update (#278)

* Refactored code

* Add confimation method when picking date for automation

---------

Co-authored-by: Benjamin Ell-Jones <56438486+Ben-EJ@users.noreply.github.com>

---------

Co-authored-by: Benjamin Ell-Jones <56438486+Ben-EJ@users.noreply.github.com>
Co-authored-by: rstrange-scottlogic <rstrange@scottlogic.com>
  • Loading branch information
3 people authored Aug 2, 2024
1 parent 2549506 commit 3f28540
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions air-quality-ui/system_tests/pages/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class Banner extends BasePage {
readonly page: Page

readonly calendarIcon: Locator
readonly dateOkButton: Locator
readonly datePicker: Locator
readonly datePickerNextMonthButton: Locator
readonly datePickerTimeOptions: Locator
Expand All @@ -22,6 +23,7 @@ export class Banner extends BasePage {
this.page = page

this.calendarIcon = page.getByTestId('CalendarIcon')
this.dateOkButton = page.getByRole('button', { name: 'Ok' })
this.datePicker = page.getByRole('textbox', { name: 'Forecast Base Date' })
this.datePickerNextMonthButton = page.getByLabel('Next month')
this.datePickerTimeOptions = page.locator('ul > [role="option"]')
Expand Down Expand Up @@ -71,6 +73,10 @@ export class Banner extends BasePage {
}
}

async confirmDate() {
await this.dateOkButton.click()
}

async setBaseTime(baseTime: string): Promise<void> {
await this.datePicker.fill(baseTime)
}
Expand Down
6 changes: 4 additions & 2 deletions air-quality-ui/system_tests/ui/city_page/city_page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ test.use({
viewport: { width: 1920, height: 1080 },
})
test.describe('City graph snapshots', () => {
test.beforeEach(async ({ cityPage, page }) => {
test.beforeEach(async ({ cityPage, page, banner }) => {
const mockedForecastResponse = [
createForecastAPIResponseData({
base_time: '2024-07-01T00:00:00Z',
Expand Down Expand Up @@ -321,6 +321,7 @@ test.describe('City graph snapshots', () => {
await gotoPage(page, '/city/Rio%20de%20Janeiro')
await cityPage.waitForAllGraphsToBeVisible()
await cityPage.setBaseTime('01/07/2024 00:00')
await banner.confirmDate()
})

test('AQI snapshot', async ({ cityPage }) => {
Expand Down Expand Up @@ -400,7 +401,7 @@ test.use({
viewport: { width: 1920, height: 1080 },
})
test.describe('Charts are fully visible in 1920x1080 viewport', () => {
test.beforeEach(async ({ page, cityPage }) => {
test.beforeEach(async ({ page, cityPage, banner }) => {
const mockedForecastResponse = [
createForecastAPIResponseData({
base_time: '2024-07-01T00:00:00Z',
Expand Down Expand Up @@ -431,6 +432,7 @@ test.describe('Charts are fully visible in 1920x1080 viewport', () => {

await cityPage.waitForAllGraphsToBeVisible()
await cityPage.setBaseTime('01/07/2024 00:00')
await banner.confirmDate()
})

test('AQI chart element is visible in fullscreen view', async ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ test.describe('API calls on changing forecast base time in UI', () => {
banner,
}) => {
await banner.clickOnDay(3)
await banner.confirmDate()
expect(requestArray.length).toEqual(1)
})

Expand All @@ -106,6 +107,7 @@ test.describe('API calls on changing forecast base time in UI', () => {
)

await banner.clickOnDay(3)
await banner.confirmDate()
expect(requestArray[0]).toContain(`base_time=${expectedForecastBaseTime}`)
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ test.describe('API calls on changing forecast base time in UI', () => {
banner,
}) => {
await banner.clickOnDay(3)
await banner.confirmDate()
expect(requestArray.length).toEqual(1)
})

Expand All @@ -151,6 +152,7 @@ test.describe('API calls on changing forecast base time in UI', () => {
await encodeDateToURIComponent(systemDate)

await banner.clickOnDay(3)
await banner.confirmDate()
expect(requestArray[0]).toContain(
`location_type=city&valid_time_from=${expectedValidTimeFrom}&valid_time_to=${systemDateUriEncoded}&base_time=${expectedForecastBaseTime}`,
)
Expand Down Expand Up @@ -179,6 +181,7 @@ test.describe('API calls on changing forecast base time in UI', () => {
banner,
}) => {
await banner.clickOnDay(3)
await banner.confirmDate()
expect(requestArray.length).toEqual(41)
})

Expand Down Expand Up @@ -229,6 +232,7 @@ test.describe('API calls on changing forecast base time in UI', () => {
'2024-07-08T12%3A00%3A00.000Z',
]
await banner.clickOnDay(3)
await banner.confirmDate()
for (const request in requestArray) {
expect(requestArray[request]).toContain(
`measurement_base_time=${expectedMeasurementBaseTimeArray[request]}&measurement_time_range=90&location_type=city`,
Expand Down

0 comments on commit 3f28540

Please sign in to comment.