Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve drivers #856

Merged
merged 42 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9014e12
improve drivers
Dec 30, 2023
6ed08c7
modify some of the layer tests
Dec 30, 2023
ef90291
update keyboard tests
Dec 30, 2023
efc507a
fix failing test
Dec 30, 2023
0dc3f4b
fix lock file
ShellyDCMS Dec 30, 2023
085eda7
convert more tests
Dec 30, 2023
f7a945a
wip
Dec 30, 2023
666bc64
wip
Dec 30, 2023
7c8b25e
restore lock file
Dec 31, 2023
0bb0ae8
wip
Dec 31, 2023
ecfdd5f
update lock file
ShellyDCMS Dec 31, 2023
7de266c
Attemopt to fix package-lock
HarelM Dec 31, 2023
d031fc6
Fix build
HarelM Dec 31, 2023
7538e02
Try fixing build again... remove cache
HarelM Dec 31, 2023
fb41a59
Update package lock after cache npm clean
HarelM Dec 31, 2023
79b36ef
Fix lint
HarelM Dec 31, 2023
ba20193
fix failing test
Dec 31, 2023
c694237
fix some more tests
Dec 31, 2023
aa8cb8f
fix some more tests
Dec 31, 2023
138f685
fix more tests
Dec 31, 2023
ff547fc
fix some more tests
Dec 31, 2023
6aa48d6
fix some more tests
Dec 31, 2023
f5ab97d
fix failing tests
Dec 31, 2023
26bf99d
fix build
Dec 31, 2023
b4e31cc
fix test
Dec 31, 2023
27190f6
restore lock file
Dec 31, 2023
20c121d
lint
Dec 31, 2023
f7f6df7
update test utils version
ShellyDCMS Dec 31, 2023
b20c54d
move then into driver
Dec 31, 2023
d4d37e5
lint i guess
Dec 31, 2023
055d35f
fix more tests
Dec 31, 2023
c5a7005
lint
Dec 31, 2023
0ed6bb5
fix more tests
Dec 31, 2023
a94ee55
update test utils version
ShellyDCMS Dec 31, 2023
2213e74
I think all tests should be green now
Dec 31, 2023
fa2dfa7
remove left overs
Dec 31, 2023
e74382d
fix build
Dec 31, 2023
13336bf
fix failing build
Dec 31, 2023
1d938b5
review comments
Jan 1, 2024
b869905
lint
Jan 1, 2024
b74e5d4
review comments
Jan 1, 2024
6650262
remove unneeded 0 by making the key unique
HarelM Jan 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cypress/e2e/accessibility.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { then } from "@shellygo/cypress-test-utils/assertable";
HarelM marked this conversation as resolved.
Show resolved Hide resolved
import MaputnikDriver from "./maputnik-driver";

