From 7fa5af419de6ccab1c162b618805d21b247309e7 Mon Sep 17 00:00:00 2001 From: gokul-sol Date: Mon, 29 Apr 2024 16:51:40 +0100 Subject: [PATCH 1/4] configuring reports --- .gitignore | 1 + functional-test/config/playwright.config.ts | 8 ++++++- functional-test/lib/webActions.ts | 12 +++++++++-- functional-test/pages/addNotePage.ts | 12 +++++------ functional-test/pages/loginPage.ts | 23 +++++++++++++-------- package.json | 2 +- 6 files changed, 38 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index c449321b65..ce13dabe52 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ Change History.json e2e-tests/node_modules sscs-ccd-e2e-tests/ dist/ +playwright-report/ diff --git a/functional-test/config/playwright.config.ts b/functional-test/config/playwright.config.ts index 1c0dc51d43..6d0367d524 100644 --- a/functional-test/config/playwright.config.ts +++ b/functional-test/config/playwright.config.ts @@ -19,10 +19,16 @@ module.exports = defineConfig({ /* Opt out of parallel tests on CI. */ workers: process.env.FUNCTIONAL_TESTS_WORKERS ? 5 : undefined, - reporter: process.env.CI ? "html" : "list", + reporter: [[process.env.CI ? "html" : "list", { outputDir: '../playwright-report/', open: 'never' }]], use: { baseURL: urls.xuiUrl, trace: "on-first-retry", + launchOptions: { + logger: { + isEnabled: (name, severity) => true, + log: (name, message) => console.log(`${name} ${message}`) + } + } }, // globalSetup: '../src/tests/e2e/global.setup.ts', projects: [ diff --git a/functional-test/lib/webActions.ts b/functional-test/lib/webActions.ts index f5629989cc..952b72987d 100644 --- a/functional-test/lib/webActions.ts +++ b/functional-test/lib/webActions.ts @@ -9,10 +9,18 @@ export class WebActions { } async chooseOptionByLabel(elementId: string, labelText: string) { - this.page.locator(elementId).selectOption({label: labelText}); + await this.page.locator(elementId).selectOption({label: labelText}); } async clickNextStepButton(elementId: string): Promise { - this.page.click(elementId); + await this.page.click(elementId); + } + + async fillText(elementId: string, inputText: string): Promise { + await this.page.fill(elementId, inputText); + } + + async clickButton(elementName: string): Promise { + await this.page.getByRole('button', {name: elementName}).click(); } } \ No newline at end of file diff --git a/functional-test/pages/addNotePage.ts b/functional-test/pages/addNotePage.ts index 587be4e710..130f662787 100644 --- a/functional-test/pages/addNotePage.ts +++ b/functional-test/pages/addNotePage.ts @@ -6,26 +6,24 @@ let webActions: WebActions; export class AddNotePage { readonly page: Page; - readonly textDetailsField: Locator; + readonly textDetailsField: string; readonly submitButton: Locator; constructor(page: Page) { this.page = page; - this.textDetailsField = page.locator('#tempNoteDetail'); - this.submitButton = page.getByRole('button', {name: 'Submit'}); + this.textDetailsField = '#tempNoteDetail'; webActions = new WebActions(this.page); - } async submitNote(noteSummary: string): Promise { - await this.textDetailsField.fill(noteSummary); - await this.submitButton.click(); + await webActions.fillText(this.textDetailsField, noteSummary); + await webActions.clickButton('Submit'); } async confirmSubmission(): Promise { - await this.submitButton.click(); + await webActions.clickButton('Submit'); } } \ No newline at end of file diff --git a/functional-test/pages/loginPage.ts b/functional-test/pages/loginPage.ts index a105d047c4..9e413c0a0c 100644 --- a/functional-test/pages/loginPage.ts +++ b/functional-test/pages/loginPage.ts @@ -1,21 +1,26 @@ import { expect, Locator, Page } from '@playwright/test'; -import {credentials} from '../config/config'; +import { credentials } from '../config/config'; +import { WebActions } from '../lib/webActions' + +let webActions: WebActions; export class LoginPage { readonly page: Page; - readonly userName: Locator; - readonly passWord: Locator; + readonly userName: string; + readonly passWord: string; readonly loginBtn: Locator; readonly pageTitle: Locator; constructor(page: Page) { this.page = page; - this.userName = page.locator('#username'); - this.passWord = page.locator('#password'); - this.loginBtn = page.getByRole('button', {name: 'Sign in'}); + this.userName = '#username'; + this.passWord = '#password'; + // this.loginBtn = page.getByRole('button', {name: 'Sign in'}); this.pageTitle = page.locator('h1'); + webActions = new WebActions(this.page); + } async goToLoginPage(): Promise { @@ -27,9 +32,9 @@ export class LoginPage { } async verifySuccessfulLoginForCaseworker(expTitle: string): Promise { - await this.userName.fill(credentials.caseWorker.email); - await this.passWord.fill(credentials.caseWorker.password); - await this.loginBtn.click(); + await webActions.fillText(this.userName, credentials.caseWorker.email); + await webActions.fillText(this.passWord, credentials.caseWorker.password); + await webActions.clickButton('Sign in'); await expect(this.pageTitle).toHaveText(expTitle); } } diff --git a/package.json b/package.json index a150dc52d8..74cacdd8f8 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "test:preview": "echo preview test infra is wip", "test:aat": "cd sscs-ccd-e2e-tests && yarn install && yarn test:fullfunctional", "test:functional": "ENVIRONMENT=${ENVIRONMENT} ./bin/run-functional-tests.sh", - "test:functional-headless": "yarn playwright install && npx playwright test --config functional-test/config/playwright.config.ts --project chromium", + "test:functional-headless": "yarn playwright install && npx playwright test --config functional-test/config/playwright.config.ts --project chromium --reporter=html", "test:functional-head": "yarn playwright install && npx playwright test --config functional-test/config/playwright.config.ts --project chromium --headed", "start": "node index.js", "test:coverage": "echo test:coverage", From 9ec5bb498e0ee354aff70a8949b06017fa43d368 Mon Sep 17 00:00:00 2001 From: gokul-sol Date: Mon, 29 Apr 2024 17:08:16 +0100 Subject: [PATCH 2/4] fix conflicts --- functional-test/lib/webActions.ts | 3 ++- functional-test/pages/addNotePage.ts | 3 ++- functional-test/pages/loginPage.ts | 7 ++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/functional-test/lib/webActions.ts b/functional-test/lib/webActions.ts index ae551f5e4e..be3b24bb4f 100644 --- a/functional-test/lib/webActions.ts +++ b/functional-test/lib/webActions.ts @@ -21,7 +21,8 @@ export class WebActions { } async clickButton(elementLocator: string): Promise { - await this.page.click(elementLocator); + // await this.page.click(elementLocator); + await this.page.getByRole('button', { name: elementLocator}).click(); } async clickNextStepButton(elementId: string): Promise { diff --git a/functional-test/pages/addNotePage.ts b/functional-test/pages/addNotePage.ts index 051dca49a3..35d32f9e66 100644 --- a/functional-test/pages/addNotePage.ts +++ b/functional-test/pages/addNotePage.ts @@ -30,7 +30,8 @@ x } async confirmSubmission(): Promise { - await webActions.clickButton('[type=\'submit\']'); + // await webActions.clickButton('[type=\'submit\']'); + await webActions.clickButton('Submit'); } } diff --git a/functional-test/pages/loginPage.ts b/functional-test/pages/loginPage.ts index 9e413c0a0c..9f8fd880f4 100644 --- a/functional-test/pages/loginPage.ts +++ b/functional-test/pages/loginPage.ts @@ -14,9 +14,6 @@ export class LoginPage { constructor(page: Page) { this.page = page; - this.userName = '#username'; - this.passWord = '#password'; - // this.loginBtn = page.getByRole('button', {name: 'Sign in'}); this.pageTitle = page.locator('h1'); webActions = new WebActions(this.page); @@ -32,8 +29,8 @@ export class LoginPage { } async verifySuccessfulLoginForCaseworker(expTitle: string): Promise { - await webActions.fillText(this.userName, credentials.caseWorker.email); - await webActions.fillText(this.passWord, credentials.caseWorker.password); + await webActions.inputField('#username', credentials.caseWorker.email); + await webActions.inputField('#password', credentials.caseWorker.password); await webActions.clickButton('Sign in'); await expect(this.pageTitle).toHaveText(expTitle); } From 8c353da93ce3168e9a948541483fac7673c20c71 Mon Sep 17 00:00:00 2001 From: gokul-sol Date: Mon, 29 Apr 2024 17:10:48 +0100 Subject: [PATCH 3/4] updates to test --- functional-test/lib/webActions.ts | 1 - functional-test/pages/addNotePage.ts | 1 - package.json | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/functional-test/lib/webActions.ts b/functional-test/lib/webActions.ts index be3b24bb4f..18e02c577c 100644 --- a/functional-test/lib/webActions.ts +++ b/functional-test/lib/webActions.ts @@ -21,7 +21,6 @@ export class WebActions { } async clickButton(elementLocator: string): Promise { - // await this.page.click(elementLocator); await this.page.getByRole('button', { name: elementLocator}).click(); } diff --git a/functional-test/pages/addNotePage.ts b/functional-test/pages/addNotePage.ts index 35d32f9e66..ac55d3c14b 100644 --- a/functional-test/pages/addNotePage.ts +++ b/functional-test/pages/addNotePage.ts @@ -30,7 +30,6 @@ x } async confirmSubmission(): Promise { - // await webActions.clickButton('[type=\'submit\']'); await webActions.clickButton('Submit'); } diff --git a/package.json b/package.json index 74cacdd8f8..b5bb3646e3 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test:aat": "cd sscs-ccd-e2e-tests && yarn install && yarn test:fullfunctional", "test:functional": "ENVIRONMENT=${ENVIRONMENT} ./bin/run-functional-tests.sh", "test:functional-headless": "yarn playwright install && npx playwright test --config functional-test/config/playwright.config.ts --project chromium --reporter=html", - "test:functional-head": "yarn playwright install && npx playwright test --config functional-test/config/playwright.config.ts --project chromium --headed", + "test:functional-head": "yarn playwright install && npx playwright test --config functional-test/config/playwright.config.ts --project chromium --headed --reporter=html", "start": "node index.js", "test:coverage": "echo test:coverage", "test:a11y": "echo test:a11y", From cc1075239c6d060d1df21e8dd535d79978909555 Mon Sep 17 00:00:00 2001 From: gokul-sol Date: Mon, 29 Apr 2024 17:11:50 +0100 Subject: [PATCH 4/4] remove wip logger feature --- functional-test/config/playwright.config.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/functional-test/config/playwright.config.ts b/functional-test/config/playwright.config.ts index 6d0367d524..4c49ceb63c 100644 --- a/functional-test/config/playwright.config.ts +++ b/functional-test/config/playwright.config.ts @@ -23,12 +23,6 @@ module.exports = defineConfig({ use: { baseURL: urls.xuiUrl, trace: "on-first-retry", - launchOptions: { - logger: { - isEnabled: (name, severity) => true, - log: (name, message) => console.log(`${name} ${message}`) - } - } }, // globalSetup: '../src/tests/e2e/global.setup.ts', projects: [