Skip to content

Commit

Permalink
✅(y-webrtc-signaling) test signaling server
Browse files Browse the repository at this point in the history
Create a e2e testcase to test the signaling server.
  • Loading branch information
AntoLC committed Apr 9, 2024
1 parent d76c470 commit 725c400
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/frontend/apps/e2e/__tests__/app-impress/pad-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,30 @@ test.describe('Pad Editor', () => {
await page.locator('.ProseMirror.bn-editor').fill('Hello World');
await expect(page.getByText('Hello World')).toBeVisible();
});

test('checks the Pad is connected to the webrtc server', async ({ page }) => {
const webSocketPromise = page.waitForEvent('websocket', (webSocket) => {
return webSocket.url().includes('ws://localhost:4444/');
});

await page.getByText('My mocked pad').first().click();
await expect(page.locator('h2').getByText('My mocked pad')).toBeVisible();

const webSocket = await webSocketPromise;
expect(webSocket.url()).toBe('ws://localhost:4444/');

const framesentPromise = webSocket.waitForEvent('framesent');

await page.locator('.ProseMirror.bn-editor').click();
await page.locator('.ProseMirror.bn-editor').fill('Hello World');

const framesent = await framesentPromise;
const payload = JSON.parse(framesent.payload as string) as {
type: string;
data: { type: string };
};

expect(payload.type).toBe('publish');
expect(payload.data.type).toBe('signal');
});
});

0 comments on commit 725c400

Please sign in to comment.