(e2e) remove some flakiness

Service worker added some flakiness, we
activate the sw only if not from the CI.
We add as well the email of the user added in a
doc to the toast message. This way we can check
if the user was added correctly, this will remove
some flakiness in some tests.
This commit is contained in:
Anthony LC
2024-06-13 14:24:56 +02:00
committed by Anthony LC
parent 14a91a5698
commit ae9555284d
9 changed files with 32 additions and 20 deletions

View File

@@ -119,7 +119,9 @@ export const addNewMember = async (
await page.getByRole('button', { name: 'Validate' }).click();
await expect(page.getByText(`User added to the document.`)).toBeVisible();
await expect(
page.getByText(`User ${users[index].email} added to the document.`),
).toBeVisible();
return users[index].email;
};

View File

@@ -87,10 +87,10 @@ test.describe('Document add users', () => {
// Select a new user
await inputSearch.fill('user');
const responseSearchUser = await responsePromiseSearchUser;
const users = (await responseSearchUser.json()).results as {
const [user] = (await responseSearchUser.json()).results as {
email: string;
}[];
await page.getByRole('option', { name: users[0].email }).click();
await page.getByRole('option', { name: user.email }).click();
// Choose a role
await page.getByRole('radio', { name: 'Administrator' }).click();
@@ -112,7 +112,9 @@ test.describe('Document add users', () => {
expect(responseCreateInvitation.ok()).toBeTruthy();
// Check user added
await expect(page.getByText(`User added to the document.`)).toBeVisible();
await expect(
page.getByText(`User ${user.email} added to the document.`),
).toBeVisible();
const responseAddUser = await responsePromiseAddUser;
expect(responseAddUser.ok()).toBeTruthy();
});
@@ -131,10 +133,10 @@ test.describe('Document add users', () => {
const inputSearch = page.getByLabel(/Find a member to add to the document/);
await inputSearch.fill('user');
const responseSearchUser = await responsePromiseSearchUser;
const users = (await responseSearchUser.json()).results as {
const [user] = (await responseSearchUser.json()).results as {
email: string;
}[];
await page.getByRole('option', { name: users[0].email }).click();
await page.getByRole('option', { name: user.email }).click();
// Choose a role
await page.getByRole('radio', { name: 'Owner' }).click();
@@ -146,7 +148,9 @@ test.describe('Document add users', () => {
await page.getByRole('button', { name: 'Validate' }).click();
await expect(page.getByText(`User added to the document.`)).toBeVisible();
await expect(
page.getByText(`User ${user.email} added to the document.`),
).toBeVisible();
const responseAddMember = await responsePromiseAddMember;
expect(responseAddMember.ok()).toBeTruthy();
@@ -154,9 +158,7 @@ test.describe('Document add users', () => {
await page.getByRole('button', { name: 'Add members' }).click();
await inputSearch.fill('user');
await expect(
page.getByRole('option', { name: users[0].email }),
).toBeHidden();
await expect(page.getByRole('option', { name: user.email })).toBeHidden();
});
test('it try to add twice the same invitation', async ({

View File

@@ -95,6 +95,9 @@ test.describe('Pad Create', () => {
});
test('checks 404 on docs/[id] page', async ({ page }) => {
// eslint-disable-next-line playwright/no-wait-for-timeout
await page.waitForTimeout(300);
await page.goto('/docs/some-unknown-pad');
await expect(
page.getByText(

View File

@@ -153,12 +153,6 @@ test.describe('Members Delete', () => {
const username = await addNewMember(page, 1, 'Admin');
await expect(
page.getByText(`User added to the document.`).last(),
).toBeHidden({
timeout: 5000,
});
await page.getByLabel('Open the document options').click();
await page.getByRole('button', { name: 'Manage members' }).click();