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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ cypress/fixtures/toggles
ws-nextjs-app/cypress/fixtures/toggles
ws-nextjs-app/cypress/downloads
ws-nextjs-app/cypress/results
ws-nextjs-app/test-results
ws-nextjs-app/test/e2e/__assets__
pack
storybook_dist
simorgh.report.html
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
],
"workspaces": {
"packages": [
"ws-nextjs-app/test/e2e",
"ws-nextjs-app",
"src/app/routes/article/getInitialData",
"src/app/routes/utils/fetchDataFromBFF",
Expand Down
22 changes: 22 additions & 0 deletions ws-nextjs-app/test/e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "e2e-tests",
"version": "1.0.0",
"description": "automation / e2e tests",
"private": true,
"packageManager": "yarn@4.12.0",
"main": "index.js",
"scripts": {
"test:e2e:chrome:playwright": "npx playwright test --project='WorldService - Chrome'",
},
"author": "",
"license": "ISC",
"devDependencies": {
"@bbc/unified-web-e2e-framework": "github:bbc/unified-web-e2e-framework#v3.0.0",
"@playwright/test": "1.57.0",
"@types/config": "3.3.5",
"@types/supertest": "6.0.3",
"supertest": "7.1.1",
"tsx": "4.19.4",
"typescript": "5.8.3"
}
}
7 changes: 7 additions & 0 deletions ws-nextjs-app/test/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { config } from '@bbc/unified-web-e2e-framework';

config.testDir = 'specs';

config.use.baseURL = 'https://www.bbc.com';

export default config;
87 changes: 87 additions & 0 deletions ws-nextjs-app/test/e2e/specs/homePage.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import SERVICES from '#app/lib/config/services';
import { test } from '@bbc/unified-web-e2e-framework';
import { expect } from '@playwright/test';

const SERVICES_PATTERN = SERVICES.join('|');

const VALID_HREF_REGEX = new RegExp(
`^https://www\\.bbc\\.com/(?:${SERVICES_PATTERN}|usingthebbc/[^/]+(?:/.*)?|programmes/[a-z0-9]{8,15})(?:/.*)?$`,
);

const testSuites = [
{
path: '/arabic',
service: 'arabic',
},
{
path: '/dari',
service: 'dari',
},
{
path: '/kyrgyz',
service: 'kyrgyz',
},
{
path: '/magyarul',
service: 'magyarul',
expectedPath: '/magyarul/articles/cwywderkzy2o',
},
{
path: '/polska',
service: 'polska',
},
{
path: '/portuguese',
service: 'portuguese',
},
{
path: '/romania',
service: 'romania',
expectedPath: '/romania/articles/c993yged1xno',
},
{
path: '/serbian/lat',
service: 'serbian',
variant: 'lat',
},
{
path: '/serbian/cyr',
service: 'serbian',
variant: 'cyr',
},
{
path: '/uzbek/lat',
service: 'uzbek',
variant: 'lat',
},
{
path: '/uzbek/cyr',
service: 'uzbek',
variant: 'cyr',
},
];

testSuites.forEach(suite => {
test.describe(`Home Page - ${suite.service}${suite.variant ?? ''}`, () => {
test('all links within <main> element should be a valid World Service URL', async ({
page,
}) => {
const expectedPath = suite.expectedPath || suite.path;

await page.goto(suite.path);
await expect(page).toHaveURL(expectedPath);

const pageLinks = await page
.locator('main a[href^="https://www.bbc.com"]')
.all();

// eslint-disable-next-line no-restricted-syntax
for (const link of pageLinks) {
// eslint-disable-next-line no-await-in-loop
const href = await link.getAttribute('href');
expect(href).not.toBeNull();
expect(href).toMatch(VALID_HREF_REGEX);
}
});
});
});
11 changes: 11 additions & 0 deletions ws-nextjs-app/test/e2e/specs/setupCheck.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test } from '@bbc/unified-web-e2e-framework';
import { expect } from '@playwright/test';

test('Verify page title', async ({ page }) => {
await page.goto('https://www.bbc.com');
expect(await page.title()).toEqual(
expect.stringMatching(
/(BBC - Home|BBC Home - Breaking News, World News, US News, Sports, Business, Innovation, Climate, Culture, Travel, Video & Audio)/,
),
);
});
Loading