From 6ad21cc2e5e842364f5c0931470f2419384829f6 Mon Sep 17 00:00:00 2001 From: Sergio Florez Date: Mon, 18 Nov 2024 14:05:33 +0100 Subject: [PATCH 1/6] feat: playwright setup first step --- .github/workflows/playwright.yml | 30 +++++++ .gitignore | 5 ++ package-lock.json | 64 +++++++++++++++ package.json | 1 + playwright.config.ts | 80 +++++++++++++++++++ tests/config.ts | 8 ++ tests/login/login.spec.ts | 16 ++++ tests/registration/registration.spec.ts | 56 +++++++++++++ .../registrationAgencyLink.spec.ts | 5 ++ .../registrationConsultantLink.spec.ts | 5 ++ tests/utils.ts | 25 ++++++ 11 files changed, 295 insertions(+) create mode 100644 .github/workflows/playwright.yml create mode 100644 playwright.config.ts create mode 100644 tests/config.ts create mode 100644 tests/login/login.spec.ts create mode 100644 tests/registration/registration.spec.ts create mode 100644 tests/registration/registrationAgencyLink.spec.ts create mode 100644 tests/registration/registrationConsultantLink.spec.ts create mode 100644 tests/utils.ts diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 000000000..7ddab15c4 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,30 @@ +name: Playwright Tests +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + env: + USER_NAME: ${{ secrets.USERNAME }} + PASSWORD: ${{ secrets.PASSWORD }} + run: npx playwright test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index da1e5896e..60269a615 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,8 @@ npm-debug.log* yarn-debug.log* yarn-error.log* /.idea/ +node_modules/ +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/package-lock.json b/package-lock.json index 1b30bc015..48cb694c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -101,6 +101,7 @@ "@cypress/webpack-dev-server": "^3.5.1", "@cypress/webpack-preprocessor": "^6.0.1", "@dtsgenerator/replace-namespace": "^1.6.0", + "@playwright/test": "^1.48.2", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11", "@storybook/addon-essentials": "^7.0.18", "@storybook/addon-interactions": "^7.0.18", @@ -4971,6 +4972,22 @@ "node": ">=14" } }, + "node_modules/@playwright/test": { + "version": "1.48.2", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.48.2.tgz", + "integrity": "sha512-54w1xCWfXuax7dz4W2M9uw0gDyh+ti/0K/MxcCUxChFh37kkdxPdfZDw5QBbuPUJHr1CiHJ1hXgSs+GgeQc5Zw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.48.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@pmmmwh/react-refresh-webpack-plugin": { "version": "0.5.11", "dev": true, @@ -24196,6 +24213,53 @@ "node": ">=4" } }, + "node_modules/playwright": { + "version": "1.48.2", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.48.2.tgz", + "integrity": "sha512-NjYvYgp4BPmiwfe31j4gHLa3J7bD2WiBz8Lk2RoSsmX38SVIARZ18VYjxLjAcDsAhA+F4iSEXTSGgjua0rrlgQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.48.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.48.2", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.48.2.tgz", + "integrity": "sha512-sjjw+qrLFlriJo64du+EK0kJgZzoQPsabGF4lBvsid+3CNIZIYLgnMj9V6JY5VhM2Peh20DJWIVpVljLLnlawA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/pngjs": { "version": "5.0.0", "license": "MIT", diff --git a/package.json b/package.json index 9dae06380..52cbd2061 100644 --- a/package.json +++ b/package.json @@ -102,6 +102,7 @@ "@cypress/webpack-dev-server": "^3.5.1", "@cypress/webpack-preprocessor": "^6.0.1", "@dtsgenerator/replace-namespace": "^1.6.0", + "@playwright/test": "^1.48.2", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11", "@storybook/addon-essentials": "^7.0.18", "@storybook/addon-interactions": "^7.0.18", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 000000000..cedc520a7 --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,80 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +import dotenv from 'dotenv'; +import path from 'path'; +dotenv.config({ path: path.resolve(__dirname, '.env') }); + +/** + * See https://playwright.dev/docs/test-configuration. + */ + +export default defineConfig({ + testDir: './tests', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + // baseURL: 'http://127.0.0.1:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry' + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] } + }, + + { + name: 'firefox', + use: { ...devices['Desktop Firefox'] } + }, + + { + name: 'webkit', + use: { ...devices['Desktop Safari'] } + } + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { ...devices['Pixel 5'] }, + // }, + // { + // name: 'Mobile Safari', + // use: { ...devices['iPhone 12'] }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + // }, + // { + // name: 'Google Chrome', + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + // }, + ] + + /* Run your local dev server before starting the tests */ + // webServer: { + // command: 'npm run start', + // url: 'http://127.0.0.1:3000', + // reuseExistingServer: !process.env.CI, + // }, +}); diff --git a/tests/config.ts b/tests/config.ts new file mode 100644 index 000000000..fd3e2b3c5 --- /dev/null +++ b/tests/config.ts @@ -0,0 +1,8 @@ +export const caritasRework = { + dev: 'https://dev.caritas-rework.dev.virtual-identity.net/', + stage: 'https://beratung-rework-staging.caritas.de/', + prod: 'https://beratung.caritas.de/' +}; + +// write util functions here in config or in another file? +// util functions being general checks in all registration pages and so on diff --git a/tests/login/login.spec.ts b/tests/login/login.spec.ts new file mode 100644 index 000000000..6b4835798 --- /dev/null +++ b/tests/login/login.spec.ts @@ -0,0 +1,16 @@ +import { test } from '@playwright/test'; +import { caritasRework } from '../config'; +import { ensureLanguage } from '../utils'; + +test('Login as an advice seeker', async ({ page }) => { + const username = process.env.TEST_USERNAME; + const password = process.env.TEST_PASSWORD; + ensureLanguage(page); + await page.goto(`${caritasRework.dev}`); + await page.getByLabel(/(user\s?name|benutzername)/i).fill(username!); + await page + .getByLabel(/pass\s?(word|wort)/i) + .first() + .fill(password!); + await page.getByRole('button', { name: /(einloggen|login)/i }).click(); +}); diff --git a/tests/registration/registration.spec.ts b/tests/registration/registration.spec.ts new file mode 100644 index 000000000..a8fc9af3f --- /dev/null +++ b/tests/registration/registration.spec.ts @@ -0,0 +1,56 @@ +import { test, expect } from '@playwright/test'; +import { caritasRework } from '../config'; +import { ensureLanguage, generateRandomAlphanumeric } from '../utils'; + +test('Check registration page elements', async ({ page }) => { + ensureLanguage(page); + await page.goto(`${caritasRework.dev}registration`); + await expect(page.locator('h1.headline--1')).toHaveText( + /Beratung & Hilfe|Consulting & Help/ + ); + await expect(page.locator('h4.headline--4')).toHaveText( + /Online. Anonym. Sicher.|Online. Anonymous. Secure./ + ); +}); + +// registration test is skipped until a delete user account feature is implemented +test.skip('Complete registration process', async ({ page }) => { + const password = process.env.TEST_PASSWORD; + ensureLanguage(page); + await page.goto(`${caritasRework.dev}registration`); + await page.click('a[data-cy="button-register"]'); + + // registration steps + const kidsTopic = page.locator('h4', { + hasText: /Kinder, Jugendliche|Children, teenagers/ + }); + await expect(kidsTopic).toBeVisible(); + await kidsTopic.click(); + await page.getByLabel(/Adoptions- und|Adoption and foster child/).check(); + await page.click('button[data-cy="button-next"]'); + await page.fill('input[data-cy="input-postal-code"]', '99999'); + await page.click('button[data-cy="button-next"]'); + await page + .locator('input[name="agency-selection-radio-group"]') + .first() + .click(); + await page.click('button[data-cy="button-next"]'); + + // usermame & password + const randomUsername = `testuser_${generateRandomAlphanumeric(3)}`; + await page.getByLabel(/(user\s?name|benutzername)/i).fill(randomUsername); + await page + .getByLabel(/pass\s?(word|wort)/i, { exact: true }) + .first() + .fill(password!); + await page + .getByLabel(/(passwort\s?wiederholen|repeat\s?password)/i) + .fill(password!); + await page + .getByLabel(/Ich habe die Datenschutzerklä|I have the Privacy policy/) + .check(); + await page.click('button[data-cy="button-register"]'); + await page + .getByRole('button', { name: /Nachricht verfassen|Compose message/ }) + .click(); +}); diff --git a/tests/registration/registrationAgencyLink.spec.ts b/tests/registration/registrationAgencyLink.spec.ts new file mode 100644 index 000000000..8f3fc8385 --- /dev/null +++ b/tests/registration/registrationAgencyLink.spec.ts @@ -0,0 +1,5 @@ +import { test } from '@playwright/test'; + +test.skip('registration via agency link', async ({ page }) => { + // +}); diff --git a/tests/registration/registrationConsultantLink.spec.ts b/tests/registration/registrationConsultantLink.spec.ts new file mode 100644 index 000000000..0577d2c83 --- /dev/null +++ b/tests/registration/registrationConsultantLink.spec.ts @@ -0,0 +1,5 @@ +import { test } from '@playwright/test'; + +test.skip('registration via consultant link', async ({ page }) => { + // +}); diff --git a/tests/utils.ts b/tests/utils.ts new file mode 100644 index 000000000..75235b1fa --- /dev/null +++ b/tests/utils.ts @@ -0,0 +1,25 @@ +import { expect, Page } from '@playwright/test'; + +export function generateRandomAlphanumeric(length: number): string { + const chars = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + let result = ''; + for (let i = 0; i < length; i++) { + const randomIndex = Math.floor(Math.random() * chars.length); + result += chars[randomIndex]; + } + return result; +} + +export async function ensureLanguage(page: Page) { + let pageLang = (await page.getAttribute('html', 'lang')) || ''; + + if (!['en', 'de'].includes(pageLang)) { + await page.evaluate(() => { + document.documentElement.lang = 'en'; + }); + pageLang = 'en'; + } + + expect(['en', 'de']).toContain(pageLang); +} From 33febd6b861791d1d906a6e7fce4c9cd22cf46c4 Mon Sep 17 00:00:00 2001 From: Sergio Florez Date: Tue, 19 Nov 2024 16:57:59 +0100 Subject: [PATCH 2/6] feat: added GH secrets to GH action --- .github/workflows/playwright.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 7ddab15c4..97d7b82f1 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,9 +1,9 @@ name: Playwright Tests on: push: - branches: [ main, master ] + branches: [ develop, staging ] pull_request: - branches: [ main, master ] + branches: [ develop, staging ] jobs: test: timeout-minutes: 60 @@ -19,8 +19,8 @@ jobs: run: npx playwright install --with-deps - name: Run Playwright tests env: - USER_NAME: ${{ secrets.USERNAME }} - PASSWORD: ${{ secrets.PASSWORD }} + TEST_USERNAME: ${{ secrets.TEST_USERNAME }} + TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }} run: npx playwright test - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} From 5b6f052bb5164edffe1ff4607657d915729273f8 Mon Sep 17 00:00:00 2001 From: Sergio Florez Date: Tue, 19 Nov 2024 17:37:21 +0100 Subject: [PATCH 3/6] fix: changed assertion on login and gh action formatted --- .github/workflows/playwright.yml | 54 ++++++++++++------------- tests/login/login.spec.ts | 11 ++++- tests/registration/registration.spec.ts | 4 +- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 97d7b82f1..78eb327be 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,30 +1,30 @@ name: Playwright Tests on: - push: - branches: [ develop, staging ] - pull_request: - branches: [ develop, staging ] + push: + branches: [develop, staging] + pull_request: + branches: [develop, staging] jobs: - test: - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Install dependencies - run: npm ci - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - env: - TEST_USERNAME: ${{ secrets.TEST_USERNAME }} - TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }} - run: npx playwright test - - uses: actions/upload-artifact@v4 - if: ${{ !cancelled() }} - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + env: + TEST_USERNAME: ${{ secrets.TEST_USERNAME }} + TEST_PASSWORD: ${{ secrets.TEST_PASSWORD }} + run: npx playwright test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/tests/login/login.spec.ts b/tests/login/login.spec.ts index 6b4835798..d9c645ab1 100644 --- a/tests/login/login.spec.ts +++ b/tests/login/login.spec.ts @@ -5,12 +5,21 @@ import { ensureLanguage } from '../utils'; test('Login as an advice seeker', async ({ page }) => { const username = process.env.TEST_USERNAME; const password = process.env.TEST_PASSWORD; - ensureLanguage(page); await page.goto(`${caritasRework.dev}`); + ensureLanguage(page); await page.getByLabel(/(user\s?name|benutzername)/i).fill(username!); await page .getByLabel(/pass\s?(word|wort)/i) .first() .fill(password!); await page.getByRole('button', { name: /(einloggen|login)/i }).click(); + await page.locator('.sessionsList__illustration__image').click(); + await page + .getByRole('tab', { name: /(profile\s?profile|profil\s?profil)/i }) + .click(); + await page + .getByRole('tab', { + name: /(abmelden\s?abmelden|log\s?out\s?log\s?out)/i + }) + .click(); }); diff --git a/tests/registration/registration.spec.ts b/tests/registration/registration.spec.ts index a8fc9af3f..29f0991e7 100644 --- a/tests/registration/registration.spec.ts +++ b/tests/registration/registration.spec.ts @@ -3,8 +3,8 @@ import { caritasRework } from '../config'; import { ensureLanguage, generateRandomAlphanumeric } from '../utils'; test('Check registration page elements', async ({ page }) => { - ensureLanguage(page); await page.goto(`${caritasRework.dev}registration`); + ensureLanguage(page); await expect(page.locator('h1.headline--1')).toHaveText( /Beratung & Hilfe|Consulting & Help/ ); @@ -16,8 +16,8 @@ test('Check registration page elements', async ({ page }) => { // registration test is skipped until a delete user account feature is implemented test.skip('Complete registration process', async ({ page }) => { const password = process.env.TEST_PASSWORD; - ensureLanguage(page); await page.goto(`${caritasRework.dev}registration`); + ensureLanguage(page); await page.click('a[data-cy="button-register"]'); // registration steps From cb3900933ae7984ffb81d1b34f7f75e97b32cef7 Mon Sep 17 00:00:00 2001 From: Sergio Florez Date: Wed, 20 Nov 2024 13:21:43 +0100 Subject: [PATCH 4/6] chore: added a comment --- tests/registration/registration.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/registration/registration.spec.ts b/tests/registration/registration.spec.ts index 29f0991e7..d75c12a2f 100644 --- a/tests/registration/registration.spec.ts +++ b/tests/registration/registration.spec.ts @@ -2,6 +2,7 @@ import { test, expect } from '@playwright/test'; import { caritasRework } from '../config'; import { ensureLanguage, generateRandomAlphanumeric } from '../utils'; +// checks if the page is correct test('Check registration page elements', async ({ page }) => { await page.goto(`${caritasRework.dev}registration`); ensureLanguage(page); From 04c6e85525b491d989e87b8e23ae71d89cf7f13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deborah=20K=C3=B6pfer?= Date: Thu, 21 Nov 2024 16:42:03 +0100 Subject: [PATCH 5/6] Update tests/registration/registration.spec.ts --- tests/registration/registration.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/registration/registration.spec.ts b/tests/registration/registration.spec.ts index d75c12a2f..68c0a1843 100644 --- a/tests/registration/registration.spec.ts +++ b/tests/registration/registration.spec.ts @@ -37,7 +37,7 @@ test.skip('Complete registration process', async ({ page }) => { .click(); await page.click('button[data-cy="button-next"]'); - // usermame & password + // username & password const randomUsername = `testuser_${generateRandomAlphanumeric(3)}`; await page.getByLabel(/(user\s?name|benutzername)/i).fill(randomUsername); await page From 506e403278ccc63de26ee928b667663f317bdf49 Mon Sep 17 00:00:00 2001 From: Sergio Florez Date: Mon, 2 Dec 2024 15:52:11 +0100 Subject: [PATCH 6/6] feat: add ids to FE elements to assert w/o strings but ids --- .github/workflows/playwright.yml | 4 ++-- src/components/app/NavigationBar.tsx | 1 + src/components/login/Login.tsx | 3 ++- tests/login/login.spec.ts | 22 +++++++--------------- tests/registration/registration.spec.ts | 20 ++++++-------------- 5 files changed, 18 insertions(+), 32 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 78eb327be..fc0182bcd 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,9 +1,9 @@ name: Playwright Tests on: push: - branches: [develop, staging] + branches: [develop] pull_request: - branches: [develop, staging] + branches: [develop] jobs: test: timeout-minutes: 60 diff --git a/src/components/app/NavigationBar.tsx b/src/components/app/NavigationBar.tsx index 5d791c6dd..c337447d3 100644 --- a/src/components/app/NavigationBar.tsx +++ b/src/components/app/NavigationBar.tsx @@ -344,6 +344,7 @@ export const NavigationBar = ({ tabIndex={-1} ref={(el) => (ref_logout.current = el)} onKeyDown={(e) => handleKeyDownMenu(e, null)} + id="logout" > { const loginButton: ButtonItem = { label: translate('login.button.label'), - type: BUTTON_TYPES.PRIMARY + type: BUTTON_TYPES.PRIMARY, + id: 'login' }; const hasTenant = tenant != null; diff --git a/tests/login/login.spec.ts b/tests/login/login.spec.ts index d9c645ab1..4927b696f 100644 --- a/tests/login/login.spec.ts +++ b/tests/login/login.spec.ts @@ -1,4 +1,4 @@ -import { test } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import { caritasRework } from '../config'; import { ensureLanguage } from '../utils'; @@ -7,19 +7,11 @@ test('Login as an advice seeker', async ({ page }) => { const password = process.env.TEST_PASSWORD; await page.goto(`${caritasRework.dev}`); ensureLanguage(page); - await page.getByLabel(/(user\s?name|benutzername)/i).fill(username!); - await page - .getByLabel(/pass\s?(word|wort)/i) - .first() - .fill(password!); - await page.getByRole('button', { name: /(einloggen|login)/i }).click(); + await page.fill('input[id="username"]', username!); + await page.fill('input[id="passwordInput"]', password!); + await page.click('button[id="login"]'); await page.locator('.sessionsList__illustration__image').click(); - await page - .getByRole('tab', { name: /(profile\s?profile|profil\s?profil)/i }) - .click(); - await page - .getByRole('tab', { - name: /(abmelden\s?abmelden|log\s?out\s?log\s?out)/i - }) - .click(); + await expect(page.locator('a[href="/profile"]')).toBeVisible(); + await expect(page.locator('div[id="local-switch-wrapper"]')).toBeVisible(); + await page.click('div[id="logout"]'); }); diff --git a/tests/registration/registration.spec.ts b/tests/registration/registration.spec.ts index 68c0a1843..ea79b60e2 100644 --- a/tests/registration/registration.spec.ts +++ b/tests/registration/registration.spec.ts @@ -2,16 +2,12 @@ import { test, expect } from '@playwright/test'; import { caritasRework } from '../config'; import { ensureLanguage, generateRandomAlphanumeric } from '../utils'; -// checks if the page is correct +// checks if the page has the home titles test('Check registration page elements', async ({ page }) => { await page.goto(`${caritasRework.dev}registration`); ensureLanguage(page); - await expect(page.locator('h1.headline--1')).toHaveText( - /Beratung & Hilfe|Consulting & Help/ - ); - await expect(page.locator('h4.headline--4')).toHaveText( - /Online. Anonym. Sicher.|Online. Anonymous. Secure./ - ); + await expect(page.locator('h1.headline--1')).toBeVisible(); + await expect(page.locator('h4.headline--4')).toBeVisible(); }); // registration test is skipped until a delete user account feature is implemented @@ -21,13 +17,9 @@ test.skip('Complete registration process', async ({ page }) => { ensureLanguage(page); await page.click('a[data-cy="button-register"]'); - // registration steps - const kidsTopic = page.locator('h4', { - hasText: /Kinder, Jugendliche|Children, teenagers/ - }); - await expect(kidsTopic).toBeVisible(); - await kidsTopic.click(); - await page.getByLabel(/Adoptions- und|Adoption and foster child/).check(); + // registration form + await page.click('div[id="panel-Children, teenagers, adults and family"]'); + await page.click('label[data-cy="topic-selection-radio-1"]'); await page.click('button[data-cy="button-next"]'); await page.fill('input[data-cy="input-postal-code"]', '99999'); await page.click('button[data-cy="button-next"]');