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

DFPL-2289 - Upgrade Playwright and Introduce Linting for Tests #5286

Merged
merged 48 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
1b9eb18
CVE-2024-1597
GauravChawlaMOJ Mar 27, 2024
7a0f9c6
Merge remote-tracking branch 'origin/master'
GauravChawlaMOJ Apr 2, 2024
05d0a88
Merge remote-tracking branch 'origin/master'
GauravChawlaMOJ Apr 3, 2024
baea01a
Merge remote-tracking branch 'origin/master'
GauravChawlaMOJ Apr 3, 2024
82b646f
Merge remote-tracking branch 'origin/master'
GauravChawlaMOJ Apr 5, 2024
7b0902e
Merge remote-tracking branch 'origin/master'
GauravChawlaMOJ Apr 9, 2024
c097468
Merge remote-tracking branch 'origin/master'
GauravChawlaMOJ Apr 11, 2024
3ef4029
DFPL-2289 update Playwright
Apr 15, 2024
a9a78aa
DFPL-2289 add typescript-eslint + fix lint issues
Apr 15, 2024
36988f8
DFPL-2289 WIP fixing linting issues
Apr 15, 2024
cecdabf
Merge remote-tracking branch 'origin/master'
GauravChawlaMOJ Apr 15, 2024
8d17c1c
commit
GauravChawlaMOJ Apr 15, 2024
823b391
commit
GauravChawlaMOJ Apr 15, 2024
540d617
commit
GauravChawlaMOJ Apr 17, 2024
5c9d075
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ Apr 17, 2024
491315e
commit
GauravChawlaMOJ Apr 17, 2024
bf3037e
Merge remote-tracking branch 'origin/DFPL-2289-temp' into DFPL-2289-temp
GauravChawlaMOJ Apr 17, 2024
bd7c7a1
commit
GauravChawlaMOJ Apr 17, 2024
44d4502
commit
GauravChawlaMOJ Apr 17, 2024
9ef9844
commit
GauravChawlaMOJ Apr 17, 2024
b038fa0
Merge remote-tracking branch 'origin/master'
GauravChawlaMOJ Apr 17, 2024
db69cc9
Merge branch 'master' into DFPL-2289-temp
Iphiclus Apr 18, 2024
9529d77
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ Apr 18, 2024
143f92c
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ Apr 19, 2024
02f8016
packages updated
GauravChawlaMOJ Apr 23, 2024
527ffed
package added
GauravChawlaMOJ Apr 24, 2024
3f18f4c
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ Apr 24, 2024
9b76e4c
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ Apr 25, 2024
78371ce
yarn.lock update
GauravChawlaMOJ Apr 26, 2024
c7be22e
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ Apr 29, 2024
e5f8366
Merge branch 'master' into DFPL-2289-temp
abigailsmith97 May 1, 2024
b0992a1
Merge branch 'master' into DFPL-2289-temp
Iphiclus May 2, 2024
45a9379
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ May 3, 2024
01ee5c4
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ May 3, 2024
e68a70d
Merge remote-tracking branch 'origin/master'
GauravChawlaMOJ May 3, 2024
3925f57
re-create yarn.lock
GauravChawlaMOJ May 3, 2024
a2b5cbe
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ May 3, 2024
45d9a5d
re-create yarn.lock
GauravChawlaMOJ May 3, 2024
1995615
re-create yarn.lock
GauravChawlaMOJ May 3, 2024
da09d23
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ May 3, 2024
090c77d
update yarn to 3.8.2
GauravChawlaMOJ May 3, 2024
7057bdc
Merge remote-tracking branch 'origin/DFPL-2289-temp' into DFPL-2289-temp
GauravChawlaMOJ May 3, 2024
6fae647
updated tests
GauravChawlaMOJ May 3, 2024
c23417a
updated tests
GauravChawlaMOJ May 3, 2024
284d95d
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ May 3, 2024
4aca628
updated tests
GauravChawlaMOJ May 3, 2024
224b85b
updated tests
GauravChawlaMOJ May 3, 2024
ba1b3d1
Merge branch 'master' into DFPL-2289-temp
GauravChawlaMOJ May 6, 2024
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
874 changes: 0 additions & 874 deletions .yarn/releases/yarn-3.6.4.cjs

