This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add more e2e test cases * Implement feedback
- Loading branch information
Showing
5 changed files
with
183 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dist | ||
docs | ||
.vscode | ||
.vscode | ||
playwright-report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { expect, Page, test } from "@playwright/test"; | ||
|
||
export const joinRoomAndAddScreenShare = async (page: Page, roomId: string): Promise<string> => | ||
test.step("Join room and add track", async () => { | ||
const peerRequest = await createPeer(page, roomId); | ||
try { | ||
const { | ||
peer: { id: peerId }, | ||
token: peerToken, | ||
} = (await peerRequest.json()).data; | ||
|
||
await test.step("Join room", async () => { | ||
await page.getByPlaceholder("token").fill(peerToken); | ||
await page.getByRole("button", { name: "Connect", exact: true }).click(); | ||
await expect(page.getByText("Status: joined")).toBeVisible(); | ||
}); | ||
|
||
await test.step("Add screenshare", async () => { | ||
await page.getByRole("button", { name: "Start screen share", exact: true }).click(); | ||
}); | ||
|
||
return peerId; | ||
} catch (e) { | ||
// todo fix | ||
throw { status: peerRequest.status(), response: await peerRequest.json() }; | ||
} | ||
}); | ||
|
||
export const assertThatRemoteTracksAreVisible = async (page: Page, otherClientIds: string[]) => { | ||
await test.step("Assert that remote tracks are visible", () => | ||
Promise.all( | ||
otherClientIds.map((peerId) => expect(page.locator(`css=video[data-peer-id="${peerId}"]`)).toBeVisible()), | ||
)); | ||
}; | ||
|
||
export const assertThatOtherVideoIsPlaying = async (page: Page) => { | ||
await test.step("Assert that media is working", async () => { | ||
const getDecodedFrames: () => Promise<number> = () => | ||
page.evaluate(async () => { | ||
const peerConnection = ( | ||
window as typeof window & { client: { webrtc: { connection: RTCPeerConnection | undefined } } } | ||
).client.webrtc.connection; | ||
const stats = await peerConnection?.getStats(); | ||
for (const stat of stats?.values() ?? []) { | ||
if (stat.type === "inbound-rtp") { | ||
return stat.framesDecoded; | ||
} | ||
} | ||
return 0; | ||
}); | ||
const firstMeasure = await getDecodedFrames(); | ||
await expect(async () => expect((await getDecodedFrames()) > firstMeasure).toBe(true)).toPass(); | ||
}); | ||
}; | ||
|
||
export const createRoom = async (page: Page, maxPeers?: number) => | ||
await test.step("Create room", async () => { | ||
const data = { | ||
...(maxPeers ? { maxPeers } : {}), | ||
}; | ||
|
||
const roomRequest = await page.request.post("http://localhost:5002/room", { data }); | ||
return (await roomRequest.json()).data.room.id as string; | ||
}); | ||
|
||
export const createPeer = async (page: Page, roomId: string, enableSimulcast: boolean = true) => | ||
await test.step("Create room", async () => { | ||
return await page.request.post("http://localhost:5002/room/" + roomId + "/peer", { | ||
data: { | ||
type: "webrtc", | ||
options: { | ||
enableSimulcast, | ||
}, | ||
}, | ||
}); | ||
}); |