✅(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:
@@ -119,7 +119,9 @@ export const addNewMember = async (
|
|||||||
|
|
||||||
await page.getByRole('button', { name: 'Validate' }).click();
|
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;
|
return users[index].email;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -87,10 +87,10 @@ test.describe('Document add users', () => {
|
|||||||
// Select a new user
|
// Select a new user
|
||||||
await inputSearch.fill('user');
|
await inputSearch.fill('user');
|
||||||
const responseSearchUser = await responsePromiseSearchUser;
|
const responseSearchUser = await responsePromiseSearchUser;
|
||||||
const users = (await responseSearchUser.json()).results as {
|
const [user] = (await responseSearchUser.json()).results as {
|
||||||
email: string;
|
email: string;
|
||||||
}[];
|
}[];
|
||||||
await page.getByRole('option', { name: users[0].email }).click();
|
await page.getByRole('option', { name: user.email }).click();
|
||||||
|
|
||||||
// Choose a role
|
// Choose a role
|
||||||
await page.getByRole('radio', { name: 'Administrator' }).click();
|
await page.getByRole('radio', { name: 'Administrator' }).click();
|
||||||
@@ -112,7 +112,9 @@ test.describe('Document add users', () => {
|
|||||||
expect(responseCreateInvitation.ok()).toBeTruthy();
|
expect(responseCreateInvitation.ok()).toBeTruthy();
|
||||||
|
|
||||||
// Check user added
|
// 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;
|
const responseAddUser = await responsePromiseAddUser;
|
||||||
expect(responseAddUser.ok()).toBeTruthy();
|
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/);
|
const inputSearch = page.getByLabel(/Find a member to add to the document/);
|
||||||
await inputSearch.fill('user');
|
await inputSearch.fill('user');
|
||||||
const responseSearchUser = await responsePromiseSearchUser;
|
const responseSearchUser = await responsePromiseSearchUser;
|
||||||
const users = (await responseSearchUser.json()).results as {
|
const [user] = (await responseSearchUser.json()).results as {
|
||||||
email: string;
|
email: string;
|
||||||
}[];
|
}[];
|
||||||
await page.getByRole('option', { name: users[0].email }).click();
|
await page.getByRole('option', { name: user.email }).click();
|
||||||
|
|
||||||
// Choose a role
|
// Choose a role
|
||||||
await page.getByRole('radio', { name: 'Owner' }).click();
|
await page.getByRole('radio', { name: 'Owner' }).click();
|
||||||
@@ -146,7 +148,9 @@ test.describe('Document add users', () => {
|
|||||||
|
|
||||||
await page.getByRole('button', { name: 'Validate' }).click();
|
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;
|
const responseAddMember = await responsePromiseAddMember;
|
||||||
expect(responseAddMember.ok()).toBeTruthy();
|
expect(responseAddMember.ok()).toBeTruthy();
|
||||||
|
|
||||||
@@ -154,9 +158,7 @@ test.describe('Document add users', () => {
|
|||||||
await page.getByRole('button', { name: 'Add members' }).click();
|
await page.getByRole('button', { name: 'Add members' }).click();
|
||||||
|
|
||||||
await inputSearch.fill('user');
|
await inputSearch.fill('user');
|
||||||
await expect(
|
await expect(page.getByRole('option', { name: user.email })).toBeHidden();
|
||||||
page.getByRole('option', { name: users[0].email }),
|
|
||||||
).toBeHidden();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('it try to add twice the same invitation', async ({
|
test('it try to add twice the same invitation', async ({
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ test.describe('Pad Create', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('checks 404 on docs/[id] page', async ({ page }) => {
|
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 page.goto('/docs/some-unknown-pad');
|
||||||
await expect(
|
await expect(
|
||||||
page.getByText(
|
page.getByText(
|
||||||
|
|||||||
@@ -153,12 +153,6 @@ test.describe('Members Delete', () => {
|
|||||||
|
|
||||||
const username = await addNewMember(page, 1, 'Admin');
|
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.getByLabel('Open the document options').click();
|
||||||
await page.getByRole('button', { name: 'Manage members' }).click();
|
await page.getByRole('button', { name: 'Manage members' }).click();
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "prettier --check . && yarn stylelint && next build",
|
"build": "prettier --check . && yarn stylelint && next build",
|
||||||
"build:ci": "cp .env.development .env.local && yarn build",
|
"build:ci": "cp .env.development .env.local && cross-env NEXT_PUBLIC_CI=true yarn build",
|
||||||
"build-theme": "cunningham -g css,ts -o src/cunningham --utility-classes",
|
"build-theme": "cunningham -g css,ts -o src/cunningham --utility-classes",
|
||||||
"start": "npx -y serve@latest out",
|
"start": "npx -y serve@latest out",
|
||||||
"lint": "tsc --noEmit && next lint",
|
"lint": "tsc --noEmit && next lint",
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
"@openfun/cunningham-react": "2.9.3",
|
"@openfun/cunningham-react": "2.9.3",
|
||||||
"@tanstack/react-query": "5.40.1",
|
"@tanstack/react-query": "5.40.1",
|
||||||
"grapesjs-blocks-basic": "1.0.2",
|
"grapesjs-blocks-basic": "1.0.2",
|
||||||
|
"cross-env": "*",
|
||||||
"i18next": "23.11.5",
|
"i18next": "23.11.5",
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
"luxon": "3.4.4",
|
"luxon": "3.4.4",
|
||||||
|
|||||||
@@ -102,7 +102,9 @@ export const ModalAddMembers = ({
|
|||||||
? t('Invitation sent to {{email}}.', {
|
? t('Invitation sent to {{email}}.', {
|
||||||
email: option.value.email,
|
email: option.value.email,
|
||||||
})
|
})
|
||||||
: t('User added to the document.');
|
: t('User {{email}} added to the document.', {
|
||||||
|
email: option.value.email,
|
||||||
|
});
|
||||||
|
|
||||||
toast(message, VariantType.SUCCESS, toastOptions);
|
toast(message, VariantType.SUCCESS, toastOptions);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export default function App({ Component, pageProps }: AppPropsWithLayout) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator && process.env.NEXT_PUBLIC_CI !== 'true') {
|
||||||
navigator.serviceWorker.register('/service-worker.js').catch((err) => {
|
navigator.serviceWorker.register('/service-worker.js').catch((err) => {
|
||||||
console.error('Service worker registration failed:', err);
|
console.error('Service worker registration failed:', err);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@types/node": "20.14.2",
|
"@types/node": "20.14.2",
|
||||||
"@types/react-dom": "18.3.0",
|
"@types/react-dom": "18.3.0",
|
||||||
|
"cross-env": "7.0.3",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"typescript": "5.4.5",
|
"typescript": "5.4.5",
|
||||||
|
|||||||
@@ -5035,7 +5035,14 @@ crelt@^1.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/crelt/-/crelt-1.0.6.tgz#7cc898ea74e190fb6ef9dae57f8f81cf7302df72"
|
resolved "https://registry.yarnpkg.com/crelt/-/crelt-1.0.6.tgz#7cc898ea74e190fb6ef9dae57f8f81cf7302df72"
|
||||||
integrity sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==
|
integrity sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==
|
||||||
|
|
||||||
cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
|
cross-env@7.0.3:
|
||||||
|
version "7.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
|
||||||
|
integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==
|
||||||
|
dependencies:
|
||||||
|
cross-spawn "^7.0.1"
|
||||||
|
|
||||||
|
cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
|
||||||
version "7.0.3"
|
version "7.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
|
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
|
||||||
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
|
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
|
||||||
|
|||||||
Reference in New Issue
Block a user