From 0084c8355171e033e8a9c9e1383bbe602beb7f1b Mon Sep 17 00:00:00 2001 From: MarconLP <13001502+MarconLP@users.noreply.github.com> Date: Sat, 15 Apr 2023 22:03:57 +0200 Subject: [PATCH] add test for playing back video --- tests/video.spec.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/video.spec.ts diff --git a/tests/video.spec.ts b/tests/video.spec.ts new file mode 100644 index 0000000..6668ae6 --- /dev/null +++ b/tests/video.spec.ts @@ -0,0 +1,16 @@ +import { expect, test } from "@playwright/test"; + +test("should be able to view video", async ({ page }) => { + await page.goto("http://localhost:3000/videos"); + await page.locator("div.grid > a:nth-child(1)").click(); + await expect(page).toHaveURL(/http:\/\/localhost:3000\/share\/[A-Za-z0-9]+/); + + const video = page.locator("video"); + expect(video).toBeTruthy(); + await video.evaluate((v: HTMLVideoElement) => v.play()); + const isPlaying = await video.evaluate((v: HTMLVideoElement) => !v.paused); + expect(isPlaying).toBe(true); + await video.click(); + const isPaused = await video.evaluate((v: HTMLVideoElement) => v.paused); + expect(isPaused).toBe(true); +});