2018-01-10 14:19:34 +01:00
|
|
|
var assert = require('assert');
|
|
|
|
var fs = require("fs");
|
|
|
|
var wd = require("../../wd-helper");
|
|
|
|
var config = require("../../config/specs");
|
|
|
|
var helper = require("../helper");
|
|
|
|
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
async function closeModal(wdKey) {
|
2020-02-18 22:39:11 +01:00
|
|
|
const selector = wd.$(wdKey);
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
await browser.waitUntil(async function() {
|
|
|
|
const elem = await $(selector);
|
|
|
|
return await elem.isDisplayedInViewport();
|
2018-01-10 14:19:34 +01:00
|
|
|
});
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
const closeBtnSelector = await $(wd.$(wdKey+".close-modal"));
|
|
|
|
await closeBtnSelector.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
await browser.waitUntil(async function() {
|
|
|
|
return await browser.execute((selector) => {
|
2020-02-18 22:39:11 +01:00
|
|
|
return !document.querySelector(selector);
|
|
|
|
}, selector);
|
2018-01-10 14:19:34 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
describe("modals", function() {
|
|
|
|
describe("open", function() {
|
|
|
|
var styleFilePath = __dirname+"/../../example-style.json";
|
|
|
|
var styleFileData = JSON.parse(fs.readFileSync(styleFilePath));
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
beforeEach(async function() {
|
|
|
|
await browser.url(config.baseUrl+"?debug");
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
const elem = await $(".maputnik-toolbar-link");
|
|
|
|
await elem.waitForExist();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
const elem2 = await $(wd.$("nav:open"));
|
|
|
|
await elem2.click();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
});
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
it("close", async function() {
|
|
|
|
await closeModal("modal:open");
|
2018-01-10 14:19:34 +01:00
|
|
|
});
|
|
|
|
|
2019-06-08 17:16:51 +02:00
|
|
|
// "chooseFile" command currently not available for wdio v5 https://github.com/webdriverio/webdriverio/pull/3632
|
2022-04-06 14:05:15 +02:00
|
|
|
it.skip("upload", async function() {
|
|
|
|
const elem = await $("*[type='file']");
|
|
|
|
await elem.waitForExist();
|
|
|
|
await browser.chooseFile("*[type='file']", styleFilePath);
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
var styleObj = await helper.getStyleStore(browser);
|
2018-01-10 14:19:34 +01:00
|
|
|
assert.deepEqual(styleFileData, styleObj);
|
|
|
|
});
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
it("load from url", async function() {
|
2018-01-10 14:19:34 +01:00
|
|
|
var styleFileUrl = helper.getGeoServerUrl("example-style.json");
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
await browser.setValueSafe(wd.$("modal:open.url.input"), styleFileUrl);
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
const selector = await $(wd.$("modal:open.url.button"));
|
|
|
|
await selector.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
|
|
|
// Allow the network request to happen
|
|
|
|
// NOTE: Its localhost so this should be fast.
|
2022-04-06 14:05:15 +02:00
|
|
|
await browser.pause(300);
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
var styleObj = await helper.getStyleStore(browser);
|
2018-01-10 14:19:34 +01:00
|
|
|
assert.deepEqual(styleFileData, styleObj);
|
|
|
|
});
|
|
|
|
|
|
|
|
// TODO: Need to work out how to mock out the end points
|
|
|
|
it("gallery")
|
|
|
|
})
|
|
|
|
|
2020-05-31 16:33:09 +02:00
|
|
|
describe("shortcuts", function() {
|
2022-04-06 14:05:15 +02:00
|
|
|
it("open/close", async function() {
|
|
|
|
await browser.url(config.baseUrl+"?debug");
|
2020-05-31 16:33:09 +02:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
const elem = await $(".maputnik-toolbar-link");
|
|
|
|
await elem.waitForExist();
|
|
|
|
await browser.flushReactUpdates();
|
2020-05-31 16:33:09 +02:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
await browser.keys(["?"]);
|
2020-05-31 16:33:09 +02:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
const modalEl = await $(wd.$("modal:shortcuts"))
|
|
|
|
assert(await modalEl.isDisplayed());
|
2020-05-31 16:33:09 +02:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
await closeModal("modal:shortcuts");
|
2020-05-31 16:33:09 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-01-10 14:19:34 +01:00
|
|
|
describe("export", function() {
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
beforeEach(async function() {
|
|
|
|
await browser.url(config.baseUrl+"?debug");
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
const elem = await $(".maputnik-toolbar-link");
|
|
|
|
await elem.waitForExist();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
const elem2 = await $(wd.$("nav:export"));
|
|
|
|
await elem2.click();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
});
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
it("close", async function() {
|
|
|
|
await closeModal("modal:export");
|
2018-01-10 14:19:34 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// TODO: Work out how to download a file and check the contents
|
|
|
|
it("download")
|
2018-04-10 15:23:11 +02:00
|
|
|
|
2018-01-10 14:19:34 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
describe("sources", function() {
|
|
|
|
it("active sources")
|
|
|
|
it("public source")
|
|
|
|
it("add new source")
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("inspect", function() {
|
2022-04-06 14:05:15 +02:00
|
|
|
it("toggle", async function() {
|
|
|
|
await browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
|
2018-01-10 14:19:34 +01:00
|
|
|
"geojson:example"
|
|
|
|
]));
|
2022-04-06 14:05:15 +02:00
|
|
|
await browser.acceptAlert();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
const selectBox = await $(wd.$("nav:inspect", "select"));
|
|
|
|
await selectBox.selectByAttribute('value', "inspect");
|
2018-01-10 14:19:34 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("style settings", function() {
|
2022-04-06 14:05:15 +02:00
|
|
|
beforeEach(async function() {
|
|
|
|
await browser.url(config.baseUrl+"?debug");
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
const elem = await $(".maputnik-toolbar-link");
|
|
|
|
await elem.waitForExist();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
const elem2 = await $(wd.$("nav:settings"));
|
|
|
|
await elem2.click();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
});
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
it("name", async function() {
|
|
|
|
await browser.setValueSafe(wd.$("modal:settings.name"), "foobar")
|
|
|
|
const elem = await $(wd.$("modal:settings.owner"));
|
|
|
|
await elem.click();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
var styleObj = await helper.getStyleStore(browser);
|
2018-01-10 14:19:34 +01:00
|
|
|
assert.equal(styleObj.name, "foobar");
|
|
|
|
})
|
2022-04-06 14:05:15 +02:00
|
|
|
it("owner", async function() {
|
|
|
|
await browser.setValueSafe(wd.$("modal:settings.owner"), "foobar")
|
|
|
|
const elem = await $(wd.$("modal:settings.name"));
|
|
|
|
await elem.click();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
var styleObj = await helper.getStyleStore(browser);
|
2018-01-10 14:19:34 +01:00
|
|
|
assert.equal(styleObj.owner, "foobar");
|
|
|
|
})
|
2022-04-06 14:05:15 +02:00
|
|
|
it("sprite url", async function() {
|
|
|
|
await browser.setValueSafe(wd.$("modal:settings.sprite"), "http://example.com")
|
|
|
|
const elem = await $(wd.$("modal:settings.name"));
|
|
|
|
await elem.click();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
var styleObj = await helper.getStyleStore(browser);
|
2018-01-10 14:19:34 +01:00
|
|
|
assert.equal(styleObj.sprite, "http://example.com");
|
|
|
|
})
|
2022-04-06 14:05:15 +02:00
|
|
|
it("glyphs url", async function() {
|
2018-01-10 14:19:34 +01:00
|
|
|
var glyphsUrl = "http://example.com/{fontstack}/{range}.pbf"
|
2022-04-06 14:05:15 +02:00
|
|
|
await browser.setValueSafe(wd.$("modal:settings.glyphs"), glyphsUrl)
|
|
|
|
const elem = await $(wd.$("modal:settings.name"));
|
|
|
|
await elem.click();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
var styleObj = await helper.getStyleStore(browser);
|
2018-01-10 14:19:34 +01:00
|
|
|
assert.equal(styleObj.glyphs, glyphsUrl);
|
|
|
|
})
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
it("maptiler access token", async function() {
|
2018-01-10 14:19:34 +01:00
|
|
|
var apiKey = "testing123";
|
2022-04-06 14:05:15 +02:00
|
|
|
await browser.setValueSafe(wd.$("modal:settings.maputnik:openmaptiles_access_token"), apiKey);
|
|
|
|
const elem = await $(wd.$("modal:settings.name"));
|
|
|
|
await elem.click();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
var styleObj = await helper.getStyleStore(browser);
|
2018-01-10 14:19:34 +01:00
|
|
|
assert.equal(styleObj.metadata["maputnik:openmaptiles_access_token"], apiKey);
|
|
|
|
})
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
it("thunderforest access token", async function() {
|
2018-10-30 20:37:56 +01:00
|
|
|
var apiKey = "testing123";
|
2022-04-06 14:05:15 +02:00
|
|
|
await browser.setValueSafe(wd.$("modal:settings.maputnik:thunderforest_access_token"), apiKey);
|
|
|
|
const elem = await $(wd.$("modal:settings.name"));
|
|
|
|
await elem.click();
|
|
|
|
await browser.flushReactUpdates();
|
2018-10-30 20:37:56 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
var styleObj = await helper.getStyleStore(browser);
|
2018-10-30 20:37:56 +01:00
|
|
|
assert.equal(styleObj.metadata["maputnik:thunderforest_access_token"], apiKey);
|
|
|
|
})
|
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
it("style renderer", async function() {
|
|
|
|
const selector = await $(wd.$("modal:settings.maputnik:renderer"));
|
|
|
|
await selector.selectByAttribute('value', "ol");
|
|
|
|
const elem = await $(wd.$("modal:settings.name"));
|
|
|
|
await elem.click();
|
|
|
|
await browser.flushReactUpdates();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2022-04-06 14:05:15 +02:00
|
|
|
var styleObj = await helper.getStyleStore(browser);
|
2018-10-30 20:06:52 +01:00
|
|
|
assert.equal(styleObj.metadata["maputnik:renderer"], "ol");
|
2018-01-10 14:19:34 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("sources", function() {
|
|
|
|
it("toggle")
|
|
|
|
})
|
|
|
|
})
|