Skip to content

Commit

Permalink
Add a test for no window when extension is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mtusnio committed Aug 24, 2024
1 parent 6bf8765 commit c26d138
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions browser_tests/popup.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';
import { TimeoutError } from 'puppeteer';
import * as utils from "./utils";


Expand All @@ -17,7 +18,7 @@ afterEach(async () => {
worker = null
});

test("popup appears when hovering over text in plain html", async () => {
test("if extension ENABLED, popup appears when hovering over text in plain html", async () => {
const page = await browser.newPage();
await page.goto(`file://${path.resolve()}/browser_tests/testdata/plain.html`, { waitUntil: ['domcontentloaded', "networkidle2"] });
await page.bringToFront();
Expand All @@ -31,6 +32,22 @@ test("popup appears when hovering over text in plain html", async () => {
// Those coordinates might be screen dependent, but for now they pass on GitHub actions
// and locally. If they start failng somewhere else, this needs to be revisited
await page.mouse.move(40, 15)
const exists = !! await page.waitForSelector("#zhongwen-window", { timeout: 5000 });
const exists = !! await page.waitForSelector("#zhongwen-window", { timeout: 4000 });
expect(exists).toBe(true)
})

test("if extension DISABLED, popup does not appear when hovering over text in plain html", async () => {
const page = await browser.newPage();
await page.goto(`file://${path.resolve()}/browser_tests/testdata/plain.html`, { waitUntil: ['domcontentloaded', "networkidle2"] });
await page.bringToFront();


await page.setViewport({ width: 1280, height: 720 });
await utils.wait(500)

// Those coordinates might be screen dependent, but for now they pass on GitHub actions
// and locally. If they start failng somewhere else, this needs to be revisited
await page.mouse.move(40, 15)
await expect(page.waitForSelector("#zhongwen-window", { timeout: 3000 })).rejects.toThrow(TimeoutError)
})

0 comments on commit c26d138

Please sign in to comment.