describe("accessibility", () => {
let { beforeAndAfter, when, should } = new MaputnikDriver();
let { beforeAndAfter, get, when, should } = new MaputnikDriver();
beforeAndAfter();

describe("skip links", () => {
Expand All @@ -16,6 +17,8 @@ describe("accessibility", () => {
should.beFocused(selector);
when.click(selector);
should.beFocused("skip-target-layer-list");

// then(get.skipTargetLayerList()).shouldBeFocused();
});

// This fails for some reason only in Chrome, but passes in firefox. Adding a skip here to allow merge and later on we'll decide if we want to fix this or not.
Expand All @@ -25,7 +28,7 @@ describe("accessibility", () => {
when.tab().tab();
should.beFocused(selector);
when.click(selector);
should.beFocused("skip-target-layer-editor");
then(get.skipTargetLayerEditor()).shouldBeFocused();
});

it("skip link to map view", () => {
Expand Down
28 changes: 6 additions & 22 deletions cypress/e2e/cypress-wrapper-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,21 @@ export default class CypressWrapperDriver {

public given = {
...this.helper.given,
/**
*
* @param url a url to a file, this assumes the file name is the last part of the url
* @param alias
*/
interceptGetToFile(url: string) {
let fileNameAndAlias = url.split('/').pop();
cy.intercept('GET', url, { fixture: fileNameAndAlias }).as(fileNameAndAlias!);
},

interceptAndIgnore(url: string) {
cy.intercept({ method: "GET", url }, []);
}
}
};

public get = {
...this.helper.get,
elementByClassOrType(slector: string) {
return cy.get(slector);
}
}
},
};

public when = {
...this.helper.when,
visit(address: string) {
cy.visit(address);
},
confirmAlert() {
cy.on("window:confirm", () => true);
}
}
},
};

public beforeAndAfter = this.helper.beforeAndAfter;
}
}
2 changes: 1 addition & 1 deletion cypress/e2e/keyboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe("keyboard", () => {
beforeAndAfter();
describe("shortcuts", () => {
beforeEach(() => {
given.setupInterception();
given.setupMockBackedResponses();
when.setStyle("");
});

Expand Down
111 changes: 80 additions & 31 deletions cypress/e2e/maputnik-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,59 @@ export default class MaputnikDriver {

public beforeAndAfter = () => {
beforeEach(() => {
this.given.setupInterception();
this.given.setupMockBackedResponses();
this.when.setStyle("both");
});
};

public given = {
setupInterception: () => {
this.helper.given.interceptGetToFile(SERVER_ADDRESS + "example-style.json");
this.helper.given.interceptGetToFile(SERVER_ADDRESS + "example-layer-style.json");
this.helper.given.interceptGetToFile(SERVER_ADDRESS + "geojson-style.json");
this.helper.given.interceptGetToFile(SERVER_ADDRESS + "raster-style.json");
this.helper.given.interceptGetToFile(SERVER_ADDRESS + "geojson-raster-style.json");

this.helper.given.interceptAndIgnore("*example.local/*");
this.helper.given.interceptAndIgnore("*example.com/*");
setupMockBackedResponses: () => {
this.helper.given.interceptAndMockResponse({
method: "GET",
url: "http://localhost:8888/example-style.json",
response: {
fixture: "example-style.json",
},
alias: "example-style.json",
});
this.helper.given.interceptAndMockResponse({
method: "GET",
url: "http://localhost:8888/example-layer-style.json",
response: {
fixture: "example-layer-style.json",
},
});
this.helper.given.interceptAndMockResponse({
method: "GET",
url: "http://localhost:8888/geojson-style.json",
response: {
fixture: "geojson-style.json",
},
});
this.helper.given.interceptAndMockResponse({
method: "GET",
url: "http://localhost:8888/raster-style.json",
response: {
fixture: "raster-style.json",
},
});
this.helper.given.interceptAndMockResponse({
method: "GET",
url: "http://localhost:8888/geojson-raster-style.json",
response: {
fixture: "geojson-raster-style.json",
},
});
this.helper.given.interceptAndMockResponse({
method: "GET",
url: "*example.local/*",
response: [],
});
this.helper.given.interceptAndMockResponse({
method: "GET",
url: "*example.com/*",
response: [],
});
},
};

Expand All @@ -37,29 +75,28 @@ export default class MaputnikDriver {
this.helper.when.waitForResponse("example-style.json");
},
chooseExampleFile: () => {
this.helper.get.elementByClassOrType("input[type='file']").selectFile(
"cypress/fixtures/example-style.json",
{ force: true }
);
this.helper.get
.bySelector("type", "file")
.selectFile("cypress/fixtures/example-style.json", { force: true });
},
setStyle: (
styleProperties: "geojson" | "raster" | "both" | "layer" | "",
zoom?: number
) => {
let url = "?debug";
switch (styleProperties) {
case "geojson":
url += `&style=${SERVER_ADDRESS}geojson-style.json`;
break;
case "raster":
url += `&style=${SERVER_ADDRESS}raster-style.json`;
break;
case "both":
url += `&style=${SERVER_ADDRESS}geojson-raster-style.json`;
break;
case "layer":
url += `&style=${SERVER_ADDRESS}/example-layer-style.json`;
break;
case "geojson":
url += `&style=${SERVER_ADDRESS}geojson-style.json`;
break;
case "raster":
url += `&style=${SERVER_ADDRESS}raster-style.json`;
break;
case "both":
url += `&style=${SERVER_ADDRESS}geojson-raster-style.json`;
break;
case "layer":
url += `&style=${SERVER_ADDRESS}/example-layer-style.json`;
break;
}
if (zoom) {
url += `#${zoom}/41.3805/2.1635`;
Expand Down Expand Up @@ -102,7 +139,10 @@ export default class MaputnikDriver {
},

setValue: (selector: string, text: string) => {
this.helper.get.element(selector).clear().type(text, { parseSpecialCharSequences: false });
this.helper.get
.element(selector)
.clear()
.type(text, { parseSpecialCharSequences: false });
},
};

Expand All @@ -119,12 +159,16 @@ export default class MaputnikDriver {
exampleFileUrl: () => {
return SERVER_ADDRESS + "example-style.json";
},
skipTargetLayerList: () =>
this.helper.get.element("skip-target-layer-list"),
skipTargetLayerEditor: () =>
this.helper.get.element("skip-target-layer-editor"),
};

public should = {
canvasBeFocused: () => {
this.when.within("maplibre:map", () => {
this.helper.get.elementByClassOrType("canvas").should("be.focused");
this.helper.get.element("canvas").should("be.focused");
});
},
notExist: (selector: string) => {
Expand Down Expand Up @@ -156,18 +200,23 @@ export default class MaputnikDriver {
styleStoreEqualToExampleFileData: () => {
cy.window().then((win: any) => {
const obj = this.get.styleFromWindow(win);
this.helper.given.fixture("example-style.json", "file:example-style.json").should("deep.equal", obj);
this.helper.given
.fixture("example-style.json", "file:example-style.json")
.should("deep.equal", obj);
});
},

exist: (selector: string) => {
this.helper.get.element(selector).should("exist");
},
beSelected: (selector: string, value: string) => {
this.helper.get.element(selector).find(`option[value="${value}"]`).should("be.selected");
this.helper.get
.element(selector)
.find(`option[value="${value}"]`)
.should("be.selected");
},
containText: (selector: string, text: string) => {
this.helper.get.element(selector).should("contain.text", text);
}
},
};
}
14 changes: 7 additions & 7 deletions cypress/e2e/modal-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class ModalDriver {
private helper = new CypressWrapperDriver();

public when = {
fillLayers: (opts: {type: string, layer?: string, id?: string}) => {
fillLayers: (opts: { type: string; layer?: string; id?: string }) => {
let type = opts.type;
let layer = opts.layer;
let id;
Expand All @@ -14,22 +14,22 @@ 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);
if (layer) {
this.helper.when.within(() => {
this.helper.get.elementByClassOrType("input").type(layer!);
}, "add-layer.layer-source-block")
}, "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");
},
Expand All @@ -38,5 +38,5 @@ export default class ModalDriver {
this.helper.when.waitUntil(() => this.helper.get.element(key));
this.helper.when.click(key + ".close-modal");
},
}
}
};
}
Loading
Loading