Refactor driver for E2E (#843)

This is basically the content of #841 with the code review changes and
relevant fixes to tests/driver code to pass the tests.
CC: @ShellyDCMS

After this we should lint the project and add the lint to the CI to make
sure it doesn't break.

---------

Co-authored-by: ShellyDCMS <60476837+ShellyDCMS@users.noreply.github.com>
Co-authored-by: shelly_goldblit <shelly_goldblit@dell.com>
This commit is contained in:
Harel M
2023-12-20 16:34:46 +02:00
committed by GitHub
parent f219ff1e17
commit 4d1e2e6893
19 changed files with 3386 additions and 4278 deletions
+27 -26
View File
@@ -1,60 +1,61 @@
import driver from "./driver";
import MaputnikDriver from "./driver";
describe("keyboard", () => {
let { beforeAndAfter, given, when, get, should } = new MaputnikDriver();
beforeAndAfter();
describe("shortcuts", () => {
beforeEach(() => {
driver.setupInterception();
driver.setStyle('');
})
given.setupInterception();
when.setStyle("");
});
it("ESC should unfocus", () => {
const targetSelector = driver.getDataAttribute("nav:inspect") + " select";
driver.focus(targetSelector);
driver.isFocused(targetSelector);
const targetSelector = "maputnik-select";
when.focus(targetSelector);
should.beFocused(targetSelector);
//driver.typeKeys("{esc}");
//driver.isFocused('body');
when.typeKeys("{esc}");
expect(should.notBeFocused(targetSelector));
});
it("'?' should show shortcuts modal", () => {
driver.typeKeys("?");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:shortcuts"));
when.typeKeys("?");
should.beVisible("modal:shortcuts");
});
it("'o' should show open modal", () => {
driver.typeKeys("o");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:open"));
when.typeKeys("o");
should.beVisible("modal:open");
});
it("'e' should show export modal", () => {
driver.typeKeys("e");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:export"));
when.typeKeys("e");
should.beVisible("modal:export");
});
it("'d' should show sources modal", () => {
driver.typeKeys("d");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:sources"));
when.typeKeys("d");
should.beVisible("modal:sources");
});
it("'s' should show settings modal", () => {
driver.typeKeys("s");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:settings"));
when.typeKeys("s");
should.beVisible("modal:settings");
});
it("'i' should change map to inspect mode", () => {
driver.typeKeys("i");
driver.isSelected(driver.getDataAttribute("nav:inspect"), "inspect");
when.typeKeys("i");
should.beSelected("nav:inspect", "inspect");
});
it("'m' should focus map", () => {
driver.typeKeys("m");
driver.isFocused(".maplibregl-canvas");
when.typeKeys("m");
should.canvasBeFocused();
});
it("'!' should show debug modal", () => {
driver.typeKeys("!");
driver.isDisplayedInViewport(driver.getDataAttribute("modal:debug"));
when.typeKeys("!");
should.beVisible("modal:debug");
});
});
});