Skip to content

Add option to toggle feature index overlay #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ <h6 class="card-title">Accessibility Settings</h6>
<label class="form-check-label" for="announceMovement">Announce movement for screen readers</label>
</div>

<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="featureIndexOverlayOption">
<label class="form-check-label" for="featureIndexOverlayOption">Show feature index</label>
</div>

</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function resetStorage() {
document.addEventListener("DOMContentLoaded", () => {
loadOptions();
document.getElementById("announceMovement").addEventListener("change", handleCheckboxChange);
document.getElementById("featureIndexOverlayOption").addEventListener("change", handleCheckboxChange);
document.getElementById("clear").addEventListener("click", resetStorage);
});

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("");
});
});