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");
|
|
|
|
|
|
|
|
|
|
|
|
function closeModal(wdKey) {
|
|
|
|
browser.waitUntil(function() {
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(wdKey);
|
|
|
|
return elem.isDisplayedInViewport();
|
2018-01-10 14:19:34 +01:00
|
|
|
});
|
|
|
|
|
2019-06-08 07:19:18 +02:00
|
|
|
const closeBtnSelector = $(wd.$(wdKey+".close-modal"));
|
|
|
|
closeBtnSelector.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
|
|
|
browser.waitUntil(function() {
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(wdKey);
|
|
|
|
return !elem.isDisplayed();
|
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));
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
browser.url(config.baseUrl+"?debug");
|
|
|
|
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(".maputnik-toolbar-link");
|
|
|
|
elem.waitForExist();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem2 = $(wd.$("nav:open"));
|
|
|
|
elem2.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("close", function() {
|
|
|
|
closeModal("open-modal");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("upload", function() {
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $("*[type='file']");
|
|
|
|
elem.waitForExist();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.chooseFile("*[type='file']", styleFilePath);
|
|
|
|
|
|
|
|
var styleObj = helper.getStyleStore(browser);
|
|
|
|
assert.deepEqual(styleFileData, styleObj);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("load from url", function() {
|
|
|
|
var styleFileUrl = helper.getGeoServerUrl("example-style.json");
|
|
|
|
|
|
|
|
browser.setValueSafe(wd.$("open-modal.url.input"), styleFileUrl);
|
|
|
|
|
2019-06-08 07:19:18 +02:00
|
|
|
const selector = $(wd.$("open-modal.url.button"));
|
|
|
|
selector.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
|
|
|
// Allow the network request to happen
|
|
|
|
// NOTE: Its localhost so this should be fast.
|
|
|
|
browser.pause(300);
|
|
|
|
|
|
|
|
var styleObj = helper.getStyleStore(browser);
|
|
|
|
assert.deepEqual(styleFileData, styleObj);
|
|
|
|
});
|
|
|
|
|
|
|
|
// TODO: Need to work out how to mock out the end points
|
|
|
|
it("gallery")
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("export", function() {
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
browser.url(config.baseUrl+"?debug");
|
|
|
|
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(".maputnik-toolbar-link");
|
|
|
|
elem.waitForExist();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem2 = $(wd.$("nav:export"));
|
|
|
|
elem2.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("close", function() {
|
|
|
|
closeModal("export-modal");
|
|
|
|
});
|
|
|
|
|
|
|
|
// 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
|
|
|
// TODO: Work out how to mock the end git points
|
|
|
|
it("save to gist")
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("sources", function() {
|
|
|
|
it("active sources")
|
|
|
|
it("public source")
|
|
|
|
it("add new source")
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("inspect", function() {
|
|
|
|
it("toggle", function() {
|
|
|
|
browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
|
|
|
|
"geojson:example"
|
|
|
|
]));
|
2019-06-08 07:19:18 +02:00
|
|
|
browser.acceptAlert();
|
2018-01-10 14:19:34 +01:00
|
|
|
|
2019-06-08 07:19:18 +02:00
|
|
|
const selectBox = $(wd.$("nav:inspect", "select"));
|
|
|
|
selectBox.selectByAttribute('value', "inspect");
|
2018-01-10 14:19:34 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("style settings", function() {
|
|
|
|
beforeEach(function() {
|
|
|
|
browser.url(config.baseUrl+"?debug");
|
|
|
|
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(".maputnik-toolbar-link");
|
|
|
|
elem.waitForExist();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem2 = $(wd.$("nav:settings"));
|
|
|
|
elem2.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("name", function() {
|
|
|
|
browser.setValueSafe(wd.$("modal-settings.name"), "foobar")
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(wd.$("modal-settings.owner"));
|
|
|
|
elem.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
|
|
|
|
var styleObj = helper.getStyleStore(browser);
|
|
|
|
assert.equal(styleObj.name, "foobar");
|
|
|
|
})
|
|
|
|
it("owner", function() {
|
|
|
|
browser.setValueSafe(wd.$("modal-settings.owner"), "foobar")
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(wd.$("modal-settings.name"));
|
|
|
|
elem.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
|
|
|
|
var styleObj = helper.getStyleStore(browser);
|
|
|
|
assert.equal(styleObj.owner, "foobar");
|
|
|
|
})
|
|
|
|
it("sprite url", function() {
|
|
|
|
browser.setValueSafe(wd.$("modal-settings.sprite"), "http://example.com")
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(wd.$("modal-settings.name"));
|
|
|
|
elem.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
|
|
|
|
var styleObj = helper.getStyleStore(browser);
|
|
|
|
assert.equal(styleObj.sprite, "http://example.com");
|
|
|
|
})
|
|
|
|
it("glyphs url", function() {
|
|
|
|
var glyphsUrl = "http://example.com/{fontstack}/{range}.pbf"
|
|
|
|
browser.setValueSafe(wd.$("modal-settings.glyphs"), glyphsUrl)
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(wd.$("modal-settings.name"));
|
|
|
|
elem.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
|
|
|
|
var styleObj = helper.getStyleStore(browser);
|
|
|
|
assert.equal(styleObj.glyphs, glyphsUrl);
|
|
|
|
})
|
|
|
|
|
|
|
|
it("mapbox access token", function() {
|
|
|
|
var apiKey = "testing123";
|
|
|
|
browser.setValueSafe(wd.$("modal-settings.maputnik:mapbox_access_token"), apiKey);
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(wd.$("modal-settings.name"));
|
|
|
|
elem.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
|
|
|
|
var styleObj = helper.getStyleStore(browser);
|
|
|
|
browser.waitUntil(function() {
|
|
|
|
return styleObj.metadata["maputnik:mapbox_access_token"] == apiKey;
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-10-30 20:37:56 +01:00
|
|
|
it("maptiler access token", function() {
|
2018-01-10 14:19:34 +01:00
|
|
|
var apiKey = "testing123";
|
|
|
|
browser.setValueSafe(wd.$("modal-settings.maputnik:openmaptiles_access_token"), apiKey);
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(wd.$("modal-settings.name"));
|
|
|
|
elem.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
|
|
|
|
var styleObj = helper.getStyleStore(browser);
|
|
|
|
assert.equal(styleObj.metadata["maputnik:openmaptiles_access_token"], apiKey);
|
|
|
|
})
|
|
|
|
|
2018-10-30 20:37:56 +01:00
|
|
|
it("thunderforest access token", function() {
|
|
|
|
var apiKey = "testing123";
|
|
|
|
browser.setValueSafe(wd.$("modal-settings.maputnik:thunderforest_access_token"), apiKey);
|
2019-06-08 07:19:18 +02:00
|
|
|
const elem = $(wd.$("modal-settings.name"));
|
|
|
|
elem.click();
|
2018-10-30 20:37:56 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
|
|
|
|
var styleObj = helper.getStyleStore(browser);
|
|
|
|
assert.equal(styleObj.metadata["maputnik:thunderforest_access_token"], apiKey);
|
|
|
|
})
|
|
|
|
|
2018-10-30 20:06:52 +01:00
|
|
|
it("style renderer", function() {
|
2019-06-08 07:19:18 +02:00
|
|
|
const selector = $(wd.$("modal-settings.maputnik:renderer"));
|
|
|
|
selector.selectByAttribute('value', "ol");
|
|
|
|
const elem = $(wd.$("modal-settings.name"));
|
|
|
|
elem.click();
|
2018-01-10 14:19:34 +01:00
|
|
|
browser.flushReactUpdates();
|
|
|
|
|
|
|
|
var styleObj = 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")
|
|
|
|
})
|
|
|
|
})
|