Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 3 additions & 27 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,7 @@ const ampIntegrationTests = {
moduleNameMapper: jestDirAlias,
setupFilesAfterEnv: ['./src/testHelpers/setupTests.js'],
testMatch: ['**/src/integration/!(utils)/**/*.test.js'],
testPathIgnorePatterns: [
'.*lite\\.test\\.js$',
'.*canonical\\.test\\.js$',
'<rootDir>/src/integration/pages/articles/',
'<rootDir>/src/integration/pages/mediaArticlePage/',
'<rootDir>/src/integration/pages/mediaAssetPage/',
'<rootDir>/src/integration/pages/photoGalleryPage/',
'<rootDir>/src/integration/pages/storyPage/',
],
testPathIgnorePatterns: ['.*lite\\.test\\.js$', '.*canonical\\.test\\.js$'],
};

const canonicalIntegrationTests = {
Expand All @@ -82,15 +74,7 @@ const canonicalIntegrationTests = {
moduleNameMapper: jestDirAlias,
setupFilesAfterEnv: ['./src/testHelpers/setupTests.js'],
testMatch: ['**/src/integration/!(utils)/**/*.test.js'],
testPathIgnorePatterns: [
'.*lite\\.test\\.js$',
'.*amp\\.test\\.js$',
'<rootDir>/src/integration/pages/articles/',
'<rootDir>/src/integration/pages/mediaArticlePage/',
'<rootDir>/src/integration/pages/mediaAssetPage/',
'<rootDir>/src/integration/pages/photoGalleryPage/',
'<rootDir>/src/integration/pages/storyPage/',
],
testPathIgnorePatterns: ['.*lite\\.test\\.js$', '.*amp\\.test\\.js$'],
};

const liteIntegrationTests = {
Expand All @@ -103,15 +87,7 @@ const liteIntegrationTests = {
moduleNameMapper: jestDirAlias,
setupFilesAfterEnv: ['./src/testHelpers/setupTests.js'],
testMatch: ['**/src/integration/!(utils)/**/*.test.js'],
testPathIgnorePatterns: [
'.*canonical\\.test\\.js$',
'.*amp\\.test\\.js$',
'<rootDir>/src/integration/pages/articles/',
'<rootDir>/src/integration/pages/mediaArticlePage/',
'<rootDir>/src/integration/pages/mediaAssetPage/',
'<rootDir>/src/integration/pages/photoGalleryPage/',
'<rootDir>/src/integration/pages/storyPage/',
],
testPathIgnorePatterns: ['.*canonical\\.test\\.js$', '.*amp\\.test\\.js$'],
};

const puppeteerTests = {
Expand Down
3 changes: 2 additions & 1 deletion ws-nextjs-app/cypress/e2e/errorPage404/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ export default ({
);
});
});
// SKIPPED: The following tests have been skipped as the Error Page hasn't yet been migrated.
if ((envConfig as EnvironmentConfigType).standaloneErrorPages) {
// These tests are skipped because the Next.js application doesn't currently have dedicated routes for /{service}/404 and /{service}/500 that return HTTP 200.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these tests? If so I'll raise a tech ticket to support /404 and /500 routes on NextJS. Else I'll bin them.

// These would need to be explicitly configured in the Next.js routing/middleware to work as standalone error pages.
describe.skip(`${service} error page routes`, () => {
it(`/${service}/404 should have response code 200`, () => {
cy.testResponseCodeAndType({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Variants } from '#app/models/types/global';
import serviceConfigs from '#src/server/utilities/serviceConfigs';
import { ServiceParametersType } from '../../../../types';

import {
clickScriptSwitcher,
// clickHomePageLink,
// clickPromoLinkOnHomePage,
clickHomePageLink,
clickPromoLinkOnHomePage,
} from '../helpers';

const assertScriptSwitchButton = ({
Expand Down Expand Up @@ -57,7 +56,7 @@ const allVariantAssertions = ({ service, variant }: ServiceParametersType) => {

export default ({
service,
// pageType,
pageType,
variant,
otherVariant,
}: ServiceParametersType) => {
Expand All @@ -69,38 +68,36 @@ export default ({
allVariantAssertions({ service, variant });

// Clicks script switcher
clickScriptSwitcher(otherVariant as Variants);
clickScriptSwitcher({ service, variant: otherVariant });

cy.log(
`Asserting script switch button, url and document lang for other variant: ${otherVariant}`,
);
allVariantAssertions({ service, variant: otherVariant });

// SKIPPED: The following tests have been skipped as the Home Page hasn't yet been migrated.
// SKIPPED: When we migrate home pages we should consider refactoring these tests to reduce visits we make to home pages
// // Navigate to home page by clicking link in the banner
// clickHomePageLink(service, otherVariant);
// Navigate to home page by clicking link in the banner
clickHomePageLink({ service, variant: otherVariant });

// cy.log(
// `Asserting script switch button, url and document lang has persisted for other variant: ${otherVariant}`,
// );
// allVariantAssertions(service, otherVariant);
cy.log(
`Asserting script switch button, url and document lang has persisted for other variant: ${otherVariant}`,
);
allVariantAssertions({ service, variant: otherVariant });

// // Finding a link to click on the home page
// clickPromoLinkOnHomePage(pageType);
// Finding a link to click on the home page
clickPromoLinkOnHomePage({ service, variant, pageType });

// cy.log(
// `Asserting script switch button, url and document lang has persisted for other variant: ${otherVariant}`,
// );
// allVariantAssertions(service, otherVariant);
cy.log(
`Asserting script switch button, url and document lang has persisted for other variant: ${otherVariant}`,
);
allVariantAssertions({ service, variant: otherVariant });

// // Clicks script switcher to original variant
// clickScriptSwitcher(variant as Variants);
// Clicks script switcher to original variant
clickScriptSwitcher({ service, variant });

// cy.log(
// `Asserting script switch button, url and document lang have changed after clicking script switcher to ${variant}`,
// );
// allVariantAssertions({ service, variant });
cy.log(
`Asserting script switch button, url and document lang have changed after clicking script switcher to ${variant}`,
);
allVariantAssertions({ service, variant });
});
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,24 @@ const clickFirstMapLink = () => {
});
};

export const clickScriptSwitcher = (variant: string) => {
export const clickScriptSwitcher = ({ variant }: ServiceParametersType) => {
cy.get(`a[data-variant="${variant}"]`).click();
};

export const clickHomePageLink = (
service: ServiceParametersType,
variant: ServiceParametersType,
) => {
export const clickHomePageLink = ({
service,
variant,
}: ServiceParametersType) => {
cy.get('header[role="banner"]').within(() => {
cy.get(
`a[aria-labelledby="BrandLink-topPage"][href="/${service}/${variant}"]`,
).click();
});
};

export const clickPromoLinkOnHomePage = (pageType: string) => {
export const clickPromoLinkOnHomePage = ({
pageType,
}: ServiceParametersType) => {
// If it is a MAP test, find first MAP on the homepage and click it
if (pageType === MEDIA_ASSET_PAGE) {
clickFirstMapLink();
Expand Down
Loading