-
Notifications
You must be signed in to change notification settings - Fork 1
APPT-1753 migrate playwright test v2 download reports #1341
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c60863c
Migrated to V2 for the report
pchoiwales ae1436e
From the PR 1341, reset the SiteSummaryReport to false
pchoi-al 930d69f
Removing the launch.json as we don't use that to debug Next JS code
pchoi-al be0fcda
Comments for Peter
jsed-nhs eeda6cd
Refactor download-report.spec.ts to use fixtures V2
pchoi-al fd93fa2
Removed locator as not used
pchoi-al 8703c5a
Fixed the headers for the report csv
pchoi-al 5da8b16
As per comments in PR 341
pchoi-al ca6ab69
As per comments in PR 1341
pchoi-al 14bfe11
package-lock.json updated to remove all node modules
pchoi-al 73432af
package-lock.json updated
pchoi-al 55a38e1
Removed V1 download-report.spec.ts
pchoi-al File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/client/testing/page-objects-v2/site/details/site-summary-report-page.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { MYALayout } from '@e2etests/types'; | ||
|
|
||
| export default class SiteSummaryReportPage extends MYALayout { | ||
| // Main Page Locators | ||
| readonly title = this.page.getByRole('heading', { | ||
| name: 'Download the report', | ||
| }); | ||
|
|
||
| readonly selectDatesStep = { | ||
| stepTitle: this.page.getByRole('heading', { | ||
| name: 'Select the dates and run a report', | ||
| }), | ||
| goBackButton: this.page.getByRole('link', { name: 'Go back' }), | ||
| startDateInput: this.page.getByLabel('Start date'), | ||
| endDateInput: this.page.getByLabel('End date'), | ||
| continueButton: this.page.getByRole('button', { name: 'Create report' }), | ||
| }; | ||
|
|
||
| readonly confirmDownloadStep = { | ||
| stepTitle: this.page.getByRole('heading', { name: 'Download the report' }), | ||
| goBackButton: this.page.getByRole('link', { name: 'Go back' }), | ||
| continueButton: this.page.getByRole('button', { name: 'Export data' }), | ||
| }; | ||
|
|
||
| async downloadReport() { | ||
| const downloadPromise = this.page.waitForEvent('download'); | ||
| await this.confirmDownloadStep.continueButton.click(); | ||
| return await downloadPromise; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/client/testing/tests-v2/reports/download-report.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import * as fs from 'fs'; | ||
| import { test, expect } from '../../fixtures-v2'; | ||
|
|
||
| test.describe.configure({ mode: 'serial' }); | ||
|
|
||
| test('Navigates to the reports page via the header before selecting a site', async ({ | ||
| setUpSingleSite, | ||
| }) => { | ||
| await setUpSingleSite({ | ||
| features: [{ name: 'SiteSummaryReport', enabled: true }], | ||
| }) | ||
| .then(async sitePageFixture => sitePageFixture.sitePage.topNav.clickReports()) | ||
| .then(async reportsPage => { | ||
| await expect(reportsPage.selectDatesStep.stepTitle).toBeVisible(); | ||
| }); | ||
| }); | ||
|
|
||
| test('Navigates to the reports page via a site page', async ({ | ||
| setUpSingleSite, | ||
| }) => { | ||
| await setUpSingleSite({ | ||
| features: [{ name: 'SiteSummaryReport', enabled: true }], | ||
| }) | ||
| .then(async sitePageFixture => sitePageFixture.sitePage.clickReportsCard()) | ||
| .then(async reportsPage => { | ||
| await expect(reportsPage.selectDatesStep.stepTitle).toBeVisible(); | ||
| }); | ||
| }); | ||
|
|
||
| test('Downloads a site summary report', async ({ page, setUpSingleSite }) => { | ||
| const fileName = 'downloaded-test-report.csv'; | ||
|
|
||
| await setUpSingleSite({ | ||
| features: [{ name: 'SiteSummaryReport', enabled: true }], | ||
| }) | ||
| .then(async sitePageFixture => sitePageFixture.sitePage.topNav.clickReports()) | ||
| .then(async reportsPage => { | ||
| const today: string = new Date().toISOString().split('T')[0]; | ||
| await reportsPage.selectDatesStep.startDateInput.fill(today); | ||
| await reportsPage.selectDatesStep.endDateInput.fill(today); | ||
| await reportsPage.selectDatesStep.continueButton.click(); | ||
|
|
||
| await expect(reportsPage.confirmDownloadStep.stepTitle).toBeVisible(); | ||
|
|
||
| const downloadPromise = page.waitForEvent('download'); | ||
| await reportsPage.confirmDownloadStep.continueButton.click(); | ||
| return downloadPromise; | ||
| }) | ||
| .then(async download => { | ||
| expect(download.suggestedFilename()).toContain( | ||
| 'GeneralSiteSummaryReport', | ||
| ); | ||
| await download.saveAs(fileName); | ||
|
|
||
| const csvContent = fs.readFileSync(fileName, 'utf-8'); | ||
| const lines = csvContent | ||
| .split('\n') | ||
| .filter(line => line.trim().length > 0); | ||
|
|
||
| // Normalize headers by splitting and trimming whitespace/line endings | ||
| const headers = lines[0].split(',').map(h => h.trim()); | ||
|
|
||
| expect(lines.length).toBeGreaterThan(1); | ||
| expect(headers).toEqual(expectedFileDownloadHeaders); | ||
| }) | ||
| .finally(() => { | ||
| if (fs.existsSync(fileName)) { | ||
| fs.unlinkSync(fileName); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| const expectedFileDownloadHeaders = [ | ||
| 'Site Name', | ||
| 'Status', | ||
| 'Site Type', | ||
| 'ICB', | ||
| 'ICB Name', | ||
| 'Region', | ||
| 'Region Name', | ||
| 'ODS Code', | ||
| 'Longitude', | ||
| 'Latitude', | ||
| 'FLU:2_3 Booked', | ||
| 'FLU:18_64 Booked', | ||
| 'FLU:65+ Booked', | ||
| 'COVID:5_11 Booked', | ||
| 'COVID:12_17 Booked', | ||
| 'COVID:18+ Booked', | ||
| 'COVID_FLU:18_64 Booked', | ||
| 'COVID_FLU:65+ Booked', | ||
| 'RSV:Adult Booked', | ||
| 'COVID_RSV:18+ Booked', | ||
| 'Total Bookings', | ||
| 'Cancelled', | ||
| 'Maximum Capacity', | ||
| 'FLU:2_3 Capacity', | ||
| 'FLU:18_64 Capacity', | ||
| 'FLU:65+ Capacity', | ||
| 'COVID:5_11 Capacity', | ||
| 'COVID:12_17 Capacity', | ||
| 'COVID:18+ Capacity', | ||
| 'COVID_FLU:18_64 Capacity', | ||
| 'COVID_FLU:65+ Capacity', | ||
| 'RSV:Adult Capacity', | ||
| 'COVID_RSV:18+ Capacity', | ||
| ]; | ||
119 changes: 0 additions & 119 deletions
119
src/client/testing/tests/reports/download-report.spec.ts
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.