Skip to content
Closed
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: 4 additions & 1 deletion src/mapml-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,10 @@ export class MapViewer extends HTMLElement {
(layer) => {
M._pasteLayer(document.activeElement, layer);
});
}});
} else if (e.keyCode === 32 && document.activeElement.nodeName === "MAPML-VIEWER") {
e.preventDefault();
}
});
this.parentElement.addEventListener('mousedown', function (e) {
if(document.activeElement.nodeName === "MAPML-VIEWER"){
document.activeElement.dispatchEvent(new CustomEvent('mapfocused', {detail:
Expand Down
87 changes: 52 additions & 35 deletions test/e2e/mapml-viewer/mapml-viewer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,7 @@ test.describe("Playwright mapml-viewer Element Tests", () => {
});
});
test("Paste geojson Layer to map using ctrl+v", async () => {
await page.click("body > textarea#copyGeoJSON");
await page.keyboard.press("Control+a");
await page.keyboard.press("Control+c");

await page.click("body > mapml-viewer");
await page.keyboard.press('Control+v');
const layerCount = await page.$eval(
"body > mapml-viewer",
(map) => map.layers.length
);
expect(layerCount).toEqual(2);
});

test("Paste Link to map using ctrl+v", async () => {
await page.click("body > textarea#copyLink");
await page.click("body > textarea#copyGeoJSON");
await page.keyboard.press("Control+a");
await page.keyboard.press("Control+c");

Expand All @@ -146,35 +132,66 @@ test.describe("Playwright mapml-viewer Element Tests", () => {
"body > mapml-viewer",
(map) => map.layers.length
);
expect(layerCount).toEqual(3);
expect(layerCount).toEqual(2);
});

test("Paste Invalid text to map using ctrl+v", async () => {
await page.click("body > textarea#invalidText");
await page.keyboard.press("Control+a");
await page.keyboard.press("Control+c");

await page.click("body > mapml-viewer");
await page.keyboard.press('Control+v');
test("Paste Link to map using ctrl+v", async () => {
await page.click("body > textarea#copyLink");
await page.keyboard.press("Control+a");
await page.keyboard.press("Control+c");

await page.click("body > mapml-viewer");
await page.keyboard.press('Control+v');
const layerCount = await page.$eval(
"body > mapml-viewer",
(map) => map.layers.length
);
expect(layerCount).toEqual(3);
});

test("Paste Invalid text to map using ctrl+v", async () => {
await page.click("body > textarea#invalidText");
await page.keyboard.press("Control+a");
await page.keyboard.press("Control+c");

await page.click("body > mapml-viewer");
await page.keyboard.press('Control+v');
const layerCount = await page.$eval(
"body > mapml-viewer",
(map) => map.layers.length
);
expect(layerCount).toEqual(3);
});

test("Paste Invalid link to map using ctrl+v", async () => {
await page.click("body > textarea#invalidLink");
await page.keyboard.press("Control+a");
await page.keyboard.press("Control+c");

await page.click("body > mapml-viewer");
await page.keyboard.press('Control+v');
await page.waitForTimeout(500);
const layerCount = await page.$eval(
"body > mapml-viewer",
(map) => map.layers.length
);
expect(layerCount).toEqual(3);
});
});

test("Paste Invalid link to map using ctrl+v", async () => {
await page.click("body > textarea#invalidLink");
await page.keyboard.press("Control+a");
await page.keyboard.press("Control+c");

test("Press spacebar when focus is on map", async () => {
await page.click("body > textarea");
const pos = await page.$eval(
"body > mapml-viewer",
() => window.pageYOffset
)
await page.click("body > mapml-viewer");
await page.keyboard.press('Control+v');
await page.waitForTimeout(500);
const layerCount = await page.$eval(
"body > mapml-viewer",
(map) => map.layers.length
await page.waitForTimeout(300);
await page.keyboard.press('Space');
await page.waitForTimeout(300);
const currPos = await page.$eval(
"body > mapml-viewer",
() => window.pageYOffset
);
expect(layerCount).toEqual(3);
expect(currPos).toEqual(pos);
});
});