Tag the video element with its track source for e2e specs

The SDK MediaView renders a plain video element, so LiveKit's
data-lk-source attribute is gone. Expose data-source from the SDK track
and point the screen-share spec at it.
This commit is contained in:
Timo K.
2026-10-14 10:23:29 +02:00
committed by Timo
parent 3f98e36c56
commit d37599a794
3 changed files with 22 additions and 6 deletions
+6 -6
View File
@@ -76,9 +76,9 @@ widgetTest("Sharing screen in group call", async ({ addUser, browserName }) => {
timeout: 5000, timeout: 5000,
}); });
await expect( await expect(frame.locator('video[data-source="screenShare"]')).toHaveCount(
frame.locator('video[data-lk-source="screen_share"]'), 1,
).toHaveCount(1); );
} }
// Alice should be in grid mode as she is local sharing // Alice should be in grid mode as she is local sharing
@@ -117,9 +117,9 @@ widgetTest("Sharing screen in group call", async ({ addUser, browserName }) => {
timeout: 5000, timeout: 5000,
}); });
await expect( await expect(frame.locator('video[data-source="screenShare"]')).toHaveCount(
frame.locator('video[data-lk-source="screen_share"]'), 2,
).toHaveCount(2); );
// Expect 2 indicators at the bottom // Expect 2 indicators at the bottom
await expect(frame.getByTestId("screenshare-indicator")).toHaveCount(2); await expect(frame.getByTestId("screenshare-indicator")).toHaveCount(2);
+15
View File
@@ -46,6 +46,21 @@ describe("MediaView", () => {
}); });
}); });
describe("with video", () => {
it("labels the video element with the track source", () => {
render(
<MediaView
{...baseProps}
video={mockVideoTrack({ source: "screenShare" })}
/>,
);
expect(screen.getByTestId("video")).toHaveAttribute(
"data-source",
"screenShare",
);
});
});
describe("name tag", () => { describe("name tag", () => {
test("is shown with name", () => { test("is shown with name", () => {
render(<MediaView {...baseProps} displayName="Bob" />); render(<MediaView {...baseProps} displayName="Bob" />);
+1
View File
@@ -205,6 +205,7 @@ export const MediaView: FC<Props> = ({
tabIndex={-1} tabIndex={-1}
disablePictureInPicture disablePictureInPicture
data-testid="video" data-testid="video"
data-source={video.source}
// Set the placeholder to a small transparent image. (On Android web // Set the placeholder to a small transparent image. (On Android web
// views the default poster image is particularly ugly.) // views the default poster image is particularly ugly.)
poster={videoPlaceholder} poster={videoPlaceholder}