(e2e) fix some flaky tests

Some tests were flaky, causing them to fail
intermittently. This commit aims to address
this issue.
This commit is contained in:
Anthony LC
2025-03-31 12:14:20 +02:00
committed by Anthony LC
parent 65ddf7fbe8
commit 50b90f9ae7
3 changed files with 14 additions and 23 deletions

View File

@@ -2,7 +2,7 @@ import path from 'path';
import { expect, test } from '@playwright/test'; import { expect, test } from '@playwright/test';
import { createDoc, verifyDocName } from './common'; import { createDoc } from './common';
const config = { const config = {
AI_FEATURE_ENABLED: true, AI_FEATURE_ENABLED: true,
@@ -100,22 +100,13 @@ test.describe('Config', () => {
page, page,
browserName, browserName,
}) => { }) => {
const webSocketPromise = page.waitForEvent('websocket', (webSocket) => {
return webSocket.url().includes('ws://localhost:4444/collaboration/ws/');
});
await page.goto('/'); await page.goto('/');
const randomDoc = await createDoc( void createDoc(page, 'doc-collaboration', browserName, 1);
page,
'doc-collaboration',
browserName,
1,
);
await verifyDocName(page, randomDoc[0]); const webSocket = await page.waitForEvent('websocket', (webSocket) => {
return webSocket.url().includes('ws://localhost:4444/collaboration/ws/');
const webSocket = await webSocketPromise; });
expect(webSocket.url()).toContain('ws://localhost:4444/collaboration/ws/'); expect(webSocket.url()).toContain('ws://localhost:4444/collaboration/ws/');
}); });

View File

@@ -58,18 +58,18 @@ test.describe('Doc Editor', () => {
* - signal of the backend to the collaborative server (connection should close) * - signal of the backend to the collaborative server (connection should close)
* - reconnection to the collaborative server * - reconnection to the collaborative server
*/ */
test('checks the connection with collaborative server', async ({ test('checks the connection with collaborative server', async ({ page }) => {
page,
browserName,
}) => {
let webSocketPromise = page.waitForEvent('websocket', (webSocket) => { let webSocketPromise = page.waitForEvent('websocket', (webSocket) => {
return webSocket return webSocket
.url() .url()
.includes('ws://localhost:4444/collaboration/ws/?room='); .includes('ws://localhost:4444/collaboration/ws/?room=');
}); });
const randomDoc = await createDoc(page, 'doc-editor', browserName, 1); await page
await verifyDocName(page, randomDoc[0]); .getByRole('button', {
name: 'New doc',
})
.click();
let webSocket = await webSocketPromise; let webSocket = await webSocketPromise;
expect(webSocket.url()).toContain( expect(webSocket.url()).toContain(
@@ -99,7 +99,7 @@ test.describe('Doc Editor', () => {
const wsClose = await wsClosePromise; const wsClose = await wsClosePromise;
expect(wsClose.isClosed()).toBeTruthy(); expect(wsClose.isClosed()).toBeTruthy();
// Checkt the ws is connected again // Check the ws is connected again
webSocketPromise = page.waitForEvent('websocket', (webSocket) => { webSocketPromise = page.waitForEvent('websocket', (webSocket) => {
return webSocket return webSocket
.url() .url()

View File

@@ -190,7 +190,7 @@ test.describe('Document grid item options', () => {
test.describe('Documents filters', () => { test.describe('Documents filters', () => {
test('it checks the prebuild left panel filters', async ({ page }) => { test('it checks the prebuild left panel filters', async ({ page }) => {
await page.goto('/'); void page.goto('/');
// All Docs // All Docs
const response = await page.waitForResponse( const response = await page.waitForResponse(
@@ -263,7 +263,7 @@ test.describe('Documents filters', () => {
test.describe('Documents Grid', () => { test.describe('Documents Grid', () => {
test('checks all the elements are visible', async ({ page }) => { test('checks all the elements are visible', async ({ page }) => {
await page.goto('/'); void page.goto('/');
let docs: SmallDoc[] = []; let docs: SmallDoc[] = [];
const response = await page.waitForResponse( const response = await page.waitForResponse(