Skip to content
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

WORK IN PROGRESS Create test coverage for e2e User journey #1579

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
55 changes: 55 additions & 0 deletions playwright-e2e/tests/page-formating-tests.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Page, expect, test } from '@playwright/test';

import { urlConfig } from '../utils/urls';

test.describe('Start application details e2e journey in English', () => {
let page: Page;
test.beforeEach(async ({ browser }) => {
const context = await browser.newContext({
locale: 'en',
});
page = await context.newPage();
await page.goto(urlConfig.citizenStartUrl);
});
test('Start up jourey url is equal to the initial url', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: journey

Copy link
Contributor

Choose a reason for hiding this comment

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

this test might be not needed as it could be incorporated into the other tests and reduce number of tests being run

await expect(page).toHaveURL(urlConfig.citizenStartUrl);
});

test('Start up journey page is default to English', async () => {
const htmlLang = await page.evaluate(() => document.documentElement.lang);

expect(htmlLang).toBe('en');
});
test('Start up journey page is to have Cymraeg language link to be visible', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

these two tests could maybe be merged into one test as they look like they are doing quite similar things?

const linkLocator = page.locator('text=cymraeg');
await expect(linkLocator).toBeVisible();
});
test('Start up journey page clicking Cymraeg langauge changes html language to cy', async () => {
const linkLocator = page.locator('text=cymraeg');
await linkLocator.click();
await page.waitForLoadState('load');

const htmlLang = await page.evaluate(() => document.documentElement.lang);

expect(htmlLang).toBe('cy');
Copy link
Contributor

Choose a reason for hiding this comment

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

might be worth checking if you continue on the user journey, the language remains welsh and does not change back to english

});

test('Start up journey page clicking Cymraeg language clicking english language changes lanuage to en', async () => {
await changePageLanguage(page, 'cymraeg', 'load');
await changePageLanguage(page, 'english', 'load');

const htmlLang = await page.evaluate(() => document.documentElement.lang);

expect(htmlLang).toBe('en');
});
});

async function changePageLanguage(
page: Page,
textLanguage: string,
state?: 'load' | 'domcontentloaded' | 'networkidle'
): Promise<void> {
const languageLinkLocator = page.locator('text='.concat(textLanguage));
await languageLinkLocator.click();
await page.waitForLoadState(state);
}