(app-desk) modal update team

Integrate the modal and the logic to update a team.
This commit is contained in:
Anthony LC
2024-03-21 10:59:26 +01:00
committed by Anthony LC
parent 7347565f8d
commit 8ea7b53286
6 changed files with 237 additions and 56 deletions

View File

@@ -18,6 +18,15 @@ export const keyCloakSignIn = async (page: Page, browserName: string) => {
}
};
export const randomTeamsName = (
teamName: string,
browserName: string,
length: number,
) =>
Array.from({ length }, (_el, index) => {
return `${teamName}-${browserName}-${Math.floor(Math.random() * 10000)}-${index}`;
});
export const createTeam = async (
page: Page,
teamName: string,
@@ -27,9 +36,7 @@ export const createTeam = async (
const panel = page.getByLabel('Teams panel').first();
const buttonCreate = page.getByRole('button', { name: 'Create the team' });
const randomTeams = Array.from({ length }, (_el, index) => {
return `${teamName}-${browserName}-${Math.floor(Math.random() * 10000)}-${index}`;
});
const randomTeams = randomTeamsName(teamName, browserName, length);
for (let i = 0; i < randomTeams.length; i++) {
await panel.getByRole('button', { name: 'Add a team' }).click();

View File

@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';
import { createTeam, keyCloakSignIn } from './common';
import { createTeam, keyCloakSignIn, randomTeamsName } from './common';
test.beforeEach(async ({ page, browserName }) => {
await page.goto('/');
@@ -40,4 +40,22 @@ test.describe('Team', () => {
page.getByText(`Last update at ${todayFormated}`),
).toBeVisible();
});
test('it updates the team name', async ({ page, browserName }) => {
await createTeam(page, 'team-update-name', browserName, 1);
await page.getByLabel(`Open the team options modal`).click();
const teamName = randomTeamsName('new-team-update-name', browserName, 1)[0];
await page.getByText('New name...', { exact: true }).fill(teamName);
await page
.getByRole('button', { name: 'Validate the modification' })
.click();
await expect(page.getByText('The team has been updated.')).toBeVisible();
await expect(
page.getByText(`Add people to the “${teamName}“ group.`),
).toBeVisible();
});
});