airboardgame/cypress/integration/selection.spec.js

69 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-11-07 20:40:54 +01:00
const { transform } = require("@babel/core");
2020-07-04 14:38:15 +02:00
describe("Selection action", () => {
beforeEach(() => {
cy.viewport(1000, 600);
cy.visit("/");
2020-10-28 13:42:11 +01:00
cy.contains("Test Game").parent().find(".button").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("mousedown", {
2020-11-21 21:03:58 +01:00
x: 350,
y: 500,
clientX: 350,
clientY: 500,
2020-07-04 14:38:15 +02:00
button: 0,
})
.trigger("mousemove", {
2020-11-21 21:03:58 +01:00
x: 600,
y: 150,
clientX: 600,
clientY: 150,
2020-07-04 14:38:15 +02:00
force: true,
});
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("mousemove", {
x: 601,
y: 151,
clientX: 601,
clientY: 151,
force: true,
});
cy.wait(500);
cy.get(".board").trigger("mouseup", {
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
});
});