aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAjay <[email protected]>2022-06-17 19:30:53 -0400
committerAjay <[email protected]>2022-06-17 19:30:53 -0400
commit619683e842bd9044e49774787e00b59cd12cf742 (patch)
tree302ff3b89540299f29984c0c0c58f7ea38f40e92 /test
parent1b5ba96bd9582af4d1ac98ac59dce05086bb0760 (diff)
downloadSponsorBlock-619683e842bd9044e49774787e00b59cd12cf742.tar.gz
SponsorBlock-619683e842bd9044e49774787e00b59cd12cf742.zip
Add test for whitelist
Diffstat (limited to 'test')
-rw-r--r--test/selenium.test.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/selenium.test.ts b/test/selenium.test.ts
index ffe8e696..279fc57e 100644
--- a/test/selenium.test.ts
+++ b/test/selenium.test.ts
@@ -32,6 +32,9 @@ test("Selenium Chrome test", async () => {
await setSegmentActionType(driver, 0, 2, false);
await driver.wait(until.elementIsNotVisible(await getDisplayTimeBox(driver, 0)));
+ await toggleWhitelist(driver);
+ await toggleWhitelist(driver);
+
} finally {
await driver.quit();
}
@@ -43,6 +46,7 @@ async function setup(): Promise<WebDriver> {
options.addArguments("--mute-audio");
options.addArguments("--disable-features=PreloadMediaEngagementData, MediaEngagementBypassAutoplayPolicies");
options.addArguments("--headless=chrome");
+ options.addArguments("--window-size=1920,1080");
const driver = await new Builder().forBrowser("chrome").setChromeOptions(options).build();
driver.manage().setTimeouts({
@@ -184,4 +188,31 @@ async function muteSkipSegment(driver: WebDriver, startTime: number, endTime: nu
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()");
+}
+
+async function toggleWhitelist(driver: WebDriver): Promise<void> {
+ const popupButton = await driver.findElement(By.id("infoButton"));
+ if ((await popupButton.getCssValue("display")) !== "none") {
+ await driver.actions().move({ origin: popupButton }).perform();
+ await popupButton.click();
+ }
+
+ const popupFrame = await driver.findElement(By.css("#sponsorBlockPopupContainer iframe"));
+ await driver.switchTo().frame(popupFrame);
+
+ const whitelistButton = await driver.findElement(By.id("whitelistButton"));
+
+ let whitelistText = await driver.findElement(By.id("whitelistChannel"));
+ const whitelistDisplayed = await whitelistText.isDisplayed();
+
+ await whitelistButton.click();
+ if (whitelistDisplayed) {
+ const unwhitelistText = await driver.findElement(By.id("unwhitelistChannel"));
+ await driver.wait(until.elementIsVisible(unwhitelistText));
+ } else {
+ whitelistText = await driver.findElement(By.id("whitelistChannel"));
+ await driver.wait(until.elementIsVisible(whitelistText));
+ }
+
+ await driver.switchTo().defaultContent();
} \ No newline at end of file