From d37599a79422145c8838dee378c5dd563725e498 Mon Sep 17 00:00:00 2001 From: "Timo K." Date: Tue, 13 Oct 2026 17:53:16 +0200 Subject: [PATCH] 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. --- playwright/widget/screen-share.test.ts | 12 ++++++------ src/tile/MediaView.test.tsx | 15 +++++++++++++++ src/tile/MediaView.tsx | 1 + 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/playwright/widget/screen-share.test.ts b/playwright/widget/screen-share.test.ts index c6b03c3f9..fb608f534 100644 --- a/playwright/widget/screen-share.test.ts +++ b/playwright/widget/screen-share.test.ts @@ -76,9 +76,9 @@ widgetTest("Sharing screen in group call", async ({ addUser, browserName }) => { timeout: 5000, }); - await expect( - frame.locator('video[data-lk-source="screen_share"]'), - ).toHaveCount(1); + await expect(frame.locator('video[data-source="screenShare"]')).toHaveCount( + 1, + ); } // 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, }); - await expect( - frame.locator('video[data-lk-source="screen_share"]'), - ).toHaveCount(2); + await expect(frame.locator('video[data-source="screenShare"]')).toHaveCount( + 2, + ); // Expect 2 indicators at the bottom await expect(frame.getByTestId("screenshare-indicator")).toHaveCount(2); diff --git a/src/tile/MediaView.test.tsx b/src/tile/MediaView.test.tsx index 0b5653517..1c634fc4d 100644 --- a/src/tile/MediaView.test.tsx +++ b/src/tile/MediaView.test.tsx @@ -46,6 +46,21 @@ describe("MediaView", () => { }); }); + describe("with video", () => { + it("labels the video element with the track source", () => { + render( + , + ); + expect(screen.getByTestId("video")).toHaveAttribute( + "data-source", + "screenShare", + ); + }); + }); + describe("name tag", () => { test("is shown with name", () => { render(); diff --git a/src/tile/MediaView.tsx b/src/tile/MediaView.tsx index 5294dce55..c49e6209d 100644 --- a/src/tile/MediaView.tsx +++ b/src/tile/MediaView.tsx @@ -205,6 +205,7 @@ export const MediaView: FC = ({ tabIndex={-1} disablePictureInPicture data-testid="video" + data-source={video.source} // Set the placeholder to a small transparent image. (On Android web // views the default poster image is particularly ugly.) poster={videoPlaceholder}