mirror of
https://github.com/maputnik/editor.git
synced 2026-01-06 13:30:03 +00:00
Improve drivers (#856)
Co-authored-by: shelly_goldblit <shelly_goldblit@dell.com> Co-authored-by: HarelM <harel.mazor@gmail.com>
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { v1 as uuid } from "uuid";
|
||||
import CypressWrapperDriver from "./cypress-wrapper-driver";
|
||||
import MaputnikCypressHelper from "./maputnik-cypress-helper";
|
||||
|
||||
export default class ModalDriver {
|
||||
private helper = new CypressWrapperDriver();
|
||||
private helper = new MaputnikCypressHelper();
|
||||
|
||||
public when = {
|
||||
fillLayers: (opts: {type: string, layer?: string, id?: string}) => {
|
||||
fillLayers: (opts: { type: string; layer?: string; id?: string }) => {
|
||||
// Having logic in test code is an anti pattern.
|
||||
// This should be splitted to multiple single responsibility functions
|
||||
let type = opts.type;
|
||||
let layer = opts.layer;
|
||||
let id;
|
||||
@@ -14,29 +16,25 @@ export default class ModalDriver {
|
||||
} else {
|
||||
id = `${type}:${uuid()}`;
|
||||
}
|
||||
|
||||
this.helper.get.element("add-layer.layer-type.select").select(type);
|
||||
this.helper.get.element("add-layer.layer-id.input").type(id);
|
||||
this.helper.when.selectOption("add-layer.layer-type.select", type);
|
||||
this.helper.when.type("add-layer.layer-id.input", id);
|
||||
|
||||
if (layer) {
|
||||
this.helper.when.within(() => {
|
||||
this.helper.get.elementByClassOrType("input").type(layer!);
|
||||
}, "add-layer.layer-source-block")
|
||||
this.helper.get.element("input").type(layer!);
|
||||
}, "add-layer.layer-source-block");
|
||||
}
|
||||
this.helper.when.click("add-layer");
|
||||
|
||||
|
||||
return id;
|
||||
},
|
||||
|
||||
open: () => {
|
||||
this.helper.when.click("layer-list:add-layer");
|
||||
|
||||
this.helper.get.element("modal:add-layer").should("exist");
|
||||
this.helper.get.element("modal:add-layer").should("be.visible");
|
||||
},
|
||||
|
||||
close: (key: string) => {
|
||||
this.helper.when.waitUntil(() => this.helper.get.element(key));
|
||||
this.helper.when.click(key + ".close-modal");
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user