diff --git a/cypress/support/helpers/getPathWithSuffix.ts b/cypress/support/helpers/getPathWithSuffix.ts deleted file mode 100644 index 3b643d1e7cf..00000000000 --- a/cypress/support/helpers/getPathWithSuffix.ts +++ /dev/null @@ -1,5 +0,0 @@ -export default ({ path, suffix = '' }) => { - const { pathname, search } = new URL(`https://www.bbc.com${path}`); - - return `${pathname}${suffix}${search}`; -}; diff --git a/cypress/e2e/pages/topicPage/index.cy.js b/ws-nextjs-app/cypress/e2e/topicPage/index.cy.ts similarity index 85% rename from cypress/e2e/pages/topicPage/index.cy.js rename to ws-nextjs-app/cypress/e2e/topicPage/index.cy.ts index 8287536cd44..040dc15b31d 100644 --- a/cypress/e2e/pages/topicPage/index.cy.js +++ b/ws-nextjs-app/cypress/e2e/topicPage/index.cy.ts @@ -1,21 +1,23 @@ -import runTestsForPage from '#nextjs/cypress/support/helpers/runTestsForPage'; +import { TOPIC_PAGE } from '#app/routes/utils/pageTypes'; import crossPlatformTests from './tests'; -import { TOPIC_PAGE } from '../../../../src/app/routes/utils/pageTypes'; -import urlValidationTest from '../../../support/helpers/urlValidationTest'; +import urlValidationTest from '../../support/helpers/urlValidationTest'; import testsForAllCanonicalPages from '../testsForAllCanonicalPages'; -import getPathWithSuffix from '../../../support/helpers/getPathWithSuffix'; -import { assertLiteSiteSummaryComponentToMainSiteClick } from '../../specialFeatures/atiAnalytics/assertions/liteSiteSummary'; -import { assertPageView } from '../../specialFeatures/atiAnalytics/assertions'; +import getPathWithSuffix from '../../support/helpers/getPathWithSuffix'; +import { assertLiteSiteSummaryComponentToMainSiteClick } from '../specialFeatures/atiAnalytics/assertions/liteSiteSummary'; +import { assertPageView } from '../specialFeatures/atiAnalytics/assertions'; import { assertDropdownNavigationComponentClick, assertDropdownNavigationComponentView, assertScrollableNavigationComponentClick, assertScrollableNavigationComponentView, -} from '../../specialFeatures/atiAnalytics/assertions/navigation'; +} from '../specialFeatures/atiAnalytics/assertions/navigation'; import { assertMessageBannerComponentClick, assertMessageBannerComponentView, -} from '../../specialFeatures/atiAnalytics/assertions/messageBanner'; +} from '../specialFeatures/atiAnalytics/assertions/messageBanner'; +import runTestsForPage, { + TestDataType, +} from '../../support/helpers/runTestsForPage'; const tests = [ crossPlatformTests, @@ -106,7 +108,7 @@ const atiAnalyticsTestSuites = [ assertMessageBannerComponentClick, ], }, -]; +] as unknown as TestDataType[]; const atiAnalyticsLiteTestSuites = atiAnalyticsTestSuites.map(testSuite => { const excludedLiteTests = [ diff --git a/cypress/e2e/pages/topicPage/tests.js b/ws-nextjs-app/cypress/e2e/topicPage/tests.ts similarity index 96% rename from cypress/e2e/pages/topicPage/tests.js rename to ws-nextjs-app/cypress/e2e/topicPage/tests.ts index 42658554591..e60fe3974d7 100644 --- a/cypress/e2e/pages/topicPage/tests.js +++ b/ws-nextjs-app/cypress/e2e/topicPage/tests.ts @@ -1,6 +1,6 @@ -import idSanitiser from '../../../../src/app/lib/utilities/idSanitiser'; -import getAppEnv from '../../../support/helpers/getAppEnv'; -import serviceConfigs from '../../../../src/server/utilities/serviceConfigs'; +import serviceConfigs from '#src/server/utilities/serviceConfigs'; +import idSanitiser from '#src/app/lib/utilities/idSanitiser'; +import getAppEnv from '../../support/helpers/getAppEnv'; export default ({ service, pageType, variant = 'default', path }) => { let topicId; @@ -16,7 +16,7 @@ export default ({ service, pageType, variant = 'default', path }) => { topicId = path.match(/(c[a-zA-Z0-9]{10,}t)/)?.[1]; // Gets the topic page data for all the tests - cy.getPageDataFromWindow().then(({ pageData }) => { + cy.getPageDataFromWindow().then(pageData => { topicTitle = pageData.title; pageCount = pageData.pageCount; numberOfItems = pageData.curations?.[0]?.summaries.length; @@ -65,8 +65,7 @@ export default ({ service, pageType, variant = 'default', path }) => { const promoCount = Cypress.$(selector).length; cy.log(`Number of promos on the page${promoCount}`); if (promoCount !== numberOfItems) { - cy.window().then(win => { - const pageData = win.SIMORGH_DATA; + cy.getPageDataFromWindow().then(pageData => { cy.log(pageData); }); } @@ -235,6 +234,7 @@ export default ({ service, pageType, variant = 'default', path }) => { } else { cy.log('No pagination as there is only one page'); } + cy.visit(path); }); it('Above 400px does not show Page x of y', () => {