airboardgame/cypress/integration/board.spec.js

148 lines
3.1 KiB
JavaScript
Raw Normal View History

2020-07-04 14:38:15 +02:00
describe("Board interactions", () => {
beforeEach(() => {
cy.viewport(1000, 600);
2021-04-22 21:43:07 +02:00
cy.intercept(
{
method: "GET",
url: "/airboardgame/store/game*",
},
"[]"
);
2020-07-04 14:38:15 +02:00
cy.visit("/");
2022-03-27 20:20:32 +02:00
cy.contains("0 Test game", { timeout: 10000 })
.parent()
.find(".img-wrapper")
.click();
2020-07-04 14:38:15 +02:00
// Way board loading
2021-04-18 14:53:42 +02:00
cy.get(".board-pane", { timeout: 10000 }).should(
2020-07-04 14:38:15 +02:00
"have.css",
"transform",
2022-04-02 13:48:10 +02:00
"matrix(0.48, 0, 0, 0.48, -11693, -11917)"
2020-07-04 14:38:15 +02:00
);
2020-11-07 20:40:54 +01:00
cy.get(".item")
.first()
.children()
.first()
.should("have.css", "transform", "none");
2020-07-04 14:38:15 +02:00
});
2020-10-28 13:42:11 +01:00
it("Load game page", () => {
2020-12-20 15:33:40 +01:00
cy.contains("0 Test game");
2021-02-18 23:08:49 +01:00
cy.get("[alt=Save]");
2021-03-13 23:13:32 +01:00
cy.get("[alt='Help & info']");
2020-10-28 13:42:11 +01:00
cy.get("[title='Add an item']");
2020-07-04 14:38:15 +02:00
});
2022-06-20 20:11:39 +02:00
it("Pan board with left click when move first", () => {
2020-07-04 14:38:15 +02:00
cy.get(".board")
.trigger("pointerdown", {
2022-06-20 20:11:39 +02:00
force: true,
clientX: 100,
clientY: 100,
2020-12-06 13:54:18 +01:00
pointerId: 1,
2022-06-20 20:11:39 +02:00
buttons: 1,
})
.trigger("pointermove", {
2020-07-04 14:38:15 +02:00
clientX: 200,
clientY: 200,
2020-12-06 13:54:18 +01:00
pointerId: 1,
2020-07-04 14:38:15 +02:00
force: true,
2022-06-20 20:11:39 +02:00
buttons: 1,
2020-07-04 14:38:15 +02:00
})
.trigger("pointerup", {
2020-07-04 14:38:15 +02:00
force: true,
2020-12-06 13:54:18 +01:00
pointerId: 1,
isPrimary: true,
2022-06-20 20:11:39 +02:00
buttons: 1,
2020-07-04 14:38:15 +02:00
});
cy.get(".board-pane").should(
"have.css",
"transform",
2022-04-02 13:48:10 +02:00
"matrix(0.48, 0, 0, 0.48, -11593, -11817)"
2020-07-04 14:38:15 +02:00
);
});
2022-06-20 20:11:39 +02:00
it("Pan board with left click and meta when in select mode", () => {
cy.get("[title^='Switch to select mode']").click({
scrollBehavior: false,
});
2020-07-04 14:38:15 +02:00
cy.get(".board")
.trigger("pointerdown", {
2022-06-11 15:28:37 +02:00
buttons: 1,
2020-07-04 14:38:15 +02:00
clientX: 100,
clientY: 100,
2020-12-06 13:54:18 +01:00
pointerId: 1,
altKey: true,
})
.trigger("pointermove", {
2020-12-06 13:54:18 +01:00
button: 0,
clientX: 200,
clientY: 200,
2020-12-06 13:54:18 +01:00
pointerId: 1,
altKey: true,
2022-06-11 15:28:37 +02:00
buttons: 1,
2020-07-04 14:38:15 +02:00
force: true,
})
.trigger("pointerup", {
2020-07-04 14:38:15 +02:00
force: true,
2020-12-06 13:54:18 +01:00
pointerId: 1,
2022-06-11 15:28:37 +02:00
buttons: 1,
isPrimary: true,
2020-07-04 14:38:15 +02:00
});
cy.get(".board-pane").should(
"have.css",
"transform",
2022-04-02 13:48:10 +02:00
"matrix(0.48, 0, 0, 0.48, -11593, -11817)"
2020-07-04 14:38:15 +02:00
);
});
2021-04-22 21:43:07 +02:00
2022-06-20 20:11:39 +02:00
it("Pan board with middle click when select is main action", () => {
cy.get("[title^='Switch to select mode']").click({
scrollBehavior: false,
});
2021-04-22 21:43:07 +02:00
cy.get(".board")
.trigger("pointerdown", {
button: 0,
x: 150,
y: 200,
clientX: 150,
clientY: 200,
2021-04-22 21:43:07 +02:00
pointerId: 1,
force: true,
scrollBehavior: false,
2022-06-20 20:11:39 +02:00
buttons: 4,
2021-04-22 21:43:07 +02:00
})
.trigger("pointermove", {
button: 0,
x: 400,
y: 400,
clientX: 400,
clientY: 400,
pointerId: 1,
force: true,
2022-06-20 20:11:39 +02:00
buttons: 4,
scrollBehavior: false,
2021-04-22 21:43:07 +02:00
})
.trigger("pointerup", {
force: true,
pointerId: 1,
isPrimary: true,
scrollBehavior: false,
2022-06-20 20:11:39 +02:00
buttons: 4,
2021-04-22 21:43:07 +02:00
});
cy.get(".board-pane").should(
"have.css",
"transform",
2022-04-02 13:48:10 +02:00
"matrix(0.48, 0, 0, 0.48, -11443, -11717)"
2021-04-22 21:43:07 +02:00
);
});
2020-07-04 14:38:15 +02:00
});
2021-04-18 22:16:33 +02:00
/* TODO
- Change main navigation
- show/Hide menu
*/