️(e2e) add workers to playwright with CI

We have added workers to playwright to run tests in parallel,
this will help us to run tests faster.
The tests run on a commun database, so to keep the tests
stable between browsers, we created 3 different
users to run the tests, it will avoid to have commun data
stepping on each other.
This commit is contained in:
Anthony LC
2024-02-09 09:54:53 +01:00
committed by Anthony LC
parent 0ab9f16cb3
commit 1e38174c1b
7 changed files with 41 additions and 14 deletions

View File

@@ -1,13 +1,18 @@
import { Page } from '@playwright/test';
export const keyCloakSignIn = async (page: Page) => {
export const keyCloakSignIn = async (page: Page, browserName: string) => {
const title = await page.locator('h1').first().textContent({
timeout: 5000,
});
if (title?.includes('Sign in to your account')) {
await page.getByRole('textbox', { name: 'username' }).fill('user-e2e');
await page.getByRole('textbox', { name: 'password' }).fill('password-e2e');
await page
.getByRole('textbox', { name: 'username' })
.fill(`user-e2e-${browserName}`);
await page
.getByRole('textbox', { name: 'password' })
.fill(`password-e2e-${browserName}`);
await page.click('input[type="submit"]');
}

View File

@@ -2,9 +2,9 @@ import { expect, test } from '@playwright/test';
import { keyCloakSignIn } from './common';
test.beforeEach(async ({ page }) => {
test.beforeEach(async ({ page, browserName }) => {
await page.goto('/');
await keyCloakSignIn(page);
await keyCloakSignIn(page, browserName);
});
test.describe('Header', () => {

View File

@@ -2,9 +2,9 @@ import { expect, test } from '@playwright/test';
import { keyCloakSignIn } from './common';
test.beforeEach(async ({ page }) => {
test.beforeEach(async ({ page, browserName }) => {
await page.goto('/');
await keyCloakSignIn(page);
await keyCloakSignIn(page, browserName);
});
test.describe('Language', () => {

View File

@@ -2,9 +2,9 @@ import { expect, test } from '@playwright/test';
import { keyCloakSignIn } from './common';
test.beforeEach(async ({ page }) => {
test.beforeEach(async ({ page, browserName }) => {
await page.goto('/');
await keyCloakSignIn(page);
await keyCloakSignIn(page, browserName);
});
test.describe('Menu', () => {

View File

@@ -4,9 +4,9 @@ import { waitForElementCount } from '../helpers';
import { keyCloakSignIn } from './common';
test.beforeEach(async ({ page }) => {
test.beforeEach(async ({ page, browserName }) => {
await page.goto('/');
await keyCloakSignIn(page);
await keyCloakSignIn(page, browserName);
});
test.describe.configure({ mode: 'serial' });