airboardgame/cypress/integration/board.spec.js

81 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-07-04 14:38:15 +02:00
describe("Board interactions", () => {
beforeEach(() => {
cy.viewport(1000, 600);
cy.visit("/");
2021-04-18 14:53:42 +02:00
cy.contains("0 Test game", { timeout: 10000 }).parent().find("img").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",
"matrix(1, 0, 0, 1, 0, -200)"
);
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
});
it("Pan board with middle click", () => {
cy.get(".board")
.trigger("pointerdown", {
button: 1,
clientX: 100,
clientY: 100,
2020-12-06 13:54:18 +01:00
pointerId: 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,
})
.trigger("pointerup", {
2020-07-04 14:38:15 +02:00
force: true,
2020-12-06 13:54:18 +01:00
pointerId: 1,
isPrimary: true,
2020-07-04 14:38:15 +02:00
});
cy.get(".board-pane").should(
"have.css",
"transform",
"matrix(1, 0, 0, 1, 100, -100)"
2020-07-04 14:38:15 +02:00
);
});
it("Pan board with left click and altKey ", () => {
cy.get(".board")
.trigger("pointerdown", {
button: 0,
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,
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,
isPrimary: true,
2020-07-04 14:38:15 +02:00
});
cy.get(".board-pane").should(
"have.css",
"transform",
"matrix(1, 0, 0, 1, 100, -100)"
2020-07-04 14:38:15 +02:00
);
});
});