This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
people/src/frontend/apps/e2e/__tests__/app-desk/teams-create.spec.ts
daproclaima ee5a785d43 🥅(frontend) improve add member form error handling
- translate known errors, including already existing
group error, and directly display the other ones
- add component tests
- update translations
- add parseAPIError, a reusable function to
catch errors on the whole frontend app

Closes issue #293

♻️(frontend) improve general error catching

- change parseAPIError to make it reusable on all
requests
- update components depending on it
2024-09-26 17:20:58 +02:00

128 lines
3.7 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { keyCloakSignIn } from './common';
test.beforeEach(async ({ page, browserName }) => {
await page.goto('/');
await keyCloakSignIn(page, browserName);
});
test.describe('Teams Create', () => {
test('checks all the create team elements are visible', async ({ page }) => {
const buttonCreateHomepage = page.getByRole('button', {
name: 'Create a new team',
});
await buttonCreateHomepage.click();
await expect(buttonCreateHomepage).toBeHidden();
const card = page.getByLabel('Create new team card').first();
await expect(card.getByLabel('Team name')).toBeVisible();
await expect(
card.getByRole('heading', {
name: 'Create a new group',
level: 3,
}),
).toBeVisible();
await expect(
card.getByRole('button', {
name: 'Create the team',
}),
).toBeVisible();
await expect(
card.getByRole('button', {
name: 'Cancel',
}),
).toBeVisible();
});
test('checks the cancel button interaction', async ({ page }) => {
const buttonCreateHomepage = page.getByRole('button', {
name: 'Create a new team',
});
await buttonCreateHomepage.click();
await expect(buttonCreateHomepage).toBeHidden();
const card = page.getByLabel('Create new team card').first();
await card
.getByRole('button', {
name: 'Cancel',
})
.click();
await expect(buttonCreateHomepage).toBeVisible();
});
test('checks the routing on new team created', async ({
page,
browserName,
}) => {
const panel = page.getByLabel('Teams panel').first();
await panel.getByRole('link', { name: 'Add a team' }).click();
const teamName = `My routing team ${browserName}-${Math.floor(Math.random() * 1000)}`;
await page.getByText('Team name').fill(teamName);
await page.getByRole('button', { name: 'Create the team' }).click();
const elTeam = page.getByRole('heading', { name: teamName });
await expect(elTeam).toBeVisible();
await panel.getByRole('link', { name: 'Add a team' }).click();
await expect(elTeam).toBeHidden();
await panel.locator('li').getByText(teamName).click();
await expect(elTeam).toBeVisible();
});
test('checks alias teams url with homepage', async ({ page }) => {
await expect(page).toHaveURL('/');
const buttonCreateHomepage = page.getByRole('button', {
name: 'Create a new team',
});
await expect(buttonCreateHomepage).toBeVisible();
await page.goto('/teams/');
await expect(buttonCreateHomepage).toBeVisible();
await expect(page).toHaveURL(/\/teams\//);
});
test('checks error when duplicate team', async ({ page, browserName }) => {
const panel = page.getByLabel('Teams panel').first();
await panel.getByRole('link', { name: 'Add a team' }).click();
const teamName = `My duplicate team ${browserName}-${Math.floor(Math.random() * 1000)}`;
await page.getByText('Team name').fill(teamName);
await page.getByRole('button', { name: 'Create the team' }).click();
await panel.getByRole('link', { name: 'Add a team' }).click();
await page.getByText('Team name').fill(teamName);
await page.getByRole('button', { name: 'Create the team' }).click();
await expect(
page.getByText(
'This name is already used for another group. Please enter another one.',
),
).toBeVisible();
});
test('checks 404 on teams/[id] page', async ({ page }) => {
await page.goto('/teams/some-unknown-team');
await expect(
page.getByText(
'It seems that the page you are looking for does not exist or cannot be displayed correctly.',
),
).toBeVisible({
timeout: 15000,
});
});
});