mirror of
https://github.com/maputnik/editor.git
synced 2026-08-25 14:37:27 +00:00
wip
This commit is contained in:
+69
-37
@@ -1,9 +1,11 @@
|
||||
import { then } from "@shellygo/cypress-test-utils/assertable";
|
||||
import MaputnikDriver from "./maputnik-driver";
|
||||
|
||||
describe("modals", () => {
|
||||
let { beforeAndAfter, when, get, should } = new MaputnikDriver();
|
||||
let { beforeAndAfter, given, when, get, should } = new MaputnikDriver();
|
||||
beforeAndAfter();
|
||||
beforeEach(() => {
|
||||
given.fixture("example-style.json", "file:example-style.json");
|
||||
when.setStyle("");
|
||||
});
|
||||
describe("open", () => {
|
||||
@@ -11,7 +13,8 @@ describe("modals", () => {
|
||||
when.click("nav:open");
|
||||
});
|
||||
|
||||
it.only("close", () => {
|
||||
it.skip("close", () => {
|
||||
// Asserting non existence is an anti-pattern
|
||||
when.modal.close("modal:open");
|
||||
should.notExist("modal:open");
|
||||
});
|
||||
@@ -19,26 +22,51 @@ describe("modals", () => {
|
||||
it.skip("upload", () => {
|
||||
// HM: I was not able to make the following choose file actually to select a file and close the modal...
|
||||
when.chooseExampleFile();
|
||||
|
||||
should.styleStoreEqualToExampleFileData();
|
||||
then(get.responseBody("example-style.json")).shouldDeepEqual(
|
||||
get.maputnikStyleFromLocalStorageObj()
|
||||
);
|
||||
});
|
||||
|
||||
it("load from url", () => {
|
||||
let styleFileUrl = get.exampleFileUrl();
|
||||
describe("when click open url", () => {
|
||||
beforeEach(() => {
|
||||
let styleFileUrl = get.exampleFileUrl();
|
||||
|
||||
when.setValue("modal:open.url.input", styleFileUrl);
|
||||
when.click("modal:open.url.button");
|
||||
when.waitForExampleFileRequset();
|
||||
when.setValue("modal:open.url.input", styleFileUrl);
|
||||
when.click("modal:open.url.button");
|
||||
});
|
||||
it.only("load from url", () => {
|
||||
// expect(
|
||||
// Cypress._.isMatch(
|
||||
// get.maputnikStyleFromLocalStorageObj(),
|
||||
// get.responseBody("example-style.json")
|
||||
// )
|
||||
// ).to.be.true;
|
||||
|
||||
should.styleStoreEqualToExampleFileData();
|
||||
// expect(
|
||||
// Cypress._.isMatch(
|
||||
// get.maputnikStyleFromLocalStorageObj(),
|
||||
// { shelly: true }
|
||||
// //get.responseBody("example-style.json")
|
||||
// )
|
||||
// );
|
||||
should.styleStoreEqualToExampleFileData();
|
||||
// then(get.fixture("file:example-style.json")).should(
|
||||
// "deep.equal",
|
||||
// get.maputnikStyleFromLocalStorageObj()
|
||||
// );
|
||||
// then(get.responseBody("example-style.json")).shouldDeepNestedInclude(
|
||||
// get.maputnikStyleFromLocalStorageObj()
|
||||
// );
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("shortcuts", () => {
|
||||
it("open/close", () => {
|
||||
it.skip("open/close", () => {
|
||||
when.setStyle("");
|
||||
when.typeKeys("?");
|
||||
when.modal.close("modal:shortcuts");
|
||||
// Anti pattern. we should test that things exist. million things don't exist
|
||||
should.notExist("modal:shortcuts");
|
||||
});
|
||||
});
|
||||
@@ -48,7 +76,7 @@ describe("modals", () => {
|
||||
when.click("nav:export");
|
||||
});
|
||||
|
||||
it("close", () => {
|
||||
it.skip("close", () => {
|
||||
when.modal.close("modal:export");
|
||||
should.notExist("modal:export");
|
||||
});
|
||||
@@ -65,9 +93,9 @@ describe("modals", () => {
|
||||
|
||||
describe("inspect", () => {
|
||||
it("toggle", () => {
|
||||
// There is no assertion in this test
|
||||
when.setStyle("geojson");
|
||||
|
||||
when.selectWithin("nav:inspect", "inspect");
|
||||
when.select("maputnik-select", "inspect");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -78,35 +106,40 @@ describe("modals", () => {
|
||||
|
||||
it("name", () => {
|
||||
when.click("field-doc-button-Name");
|
||||
|
||||
should.containText("spec-field-doc", "name for the style");
|
||||
then(get.elementsText("spec-field-doc")).shouldContainText(
|
||||
"name for the style"
|
||||
);
|
||||
});
|
||||
|
||||
it("show name specifications", () => {
|
||||
when.setValue("modal:settings.name", "foobar");
|
||||
when.click("modal:settings.owner");
|
||||
|
||||
should.equalStyleStore((obj) => obj.name, "foobar");
|
||||
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
name: "foobar",
|
||||
});
|
||||
});
|
||||
|
||||
it("owner", () => {
|
||||
when.setValue("modal:settings.owner", "foobar");
|
||||
when.click("modal:settings.name");
|
||||
|
||||
should.equalStyleStore((obj) => obj.owner, "foobar");
|
||||
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
owner: "foobar",
|
||||
});
|
||||
});
|
||||
it("sprite url", () => {
|
||||
when.setValue("modal:settings.sprite", "http://example.com");
|
||||
when.click("modal:settings.name");
|
||||
|
||||
should.equalStyleStore((obj) => obj.sprite, "http://example.com");
|
||||
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
sprite: "http://example.com",
|
||||
});
|
||||
});
|
||||
it("glyphs url", () => {
|
||||
let glyphsUrl = "http://example.com/{fontstack}/{range}.pbf";
|
||||
when.setValue("modal:settings.glyphs", glyphsUrl);
|
||||
when.click("modal:settings.name");
|
||||
|
||||
should.equalStyleStore((obj) => obj.glyphs, glyphsUrl);
|
||||
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
glyphs: glyphsUrl,
|
||||
});
|
||||
});
|
||||
|
||||
it("maptiler access token", () => {
|
||||
@@ -116,11 +149,9 @@ describe("modals", () => {
|
||||
apiKey
|
||||
);
|
||||
when.click("modal:settings.name");
|
||||
|
||||
should.equalStyleStore(
|
||||
(obj) => obj.metadata["maputnik:openmaptiles_access_token"],
|
||||
apiKey
|
||||
);
|
||||
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
metadata: { "maputnik:openmaptiles_access_token": apiKey },
|
||||
});
|
||||
});
|
||||
|
||||
it("thunderforest access token", () => {
|
||||
@@ -130,21 +161,22 @@ describe("modals", () => {
|
||||
apiKey
|
||||
);
|
||||
when.click("modal:settings.name");
|
||||
|
||||
should.equalStyleStore(
|
||||
(obj) => obj.metadata["maputnik:thunderforest_access_token"],
|
||||
apiKey
|
||||
);
|
||||
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
metadata: { "maputnik:thunderforest_access_token": apiKey },
|
||||
});
|
||||
});
|
||||
|
||||
it("style renderer", () => {
|
||||
cy.on("uncaught:exception", () => false); // this is due to the fact that this is an invalid style for openlayers
|
||||
when.select("modal:settings.maputnik:renderer", "ol");
|
||||
should.beSelected("modal:settings.maputnik:renderer", "ol");
|
||||
then(get.inputValue("modal:settings.maputnik:renderer")).shouldEqual(
|
||||
"ol"
|
||||
);
|
||||
|
||||
when.click("modal:settings.name");
|
||||
|
||||
should.equalStyleStore((obj) => obj.metadata["maputnik:renderer"], "ol");
|
||||
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
metadata: { "maputnik:renderer": "ol" },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user