From df5b20053b3ccbed250866a6d043a99355e402a5 Mon Sep 17 00:00:00 2001 From: ben-lu-uw Date: Fri, 27 May 2022 11:52:52 -0400 Subject: [PATCH] Add tests for feature index option --- test/e2e/basics/popup.test.js | 40 ++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/test/e2e/basics/popup.test.js b/test/e2e/basics/popup.test.js index 9c3d2b8..f64ce3f 100644 --- a/test/e2e/basics/popup.test.js +++ b/test/e2e/basics/popup.test.js @@ -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"); @@ -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 ()=>{ @@ -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(""); }); }); \ No newline at end of file