maputnik/test/functional/modals/index.js

225 lines
6.9 KiB
JavaScript
Raw Normal View History

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");
async function closeModal(wdKey) {
const selector = wd.$(wdKey);
await browser.waitUntil(async function() {
const elem = await $(selector);
return await elem.isDisplayedInViewport();
2018-01-10 14:19:34 +01:00
});
const closeBtnSelector = await $(wd.$(wdKey+".close-modal"));
await closeBtnSelector.click();
2018-01-10 14:19:34 +01:00
await browser.waitUntil(async function() {
return await browser.execute((selector) => {
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));
beforeEach(async function() {
await browser.url(config.baseUrl+"?debug");
2018-01-10 14:19:34 +01:00
const elem = await $(".maputnik-toolbar-link");
await elem.waitForExist();
await browser.flushReactUpdates();
2018-01-10 14:19:34 +01:00
const elem2 = await $(wd.$("nav:open"));
await elem2.click();
await browser.flushReactUpdates();
2018-01-10 14:19:34 +01: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
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
var styleObj = await helper.getStyleStore(browser);
2018-01-10 14:19:34 +01:00
assert.deepEqual(styleFileData, styleObj);
});
it("load from url", async function() {
2018-01-10 14:19:34 +01:00
var styleFileUrl = helper.getGeoServerUrl("example-style.json");
await browser.setValueSafe(wd.$("modal:open.url.input"), styleFileUrl);
2018-01-10 14:19:34 +01: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.
await browser.pause(300);
2018-01-10 14:19:34 +01: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() {
it("open/close", async function() {
await browser.url(config.baseUrl+"?debug");
2020-05-31 16:33:09 +02:00
const elem = await $(".maputnik-toolbar-link");
await elem.waitForExist();
await browser.flushReactUpdates();
2020-05-31 16:33:09 +02:00
await browser.keys(["?"]);
2020-05-31 16:33:09 +02:00
const modalEl = await $(wd.$("modal:shortcuts"))
assert(await modalEl.isDisplayed());
2020-05-31 16:33:09 +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() {
beforeEach(async function() {
await browser.url(config.baseUrl+"?debug");
2018-01-10 14:19:34 +01:00
const elem = await $(".maputnik-toolbar-link");
await elem.waitForExist();
await browser.flushReactUpdates();
2018-01-10 14:19:34 +01:00
const elem2 = await $(wd.$("nav:export"));
await elem2.click();
await browser.flushReactUpdates();
2018-01-10 14:19:34 +01: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() {
it("toggle", async function() {
await browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
2018-01-10 14:19:34 +01:00
"geojson:example"
]));
await browser.acceptAlert();
2018-01-10 14:19:34 +01: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() {
beforeEach(async function() {
await browser.url(config.baseUrl+"?debug");
2018-01-10 14:19:34 +01:00
const elem = await $(".maputnik-toolbar-link");
await elem.waitForExist();
await browser.flushReactUpdates();
2018-01-10 14:19:34 +01:00
const elem2 = await $(wd.$("nav:settings"));
await elem2.click();
await browser.flushReactUpdates();
2018-01-10 14:19:34 +01: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
var styleObj = await helper.getStyleStore(browser);
2018-01-10 14:19:34 +01:00
assert.equal(styleObj.name, "foobar");
})
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
var styleObj = await helper.getStyleStore(browser);
2018-01-10 14:19:34 +01:00
assert.equal(styleObj.owner, "foobar");
})
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
var styleObj = await helper.getStyleStore(browser);
2018-01-10 14:19:34 +01:00
assert.equal(styleObj.sprite, "http://example.com");
})
it("glyphs url", async function() {
2018-01-10 14:19:34 +01:00
var glyphsUrl = "http://example.com/{fontstack}/{range}.pbf"
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
var styleObj = await helper.getStyleStore(browser);
2018-01-10 14:19:34 +01:00
assert.equal(styleObj.glyphs, glyphsUrl);
})
it("maptiler access token", async function() {
2018-01-10 14:19:34 +01:00
var apiKey = "testing123";
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
var styleObj = await helper.getStyleStore(browser);
2018-01-10 14:19:34 +01:00
assert.equal(styleObj.metadata["maputnik:openmaptiles_access_token"], apiKey);
})
it("thunderforest access token", async function() {
2018-10-30 20:37:56 +01:00
var apiKey = "testing123";
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
var styleObj = await helper.getStyleStore(browser);
2018-10-30 20:37:56 +01:00
assert.equal(styleObj.metadata["maputnik:thunderforest_access_token"], apiKey);
})
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
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")
})
})