airboardgame/cypress/integration/selection.spec.js

73 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-07-04 14:38:15 +02:00
describe("Selection action", () => {
beforeEach(() => {
cy.viewport(1000, 600);
cy.visit("/");
2020-12-20 15:33:40 +01:00
cy.contains("0 Test game").parent().find("img").click();
2020-07-04 14:38:15 +02:00
// Way board loading
cy.get(".board-pane").should(
"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
});
it("should select multiple items with left click ", () => {
cy.get(".board")
.trigger("pointerdown", {
2020-11-21 21:03:58 +01:00
x: 350,
y: 500,
button: 0,
2020-11-21 21:03:58 +01:00
clientX: 350,
clientY: 500,
isPrimary: true,
2020-07-04 14:38:15 +02:00
})
.trigger("pointermove", {
2020-11-21 21:03:58 +01:00
x: 600,
y: 150,
button: 0,
2020-11-21 21:03:58 +01:00
clientX: 600,
clientY: 150,
2020-07-04 14:38:15 +02:00
force: true,
isPrimary: true,
2020-07-04 14:38:15 +02:00
});
2020-11-21 21:03:58 +01:00
cy.get(".selector").should(
"have.css",
"transform",
"matrix(1, 0, 0, 1, 350, 350)"
);
cy.get(".board").trigger("pointermove", {
2020-11-21 21:03:58 +01:00
x: 601,
y: 151,
button: 0,
2020-11-21 21:03:58 +01:00
clientX: 601,
clientY: 151,
isPrimary: true,
2020-11-21 21:03:58 +01:00
force: true,
});
cy.wait(500);
cy.get(".board").trigger("pointerup", {
isPrimary: true,
2020-11-21 21:03:58 +01:00
force: true,
});
2020-07-04 14:38:15 +02:00
cy.get("img[src='/games/AS.jpg']")
.parents(".item")
2020-11-21 21:03:58 +01:00
.should("have.class", "selected");
2020-07-04 14:38:15 +02:00
cy.get("img[src='/games/JC.jpg']")
.parents(".item")
2020-11-21 21:03:58 +01:00
.should("have.class", "selected");
cy.get("img[src='/games/BH.jpg']")
.parents(".item")
.should("have.class", "selected");
2020-07-04 14:38:15 +02:00
});
});