From bbd08dffb611aa8b7a081d78723348a74dce2ced Mon Sep 17 00:00:00 2001 From: mildred Date: Wed, 13 Mar 2024 12:59:57 +0100 Subject: [PATCH] update readme examples --- README.md | 18 ++++++++++-------- tests/00-COMM-loginFunctionality.spec.ts | 7 +++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 550f796..d66d05a 100644 --- a/README.md +++ b/README.md @@ -81,16 +81,17 @@ An example of a simple test might look like this: ```typescript test('Successful login as user', async ({ page }) => { await loginAsUser(page, USER1_EMAIL, URL_IDHUB); - await expect.soft(page).toHaveTitle('Dashboard – IdHub'); + await expect(page).toHaveTitle('Dashboard – IdHub'); }) ``` The 'loginAs' function, is defined in `steps.ts` as follow: ```typescript export async function loginAsUser(page: Page, userEmail: string, url: string) { - try { const loginPage = new LogInPage(page); + const dataProtectionPage = new DataProtectionPage(page); + await loginPage.visit(url); await loginPage.login(userEmail, USER_K); @@ -98,10 +99,10 @@ export async function loginAsUser(page: Page, userEmail: string, url: string) { if (currentTitle === 'Data Protection – IdHub') { // Code to accept terms and conditions - await page.click('#id_accept_privacy'); - await page.click('#id_accept_legal'); - await page.click('#id_accept_cookies'); - await page.click('a[type="button"]'); + await dataProtectionPage.checkAcceptPrivacyCheckBox(); + await dataProtectionPage.checkAcceptCookiesCheckBox(); + await dataProtectionPage.checkAcceptLegalCheckBox(); + await dataProtectionPage.clickConfirmButton(); } await expect(page).toHaveTitle('Dashboard – IdHub'); } catch (error) { @@ -110,7 +111,7 @@ export async function loginAsUser(page: Page, userEmail: string, url: string) { } } ``` -The 'loginAs' function in `steps.ts` use the 'LoginPage' page object, where are defined all the user related actions (e.g., visit, login, etc.). +The 'loginAs' function in `steps.ts` use the 'LoginPage' page object, where are defined all the user related actions (e.g., visit, login, etc.) and the 'DataProtectionPage' page object where the interactions to accept or deny the data protection options are defined. ## Project Directory Structure @@ -163,6 +164,7 @@ end2end-tests: ``` **Adding reporting**: Uploads the `playwright-report/` directory as an artifact named `playwright-report`. This step always runs, even if previous steps fail, and the artifact is retained for 30 days before automatic deletion. +```yaml - uses: actions/upload-artifact@v3 if: always() with: @@ -170,6 +172,6 @@ end2end-tests: path: playwright-report/ retention-days: 30 - +``` diff --git a/tests/00-COMM-loginFunctionality.spec.ts b/tests/00-COMM-loginFunctionality.spec.ts index 8d5d101..c8d2676 100644 --- a/tests/00-COMM-loginFunctionality.spec.ts +++ b/tests/00-COMM-loginFunctionality.spec.ts @@ -16,7 +16,7 @@ test.describe('Admin login functionality', () => { test('Navigate to Forgot password page from login page', async ({ page }) => { const loginPage = new LogInPage(page) await loginPage.visitForgotPassword(URL_PASS_RESET) - await expect.soft(page).toHaveTitle('Password reset – IdHub'); + await expect(page).toHaveTitle('Password reset – IdHub'); }) }) @@ -24,14 +24,13 @@ test.describe('Admin login functionality', () => { test.describe('User login functionality', () => { test('Successful login as user', async ({ page }) => { await loginAsUser(page, USER1_EMAIL, URL_IDHUB); - await expect.soft(page).toHaveTitle('Dashboard – IdHub'); - //TODO: check email at the right corner + await expect(page).toHaveTitle('Dashboard – IdHub'); }) test('Unsuccessful login as user', async ({ page }) => { const loginPage = new LogInPage(page) await loginPage.visit(URL_IDHUB); await loginPage.login(USER1_EMAIL, KO_USER_K) - await expect.soft(loginPage.errorMessageIsValid()).toBeTruthy(); + await expect(loginPage.errorMessageIsValid()).toBeTruthy(); }) }) \ No newline at end of file