mirror of
https://github.com/maputnik/editor.git
synced 2026-06-14 11:17:26 +00:00
Refactor driver for E2E (#843)
This is basically the content of #841 with the code review changes and relevant fixes to tests/driver code to pass the tests. CC: @ShellyDCMS After this we should lint the project and add the lint to the CI to make sure it doesn't break. --------- Co-authored-by: ShellyDCMS <60476837+ShellyDCMS@users.noreply.github.com> Co-authored-by: shelly_goldblit <shelly_goldblit@dell.com>
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import querystring from 'querystring'
|
||||
interface DebugStore {
|
||||
[namespace: string]: {
|
||||
[key: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const debugStore = {};
|
||||
const debugStore: DebugStore = {};
|
||||
|
||||
function enabled() {
|
||||
const qs = querystring.parse(window.location.search.slice(1));
|
||||
if(qs.hasOwnProperty("debug")) {
|
||||
return !!qs.debug.match(/^(|1|true)$/);
|
||||
const qs = new URL(window.location.href).searchParams;
|
||||
const debugQs = qs.get("debug");
|
||||
if(debugQs) {
|
||||
return !!debugQs.match(/^(|1|true)$/);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
@@ -17,7 +21,7 @@ function genErr() {
|
||||
return new Error("Debug not enabled, enable by appending '?debug' to your query string");
|
||||
}
|
||||
|
||||
function set(namespace, key, value) {
|
||||
function set(namespace: keyof DebugStore, key: string, value: any) {
|
||||
if(!enabled()) {
|
||||
throw genErr();
|
||||
}
|
||||
@@ -25,7 +29,7 @@ function set(namespace, key, value) {
|
||||
debugStore[namespace][key] = value;
|
||||
}
|
||||
|
||||
function get(namespace, key) {
|
||||
function get(namespace: keyof DebugStore, key: string) {
|
||||
if(!enabled()) {
|
||||
throw genErr();
|
||||
}
|
||||
@@ -38,7 +42,7 @@ const mod = {
|
||||
enabled,
|
||||
get,
|
||||
set
|
||||
}
|
||||
};
|
||||
|
||||
window.debug = mod;
|
||||
(window as any).debug = mod;
|
||||
export default mod;
|
||||
@@ -3,6 +3,7 @@ export default class ZoomControl {
|
||||
this._map = map;
|
||||
this._container = document.createElement('div');
|
||||
this._container.className = 'maplibregl-ctrl maplibregl-ctrl-group maplibregl-ctrl-zoom';
|
||||
this._container.setAttribute("data-wd-key", "maplibre:ctrl-zoom");
|
||||
this._container.innerHTML = `
|
||||
Zoom: <span></span>
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user