Skip to content

Commit

Permalink
Add tests for feature index option
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-lu-uw committed May 27, 2022
1 parent 5a8c49a commit df5b200
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions test/e2e/basics/popup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ describe("Popup test", () => {
});

test("Turn on options", async ()=>{
let extension = page;
await page.keyboard.press("Tab");
await page.waitForTimeout(500);

for(let i = 0; i < 2; i++){
await page.keyboard.press("Tab");
await page.waitForTimeout(500);
await page.keyboard.press("Space");
await page.waitForTimeout(500);
}
await extension.keyboard.press("Space");
await extension.waitForTimeout(500);

let newPage = await context.newPage();
await newPage.waitForTimeout(1000);
await newPage.goto(PATH + "basics/locale.html");
Expand All @@ -37,25 +38,36 @@ describe("Popup test", () => {
await newPage.waitForTimeout(500);
await newPage.keyboard.press("ArrowUp");
await newPage.waitForTimeout(1000);
const output = await newPage.$eval(

const featureIndexOverlay = await newPage.$eval(
"xpath=//html/body/mapml-viewer >> css=div",
(div) => div.querySelector("output.mapml-feature-index")
);

const announceMovement = await newPage.$eval(
"xpath=//html/body/mapml-viewer >> css=div > output",
(output) => output.innerHTML
);

await newPage.close();
await expect(output).toEqual("zoom level 2 column 10 row 11");
await expect(featureIndexOverlay === null).toEqual(false);
await expect(announceMovement).toEqual("zoom level 2 column 10 row 11");
});

test("Clear storage", async ()=>{
for(let i = 0; i < 2; i++){
await page.keyboard.press("Tab");
await page.waitForTimeout(500);
}
await page.keyboard.press("Space");
await page.waitForTimeout(500);
await page.keyboard.press("Shift+Tab");
await page.waitForTimeout(500);
await page.keyboard.press("Space");
await page.waitForTimeout(500);

await page.reload();
await page.waitForTimeout(1000);
let announceMoveOption = await page.locator('[id=announceMovement]').isChecked();
let featureIndexOverlayOption = await page.locator('[id=featureIndexOverlayOption]').isChecked();
expect(announceMoveOption).toBe(false);
expect(featureIndexOverlayOption).toBe(false);
});

test("Check if options are off", async ()=>{
Expand All @@ -67,10 +79,18 @@ describe("Popup test", () => {
await newPage.waitForTimeout(500);
await newPage.keyboard.press("ArrowUp");
await newPage.waitForTimeout(1000);

const featureIndexOverlay = await newPage.$eval(
"xpath=//html/body/mapml-viewer >> css=div",
(div) => div.querySelector("output.mapml-feature-index")
);

const output = await newPage.$eval(
"xpath=//html/body/mapml-viewer >> css=div > output",
(output) => output.innerHTML
);

await expect(featureIndexOverlay).toEqual(null);
await expect(output).toEqual("");
});
});

0 comments on commit df5b200

Please sign in to comment.