✅(e2e) fix flaky tests
Some tests were flaky, we improved their stability.
This commit is contained in:
@@ -60,35 +60,30 @@ test.describe('Doc Routing', () => {
|
|||||||
|
|
||||||
await page.locator('.ProseMirror.bn-editor').fill('Hello World');
|
await page.locator('.ProseMirror.bn-editor').fill('Hello World');
|
||||||
|
|
||||||
// Wait for the doc link (via its dynamic title) to be visible
|
const responsePromise = page.route(
|
||||||
const docLink = page.getByRole('link', { name: docTitle });
|
/.*\/documents\/.*\/$|users\/me\/$/,
|
||||||
await expect(docLink).toBeVisible();
|
async (route) => {
|
||||||
|
const request = route.request();
|
||||||
|
|
||||||
// Intercept GET/PATCH requests to return 401
|
if (
|
||||||
await page.route(/.*\/documents\/.*\/$|users\/me\/$/, async (route) => {
|
request.method().includes('PATCH') ||
|
||||||
const request = route.request();
|
request.method().includes('GET')
|
||||||
if (
|
) {
|
||||||
request.method().includes('PATCH') ||
|
await route.fulfill({
|
||||||
request.method().includes('GET')
|
status: 401,
|
||||||
) {
|
json: {
|
||||||
await route.fulfill({
|
detail: 'Log in to access the document',
|
||||||
status: 401,
|
},
|
||||||
json: { detail: 'Log in to access the document' },
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
await route.continue();
|
||||||
await route.continue();
|
}
|
||||||
}
|
},
|
||||||
});
|
|
||||||
|
|
||||||
// Explicitly wait for a 401 response after clicking
|
|
||||||
const wait401 = page.waitForResponse(
|
|
||||||
(resp) =>
|
|
||||||
resp.status() === 401 &&
|
|
||||||
/\/(documents\/[^/]+\/|users\/me\/)$/.test(resp.url()),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await docLink.click();
|
await page.getByRole('link', { name: '401-doc-parent' }).click();
|
||||||
await wait401;
|
|
||||||
|
await responsePromise;
|
||||||
|
|
||||||
await expect(page.getByText('Log in to access the document.')).toBeVisible({
|
await expect(page.getByText('Log in to access the document.')).toBeVisible({
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ export const navigateToPageFromTree = async ({
|
|||||||
title: string;
|
title: string;
|
||||||
}) => {
|
}) => {
|
||||||
const docTree = page.getByTestId('doc-tree');
|
const docTree = page.getByTestId('doc-tree');
|
||||||
await docTree.getByText(title).click();
|
await docTree
|
||||||
|
.getByText(title, {
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.click();
|
||||||
await verifyDocName(page, title);
|
await verifyDocName(page, title);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user