From 3187efaf1a0ebf8174a9df05c57c0c85371c605f Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 30 Jul 2021 16:00:59 -0400 Subject: [PATCH] Add test for skipping preview segment --- test/selenium.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/selenium.test.ts b/test/selenium.test.ts index f87e92cf..f06de269 100644 --- a/test/selenium.test.ts +++ b/test/selenium.test.ts @@ -24,6 +24,8 @@ test("Selenium Chrome test", async () => { await createSegment(driver, "4", "10.33", "0:04.000 to 0:10.330"); await editSegments(driver, 0, "0:04.000", "0:10.330", "5", "13.211", "0:05.000 to 0:13.211", false); + + await skipSegment(driver, 5, 13.211); } finally { await driver.quit(); } @@ -85,4 +87,16 @@ async function editSegments(driver: WebDriver, index: number, expectedStartTimeB sponsorTimeDisplays = await driver.findElements(By.className("sponsorTimeDisplay")); sponsorTimeDisplay = sponsorTimeDisplays[index]; await driver.wait(until.elementTextIs(sponsorTimeDisplay, expectedDisplayedTime)); +} + +async function skipSegment(driver: WebDriver, startTime: number, endTime: number): Promise { + const video = await driver.findElement(By.css("video")); + + await driver.executeScript("document.querySelector('video').currentTime = " + (startTime - 0.5)); + await driver.executeScript("document.querySelector('video').play()"); + + await driver.sleep(1000); + + expect(parseFloat(await video.getAttribute("currentTime"))).toBeGreaterThan(endTime); + await driver.executeScript("document.querySelector('video').pause()"); } \ No newline at end of file