WS-2092: Migrate cypress tests for OnDemandAudio pages to NextJS#13688
WS-2092: Migrate cypress tests for OnDemandAudio pages to NextJS#13688Isabella-Mitchell merged 8 commits intolatestfrom
Conversation
| cy.log( | ||
| `On Demand Radio Page configured for Radio Schedule? ${scheduleIsEnabled}`, | ||
| ); | ||
| cy.fixture(`toggles/${service}.json`).then(toggles => { |
There was a problem hiding this comment.
Refactors this test so that it won't fail on live and test before the ALB changes are live.
The issue is that the getPageDataFromWindow() function relies on the Next object. This will always return false before the ALB changes are live. So the check on line 92 cy.get('[data-e2e=radio-schedule]').should('not.exist'); was being run against live and test pages which did have the radio schedule.
This refactor means that the the cy.get('[data-e2e=radio-schedule]').should('not.exist'); is only run on assets were the toggle is false. If the pageData object is false, there are no assertions.
There was a problem hiding this comment.
Pull request overview
Migrates Cypress E2E coverage for OnDemandAudio pages into the Next.js app, converting the main spec to TypeScript and removing the legacy Express-app equivalents.
Changes:
- Moved OnDemandAudio Cypress specs into
ws-nextjs-appand converted the main entry spec to.ts - Removed the old
.jsCypress spec files from the prior locations - Updated page type usage to align with Next.js route/page type constants
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ws-nextjs-app/cypress/e2e/onDemandAudio/tests.ts | Updates OnDemandAudio test logic around radio schedule toggle/data handling |
| ws-nextjs-app/cypress/e2e/onDemandAudio/index.cy.ts | Converts the spec to TS, updates imports, and introduces typing for test suites |
| ws-nextjs-app/cypress/e2e/onDemandAudio/index.cy.js | Removes legacy JS spec in favor of TS version |
| cypress/e2e/pages/onDemandAudio/tests.js | Removes legacy Express-app OnDemandAudio tests |
| if (scheduleIsEnabled && radioScheduleData) { | ||
| cy.log('Schedule has enough data'); | ||
| cy.get('[data-e2e=radio-schedule]').should('exist'); | ||
| // cy.get('[data-e2e=live]').should('exist'); |
There was a problem hiding this comment.
When the schedule toggle is enabled but radioScheduleData is missing/insufficient, the test currently makes no assertion (it will pass regardless). Re-introduce the negative assertion (and/or an explicit log) for the !radioScheduleData case so the test reliably validates expected behavior.
| if (scheduleIsEnabled && radioScheduleData) { | |
| cy.log('Schedule has enough data'); | |
| cy.get('[data-e2e=radio-schedule]').should('exist'); | |
| // cy.get('[data-e2e=live]').should('exist'); | |
| if (radioScheduleData) { | |
| cy.log('Schedule has enough data'); | |
| cy.get('[data-e2e=radio-schedule]').should('exist'); | |
| // cy.get('[data-e2e=live]').should('exist'); | |
| } else { | |
| cy.log( | |
| 'Schedule toggle is on but schedule data is missing or insufficient', | |
| ); | |
| cy.get('[data-e2e=radio-schedule]').should('not.exist'); |
There was a problem hiding this comment.
Created a tech ticket for this - https://bbc.atlassian.net/browse/WS-2175
Resolves JIRA: https://bbc.atlassian.net/browse/WS-2092
Summary
Migrate cypress tests for OnDemandAudio pages to NextJS
Code changes
Testing
Run locally
Also check on Test, Live and non-smoke tests, using flags like CYPRESS_APP_ENV=test or live and CYPRESS_SMOKE=false
Useful Links