maputnik/test/functional/helper.js

87 lines
2.4 KiB
JavaScript
Raw Normal View History

2018-01-10 14:19:34 +01:00
var wd = require("../wd-helper");
var {v1: uuid} = require('uuid');
2018-01-10 14:19:34 +01:00
var geoServer = require("../geojson-server");
var testNetwork = process.env.TEST_NETWORK || "localhost";
var geoserver;
2018-01-10 14:19:34 +01:00
module.exports = {
startGeoserver: function(done) {
geoserver = geoServer.listen(9002, "0.0.0.0", done);
},
stopGeoserver: function(done) {
geoserver.close(done);
geoserver = undefined;
},
2018-01-10 14:19:34 +01:00
getStyleUrl: function(styles) {
var port = geoserver.address().port;
return "http://"+testNetwork+":"+port+"/styles/empty/"+styles.join(",");
2018-01-10 14:19:34 +01:00
},
getGeoServerUrl: function(urlPath) {
var port = geoserver.address().port;
return "http://"+testNetwork+":"+port+"/"+urlPath;
2018-01-10 14:19:34 +01:00
},
getStyleStore: async function(browser) {
return await browser.executeAsync(function(done) {
2018-01-10 14:19:34 +01:00
window.debug.get("maputnik", "styleStore").latestStyle(done);
});
2018-01-10 14:19:34 +01:00
},
getRevisionStore: async function(browser) {
var result = await browser.execute(function() {
2018-01-10 14:19:34 +01:00
var rs = window.debug.get("maputnik", "revisionStore")
return {
currentIdx: rs.currentIdx,
revisions: rs.revisions
};
})
return result.value;
},
modal: {
addLayer: {
open: async function() {
const selector = await $(wd.$('layer-list:add-layer'));
await selector.click();
2018-01-10 14:19:34 +01:00
// Wait for events
await browser.flushReactUpdates();
2018-01-10 14:19:34 +01:00
const elem = await $(wd.$('modal:add-layer'));
await elem.waitForExist();
await elem.isDisplayed();
await elem.isDisplayedInViewport();
2018-01-10 14:19:34 +01:00
// Wait for events
await browser.flushReactUpdates();
2018-01-10 14:19:34 +01:00
},
fill: async function(opts) {
2018-01-10 14:19:34 +01:00
var type = opts.type;
var layer = opts.layer;
var id;
if(opts.id) {
id = opts.id
}
else {
id = type+":"+uuid();
}
const selectBox = await $(wd.$("add-layer.layer-type", "select"));
await selectBox.selectByAttribute('value', type);
await browser.flushReactUpdates();
2018-01-10 14:19:34 +01:00
await browser.setValueSafe(wd.$("add-layer.layer-id", "input"), id);
2018-01-10 14:19:34 +01:00
if(layer) {
await browser.setValueSafe(wd.$("add-layer.layer-source-block", "input"), layer);
2018-01-10 14:19:34 +01:00
}
await browser.flushReactUpdates();
const elem_addLayer = await $(wd.$("add-layer"));
await elem_addLayer.click();
2018-01-10 14:19:34 +01:00
return id;
}
}
}
}