(app-desk) e2e test app-desk

Tests:
- login to keycloak
- create new teams
- check teams are displayed
This commit is contained in:
Anthony LC
2024-01-11 12:32:45 +01:00
committed by Anthony LC
parent 2ef31a424a
commit 5f280ae3fc
2 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import { expect, test } from '@playwright/test';
import { keyCloakSignIn } from './common';
test.beforeEach(async ({ page }) => {
await page.goto('/');
await keyCloakSignIn(page);
});
test.describe('App', () => {
test('should display the homepage after keycloak login', async ({ page }) => {
await expect(page.locator('h2')).toContainText('Hello world!');
});
test('creates 2 teams and displayed them', async ({ page }) => {
await page.getByLabel('Team name').fill('My new team');
await page.click('button:has-text("Create Team")');
await page.getByLabel('Team name').fill('My second new team');
await page.click('button:has-text("Create Team")');
await expect(
page.locator('li').getByText('My new team').first(),
).toBeVisible();
await expect(
page.locator('li').getByText('My second new team').first(),
).toBeVisible();
});
});

View File

@@ -0,0 +1,14 @@
import { Page } from '@playwright/test';
export const keyCloakSignIn = async (page: Page) => {
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.click('input[type="submit"]');
}
};