diff options
author | Ajay Ramachandran <[email protected]> | 2021-07-30 16:00:59 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2021-07-30 16:00:59 -0400 |
commit | 3187efaf1a0ebf8174a9df05c57c0c85371c605f (patch) | |
tree | fa793d9529c4a1ae05054a929321caf390aee04b | |
parent | b9bbbebc106f761002247540f421e66471024a1a (diff) | |
download | SponsorBlock-3187efaf1a0ebf8174a9df05c57c0c85371c605f.tar.gz SponsorBlock-3187efaf1a0ebf8174a9df05c57c0c85371c605f.zip |
Add test for skipping preview segment
-rw-r--r-- | test/selenium.test.ts | 14 |
1 files changed, 14 insertions, 0 deletions
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<void> { + 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 |