This file was deleted.

875 changes: 875 additions & 0 deletions .yarn/releases/yarn-3.8.2.cjs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.6.4.cjs

yarnPath: .yarn/releases/yarn-3.8.2.cjs
18 changes: 18 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
ignores: [
"e2e/*",
"codecept.conf.js",
".eslintrc.js",
"typings/*",
"saucelabs.conf.js",
],
},
);
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{
"name": "fpl-ccd-configuration",
"version": "1.0.0",
"type": "module",
"description": "FPL CCD e2e tests",
"engines": {
"node": ">=18.0.0"
},
"devDependencies": {
"@babel/core": "^7.11.0",
"@babel/eslint-parser": "^7.17.0",
"@playwright/test": "^1.40.1",
"@eslint/js": "^9.0.0",
"@playwright/test": "^1.43.1",
"@types/node": "^20.10.7",
"@types/qs": "^6.9.11",
"axios": "^1.6.7",
"codeceptjs": "3.5.10",
"dateformat": "^4.6.3",
"debug": "4.3.4",
"eslint": "7.32.0",
"eslint": "^8.0.0",
"eslint-plugin-codeceptjs": "^1.3.0",
"glob": "^7.2.3",
"html_codesniffer": "^2.5.1",
Expand All @@ -29,11 +31,13 @@
"moment": "2.30.1",
"node-fetch": "^2.6.9",
"node-gyp": "^9.4.0",
"playwright-core": "^1.43.1",
"qs": "^6.11.2",
"typescript": "^5.4.5",
"webdriverio": "8.36.1"
},
"scripts": {
"lint": "eslint e2e",
"lint": "yarn eslint .",
"typings": "codeceptjs def && mv steps.d.ts typings/codeceptjs.d.ts",
"test": "codeceptjs run-multiple parallel",
"test:functional": "NODE_TLS_REJECT_UNAUTHORIZED=0 MOCHAWESOME_REPORTFILENAME=functional codeceptjs run-multiple parallel --grep '(?=.*)^(?!.*(@smoke-tests|@flaky|@nightlyOnly))' --reporter mocha-multi --verbose",
Expand All @@ -56,7 +60,7 @@
"resolutions": {
"yargs-parser": "^20.2.9"
},
"packageManager": "yarn@3.6.4",
"packageManager": "yarn@3.8.2",
"license": "MIT",
"dependencies": {
"@axe-core/playwright": "^4.8.5",
Expand Down
2 changes: 1 addition & 1 deletion playwright-e2e/fixtures/axe-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type AxeFixture = {
};

export const test = base.extend<AxeFixture>({
makeAxeBuilder: async ({ page }, use, testInfo) => {
makeAxeBuilder: async ({ page }, use) => {
const makeAxeBuilder = () =>
new AxeBuilder({ page })
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22a", "wcag22aa"])
Expand Down
9 changes: 4 additions & 5 deletions playwright-e2e/pages/add-application-documents.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type Page, type Locator, expect } from "@playwright/test";
import config from "../settings/test-docs/config";
import path from "path";

export class AddApplicationDocuments {

Expand All @@ -10,7 +9,7 @@ export class AddApplicationDocuments {
readonly typeOfDocument: Locator;
readonly chooseFileButton: Locator;
readonly giveDetailsText: Locator;

public constructor(page: Page) {
this.page = page;
this.applicationDocumentsHeading = page.getByRole('heading', { name: 'Application documents' });
Expand All @@ -27,12 +26,12 @@ export class AddApplicationDocuments {
await this.typeOfDocument.selectOption('8: BIRTH_CERTIFICATE');
await this.page.locator('input#temporaryApplicationDocuments_0_document').first().setInputFiles(config.testPdfFile);
// Wait for the "Uploading..." process to finish otherwise step will fail
await this.page.locator('span.error-message:has-text("Uploading...")').isVisible();
await expect(this.page.locator('span.error-message:has-text("Uploading...")')).toBeHidden();
await this.page.locator('span.error-message:text("Uploading...")').isVisible();
await expect(this.page.locator('span.error-message:text("Uploading...")')).toBeHidden();
await this.giveDetailsText.isVisible();
await this.giveDetailsText.fill('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.');
await this.page.getByRole('button', { name: 'Continue' }).click();
await this.page.getByRole('heading', { name: 'Check your answers' }).click();
await this.page.getByRole('button', { name: 'Save and continue' }).click();
}
}
}
8 changes: 8 additions & 0 deletions playwright-e2e/pages/additional-applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ export class AdditionalApplications extends BasePage {
await this.clickContinue();
}


public async expectAllUploadsCompleted() {
const locs = await this.page.getByText('Cancel upload').all();
for (let i = 0; i < locs.length; i++) {
await expect(locs[i]).toBeDisabled();
}
}

public async fillC2ApplicationDetails() {
// upload application form
await this.c2ApplicationForm.setInputFiles(config.testTextFile);
Expand Down
2 changes: 1 addition & 1 deletion playwright-e2e/pages/allocation-proposal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Page, type Locator, expect } from "@playwright/test";
import { type Page, type Locator } from "@playwright/test";

export class AllocationProposal {

Expand Down
2 changes: 1 addition & 1 deletion playwright-e2e/pages/applicant-details.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Page, type Locator, expect } from "@playwright/test";
import { type Page, type Locator } from "@playwright/test";
import { BasePage } from "./base-page";

export class ApplicantDetails extends BasePage{
Expand Down
4 changes: 2 additions & 2 deletions playwright-e2e/pages/base-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BasePage {
}

async waitForAllUploadsToBeCompleted() {
let locs = await this.page.getByText('Cancel upload').all();
const locs = await this.page.getByText('Cancel upload').all();
for (let i = 0; i < locs.length; i++) {
await expect(locs[i]).toBeDisabled();
}
Expand All @@ -69,7 +69,7 @@ export class BasePage {
expect(await this.reloadAndCheckForText(userName, 10000, 3)).toBeTruthy();
}

async reloadAndCheckForText(text: string, timeout?: number, maxAttempts?: number): Promise<Boolean> {
async reloadAndCheckForText(text: string, timeout?: number, maxAttempts?: number): Promise<boolean> {
// reload the page, wait 5s, see if it's there
for (let attempt = 0; attempt < (maxAttempts ?? 12); attempt++) {
await this.page.reload();
Expand Down
7 changes: 4 additions & 3 deletions playwright-e2e/pages/create-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class CreateCase{
readonly createCaseLink: Locator;
readonly addApplicationTitle: Locator;
readonly viewHistory: Locator;
generatedCaseName: any;
generatedCaseName: string;

public constructor(page: Page) {
this.page = page;
Expand All @@ -19,6 +19,7 @@ export class CreateCase{
name: "Add application details",
});
this.viewHistory = page.getByText("History");
this.generatedCaseName = "";
}

async createCase() {
Expand All @@ -40,7 +41,7 @@ export class CreateCase{
}

caseName() {
let formattedDate = CreateCaseName.getFormattedDate();
const formattedDate = CreateCaseName.getFormattedDate();
this.generatedCaseName = `Smoke Test ${formattedDate}`;
}

Expand Down Expand Up @@ -70,7 +71,7 @@ export class CreateCase{
await this.page.getByLabel("Case name").fill(caseName);
await this.page.getByLabel("Apply filter").click();
await this.page.getByLabel("Day").click();
await expect(this.page.getByText(caseName)).toBeVisible;
expect(this.page.getByText(caseName).isVisible());
await this.page.getByText(caseName).click();
}
}
1 change: 0 additions & 1 deletion playwright-e2e/pages/gatekeeping-listing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {BasePage} from "./base-page";
import {expect, Page} from "@playwright/test";
import {ManageHearings} from "./manage-hearings";
import {HearingDetailsMixin} from "./mixins/hearing-details-mixin";

export class GatekeepingListing extends HearingDetailsMixin(BasePage)
Expand Down
2 changes: 1 addition & 1 deletion playwright-e2e/pages/international-element.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Page, type Locator, expect } from "@playwright/test";
import { type Page, type Locator } from "@playwright/test";
import { BasePage } from "./base-page";

export class InternationalElement extends BasePage {
Expand Down
2 changes: 1 addition & 1 deletion playwright-e2e/pages/manage-hearings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {type Page, type Locator, expect} from "@playwright/test";
import {type Page, type Locator } from "@playwright/test";
import {BasePage} from "./base-page";
import {HearingDetailsMixin} from "./mixins/hearing-details-mixin";

Expand Down
2 changes: 1 addition & 1 deletion playwright-e2e/pages/respondent-details.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Page, type Locator, expect } from "@playwright/test";
import { type Page, type Locator } from "@playwright/test";

export class RespondentDetails {

Expand Down
19 changes: 3 additions & 16 deletions playwright-e2e/pages/start-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,15 @@ export class StartApplication {
this.childDetailsUpdated = page.locator('p').filter({ hasText: 'Child\'s Details' }).getByRole('img', { name: 'Information added' });
this.welshLanguageRequirements = page.getByRole('link', { name: 'Welsh language requirements' });
this.welshLanguageReqFinished = page.locator('p:has(a[text="Welsh language requirements"]) > img[title="Finished"]');

this.internationalElementsHeading = page.getByRole('link', { name: 'International element' });
this.submitApplicationLink = page.getByRole('link', { name: 'Submit application' });
this.welshLanguageReqFinished = page.locator('p:has(a[text="Welsh language requirements"]) > img[title="Finished"]');
this.courtServicesNeeded = page.getByRole('link', { name: 'Court services needed' });

}

async addApplicationDetails() {
await expect(this.addApplicationDetailsHeading).toBeVisible();
}
this.courtServicesNeeded = page.getByRole('link', { name: 'Court services needed' });

async ordersAndDirectionsSought() {
await this.ordersAndDirectionsSoughtLink.isVisible();
await this.ordersAndDirectionsSoughtLink.click();
}

async hearingUrgency() {
await this.hearingUrgencyLink.isVisible();
await this.hearingUrgencyLink.click();
await expect(this.hearingUrgencyHeader).toBeVisible();
}

async groundsForTheApplication() {
await this.groundsForTheApplicationLink.isVisible();
Expand All @@ -82,8 +70,7 @@ export class StartApplication {
}

async groundsForTheApplicationHasBeenUpdated() {
await expect(this.groundsForTheApplicationHasBeenUpdatedFinished)
.toBeVisible;
await this.groundsForTheApplicationHasBeenUpdatedFinished.isVisible;
}

async riskAndHarmToChildren() {
Expand Down
6 changes: 3 additions & 3 deletions playwright-e2e/pages/welsh-lang-requirements.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Page, type Locator, expect } from "@playwright/test";
import { type Page, type Locator } from "@playwright/test";
import { BasePage } from "./base-page";

export class WelshLangRequirements extends BasePage {
Expand All @@ -10,7 +10,7 @@ export class WelshLangRequirements extends BasePage {
readonly englishLangRadio: Locator;
readonly needToBeTranslatedQuestion: Locator;
readonly needToBeInWelshYesRadio: Locator;

constructor(page: Page) {
super(page);
this.welshLangHeading = page.getByRole('heading', { name: 'Welsh language requirements' });
Expand All @@ -30,7 +30,7 @@ export class WelshLangRequirements extends BasePage {
await this.needToBeTranslatedQuestion.isVisible();
await this.needToBeInWelshYesRadio.click();
await this.clickContinue();
await this.checkYourAnswersHeader.isVisible;
await this.checkYourAnswersHeader.isVisible();
await this.checkYourAnsAndSubmit();
}
}
Expand Down
14 changes: 9 additions & 5 deletions playwright-e2e/settings/test-docs/config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import path from "path";
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';

export interface testFiles {}
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

interface testFiles {}

interface Config {
[key: string]: testFiles | string;
}

const config: Config = {
testPdfFile: path.resolve(
testPdfFile: join(
__dirname,
"../test-docs/testPdf.pdf",
),
testWordFile: path.resolve(
testWordFile: join(
__dirname,
"../test-docs/testWordDoc.docx",
),
testTextFile: path.resolve(
testTextFile: join(
__dirname,
"../test-docs/testTextFile.txt",
),
Expand Down
2 changes: 1 addition & 1 deletion playwright-e2e/settings/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface UrlConfig {

export const urlConfig: UrlConfig = {
idamUrl: process.env.AAT_IDAM_URL || `https://idam-api.${env}.platform.hmcts.net`,
serviceUrl: process.env.AAT_SERVICE_URL || `http://fpl-case-service-${env}.service.core-compute-${env}.internal`,
serviceUrl: process.env.AAT_SERVICE_URL || `http://fpl-case-service-${env}.service.core-compute-${env}.internal/`,
frontEndBaseURL: process.env.FE_BASE_URL || `https://manage-case.${env}.platform.hmcts.net/`,
// You can add other URLs as needed
};
27 changes: 15 additions & 12 deletions playwright-e2e/tests/additional-applications.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import { test } from '../fixtures/create-fixture';
import { Apihelp } from '../utils/api-helper';
import caseData from '../caseData/mandatorySubmissionFieldsWithoutAdditionalApp.json';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
import { newSwanseaLocalAuthorityUserOne, judgeWalesUser } from '../settings/user-credentials';
import { expect } from "@playwright/test";
import { testConfig } from '../settings/test-config';
import {createCase, updateCase} from "../utils/api-helper";

test.describe('Upload additional applications', () => {
let apiDataSetup = new Apihelp();
const dateTime = new Date().toISOString();
let caseNumber: string;
let casename: string;
let caseName: string;
const caseData = require('../caseData/mandatorySubmissionFieldsWithoutAdditionalApp.json');

test.beforeEach(async () => {
caseNumber = await apiDataSetup.createCase('e2e case', newSwanseaLocalAuthorityUserOne);


test.beforeEach(async () => {
caseNumber = await createCase('e2e case', newSwanseaLocalAuthorityUserOne);
});

test('LA uploads a C1 application',
async ({ page, signInPage, additionalApplications }) => {
casename = 'LA uploads an other application ' + dateTime.slice(0, 10);
await apiDataSetup.updateCase(casename, caseNumber, caseData);
caseName = 'LA uploads an other application ' + dateTime.slice(0, 10);
await updateCase(caseName, caseNumber, caseData);
await signInPage.visit();
await signInPage.login(newSwanseaLocalAuthorityUserOne.email, newSwanseaLocalAuthorityUserOne.password);
await signInPage.navigateTOCaseDetails(caseNumber);
Expand Down Expand Up @@ -64,8 +67,8 @@ test.describe('Upload additional applications', () => {

test('LA uploads a C2 application with draft order',
async ({ page, signInPage, additionalApplications }) => {
casename = 'LA uploads a C2 application with draft order ' + dateTime.slice(0, 10);
await apiDataSetup.updateCase(casename, caseNumber, caseData);
caseName = 'LA uploads a C2 application with draft order ' + dateTime.slice(0, 10);
await updateCase(caseName, caseNumber, caseData);
await signInPage.visit();
await signInPage.login(newSwanseaLocalAuthorityUserOne.email, newSwanseaLocalAuthorityUserOne.password);
await signInPage.navigateTOCaseDetails(caseNumber);
Expand Down Expand Up @@ -94,8 +97,8 @@ test.describe('Upload additional applications', () => {

test('LA uploads combined Other and C2 applications',
async ({ page, signInPage, additionalApplications }) => {
casename = 'LA uploads additional application with both Other and C2 ' + dateTime.slice(0, 10);
await apiDataSetup.updateCase(casename, caseNumber, caseData);
caseName = 'LA uploads additional application with both Other and C2 ' + dateTime.slice(0, 10);
await updateCase(caseName, caseNumber, caseData);
await signInPage.visit();
await signInPage.login(newSwanseaLocalAuthorityUserOne.email, newSwanseaLocalAuthorityUserOne.password);
await signInPage.navigateTOCaseDetails(caseNumber);
Expand Down
Loading
Loading