aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2021-09-01 21:59:04 -0400
committerAjay Ramachandran <[email protected]>2021-09-01 22:00:48 -0400
commit5ad809cfb452ed4f76c1ed26c92dad8c979cd341 (patch)
treee3cc59bdd8bfb2d81f298c0940f361fce6a4d1f4 /test
parentd1e46825af3350be5d42958412284bd2c74ac153 (diff)
downloadSponsorBlock-5ad809cfb452ed4f76c1ed26c92dad8c979cd341.tar.gz
SponsorBlock-5ad809cfb452ed4f76c1ed26c92dad8c979cd341.zip
Add e2e test for mute skip
Diffstat (limited to 'test')
-rw-r--r--test/selenium.test.ts33
1 files changed, 30 insertions, 3 deletions
diff --git a/test/selenium.test.ts b/test/selenium.test.ts
index 530546fa..3ec4037e 100644
--- a/test/selenium.test.ts
+++ b/test/selenium.test.ts
@@ -13,8 +13,11 @@ 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 autoskipSegment(driver, 5, 13.211);
+
+ await setSegmentActionType(driver, 0, 1, false);
+ await editSegments(driver, 0, "0:05.000", "0:13.211", "5", "7.5", "0:05.000 to 0:07.500", false);
+ await muteSkipSegment(driver, 5, 7.5);
} finally {
await driver.quit();
}
@@ -24,7 +27,7 @@ async function setup(): Promise<WebDriver> {
const options = new Chrome.Options();
options.addArguments("--load-extension=" + Path.join(__dirname, "../dist/"));
options.addArguments("--mute-audio");
- options.addArguments("--disable-features=PreloadMediaEngagementData, MediaEngagementBypassAutoplayPolicies")
+ options.addArguments("--disable-features=PreloadMediaEngagementData, MediaEngagementBypassAutoplayPolicies");
const driver = await new Builder().forBrowser("chrome").setChromeOptions(options).build();
driver.manage().setTimeouts({
@@ -106,6 +109,16 @@ async function editSegments(driver: WebDriver, index: number, expectedStartTimeB
await driver.wait(until.elementTextIs(sponsorTimeDisplay, expectedDisplayedTime));
}
+async function setSegmentActionType(driver: WebDriver, index: number, actionTypeIndex: number, openSubmitBox: boolean): Promise<void> {
+ if (openSubmitBox) {
+ const submitButton = await driver.findElement(By.id("submitButton"));
+ await submitButton.click();
+ }
+
+ const actionTypeSelection = await driver.findElement(By.css(`#sponsorTimeActionTypesSubmissionNotice${index} > option:nth-child(${actionTypeIndex + 1})`));
+ actionTypeSelection.click();
+}
+
async function autoskipSegment(driver: WebDriver, startTime: number, endTime: number): Promise<void> {
const video = await driver.findElement(By.css("video"));
@@ -113,7 +126,21 @@ async function autoskipSegment(driver: WebDriver, startTime: number, endTime: nu
await driver.executeScript("document.querySelector('video').play()");
await driver.sleep(1300);
-
expect(parseFloat(await video.getAttribute("currentTime"))).toBeGreaterThan(endTime);
await driver.executeScript("document.querySelector('video').pause()");
+}
+
+async function muteSkipSegment(driver: WebDriver, startTime: number, endTime: number): Promise<void> {
+ const duration = endTime - startTime;
+ 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(1300);
+ expect(await video.getAttribute("muted")).toEqual("true");
+
+ await driver.sleep(duration * 1000 + 300);
+ expect(await video.getAttribute("muted")).toBeNull(); // Default is null for some reason
+ await driver.executeScript("document.querySelector('video').pause()");
} \ No newline at end of file