(e2e) fix flaki tests

Some tests were getting flaky:
- check the reorder of sub page
- it checks interlink feature
This commit is contained in:
Anthony LC
2026-01-21 11:55:20 +01:00
parent 65b67a29b1
commit f64800727a
5 changed files with 33 additions and 49 deletions

View File

@@ -1,6 +1,6 @@
# e2e # e2e
test-results/ test-results/
report/ report*/
blob-report/ blob-report/
playwright/.auth/ playwright/.auth/
playwright/.cache/ playwright/.cache/

View File

@@ -890,6 +890,9 @@ test.describe('Doc Editor', () => {
await expect(interlinkChild.locator('svg').first()).toBeHidden(); await expect(interlinkChild.locator('svg').first()).toBeHidden();
await interlinkChild.click(); await interlinkChild.click();
// wait for navigation to complete
await page.waitForTimeout(1000);
await verifyDocName(page, docChild2); await verifyDocName(page, docChild2);
await editor.click(); await editor.click();

View File

@@ -447,6 +447,8 @@ export const overrideDocContent = async ({
await verifyDocName(page, randomDoc); await verifyDocName(page, randomDoc);
await page.waitForTimeout(1000);
// Add Image SVG // Add Image SVG
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
const { suggestionMenu } = await openSuggestionMenu({ page }); const { suggestionMenu } = await openSuggestionMenu({ page });

View File

@@ -27,47 +27,32 @@ test.describe('Doc Tree', () => {
const docTree = page.getByTestId('doc-tree'); const docTree = page.getByTestId('doc-tree');
// Create first sub page // Create first sub page
const firstResponsePromise = page.waitForResponse(
(response) =>
response.url().includes('/documents/') &&
response.url().includes('/children/') &&
response.request().method() === 'POST',
);
await clickOnAddRootSubPage(page); await clickOnAddRootSubPage(page);
const firstResponse = await firstResponsePromise; await updateDocTitle(page, 'first move');
expect(firstResponse.ok()).toBeTruthy();
await updateDocTitle(page, 'first');
const secondResponsePromise = page.waitForResponse(
(response) =>
response.url().includes('/documents/') &&
response.url().includes('/children/') &&
response.request().method() === 'POST',
);
// Create second sub page // Create second sub page
await clickOnAddRootSubPage(page); await clickOnAddRootSubPage(page);
const secondResponse = await secondResponsePromise; await updateDocTitle(page, 'second move');
expect(secondResponse.ok()).toBeTruthy();
await updateDocTitle(page, 'second');
const secondSubPageJson = await secondResponse.json(); const firstSubPageItem = docTree.getByText('first move').first();
const firstSubPageJson = await firstResponse.json(); const secondSubPageItem = docTree.getByText('second move').first();
const firstSubPageItem = docTree
.getByTestId(`doc-sub-page-item-${firstSubPageJson.id}`)
.first();
const secondSubPageItem = docTree
.getByTestId(`doc-sub-page-item-${secondSubPageJson.id}`)
.first();
// check that the sub pages are visible in the tree // check that the sub pages are visible in the tree
await expect(firstSubPageItem).toBeVisible(); await expect(firstSubPageItem).toBeVisible();
await expect(secondSubPageItem).toBeVisible(); await expect(secondSubPageItem).toBeVisible();
// get the bounding boxes of the sub pages // Check the position of the sub pages
const allSubPageItems = await docTree
.getByTestId(/^doc-sub-page-item/)
.all();
expect(allSubPageItems.length).toBe(2);
// Check that elements are in the correct order
await expect(allSubPageItems[0].getByText('first move')).toBeVisible();
await expect(allSubPageItems[1].getByText('second move')).toBeVisible();
// Will move the first sub page to the second position
const firstSubPageBoundingBox = await firstSubPageItem.boundingBox(); const firstSubPageBoundingBox = await firstSubPageItem.boundingBox();
const secondSubPageBoundingBox = await secondSubPageItem.boundingBox(); const secondSubPageBoundingBox = await secondSubPageItem.boundingBox();
@@ -75,10 +60,9 @@ test.describe('Doc Tree', () => {
expect(secondSubPageBoundingBox).toBeDefined(); expect(secondSubPageBoundingBox).toBeDefined();
if (!firstSubPageBoundingBox || !secondSubPageBoundingBox) { if (!firstSubPageBoundingBox || !secondSubPageBoundingBox) {
throw new Error('Impossible de déterminer la position des éléments'); throw new Error('unable to determine the position of the elements');
} }
// move the first sub page to the second position
await page.mouse.move( await page.mouse.move(
firstSubPageBoundingBox.x + firstSubPageBoundingBox.width / 2, firstSubPageBoundingBox.x + firstSubPageBoundingBox.width / 2,
firstSubPageBoundingBox.y + firstSubPageBoundingBox.height / 2, firstSubPageBoundingBox.y + firstSubPageBoundingBox.height / 2,
@@ -105,24 +89,19 @@ test.describe('Doc Tree', () => {
await expect(firstSubPageItem).toBeVisible(); await expect(firstSubPageItem).toBeVisible();
await expect(secondSubPageItem).toBeVisible(); await expect(secondSubPageItem).toBeVisible();
// Check the position of the sub pages // Check that elements are in the correct order
const allSubPageItems = await docTree const allSubPageItemsAfterReload = await docTree
.getByTestId(/^doc-sub-page-item/) .getByTestId(/^doc-sub-page-item/)
.all(); .all();
expect(allSubPageItems.length).toBe(2); expect(allSubPageItemsAfterReload.length).toBe(2);
// Check that the first element has the ID of the second sub page after the drag and drop await expect(
await expect(allSubPageItems[0]).toHaveAttribute( allSubPageItemsAfterReload[0].getByText('second move'),
'data-testid', ).toBeVisible();
`doc-sub-page-item-${secondSubPageJson.id}`, await expect(
); allSubPageItemsAfterReload[1].getByText('first move'),
).toBeVisible();
// Check that the second element has the ID of the first sub page after the drag and drop
await expect(allSubPageItems[1]).toHaveAttribute(
'data-testid',
`doc-sub-page-item-${firstSubPageJson.id}`,
);
}); });
test('it detaches a document', async ({ page, browserName }) => { test('it detaches a document', async ({ page, browserName }) => {

View File

@@ -162,7 +162,7 @@ export const verifyDocName = async (page: Page, docName: string) => {
await expect( await expect(
page.getByRole('textbox', { name: 'Document title' }), page.getByRole('textbox', { name: 'Document title' }),
).toContainText(docName, { ).toContainText(docName, {
timeout: 1000, timeout: 3000,
}); });
} catch { } catch {
await expect(page.getByRole('heading', { name: docName })).toBeVisible(); await expect(page.getByRole('heading', { name: docName })).toBeVisible();