airboardgame/cypress/integration/item.spec.js

101 lines
2.6 KiB
JavaScript
Raw Normal View History

2020-07-04 14:38:15 +02:00
describe("Item interactions", () => {
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 move item", () => {
cy.get("img[src='/games/JC.jpg']")
.parents(".item")
.parent()
.should("have.css", "transform", "matrix(1, 0, 0, 1, 420, 400)");
2020-07-04 14:38:15 +02:00
// Select card
cy.get("img[src='/games/JC.jpg']")
.parents(".item")
.click(500, 500, { force: true });
2020-12-06 13:54:18 +01:00
cy.get("img[src='/games/JC.jpg']").parents(".item").trigger("pointerdown", {
button: 0,
clientX: 430,
clientY: 430,
force: true,
pointerId: 1,
});
2020-07-04 14:38:15 +02:00
cy.get("img[src='/games/JC.jpg']")
.parents(".item")
.trigger("pointermove", {
2020-12-06 13:54:18 +01:00
button: 0,
clientX: 530,
clientY: 530,
2020-07-04 14:38:15 +02:00
force: true,
2020-12-06 13:54:18 +01:00
pointerId: 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,
2020-07-04 14:38:15 +02:00
});
cy.get("img[src='/games/JC.jpg']")
.parents(".item")
.parent()
2020-12-06 13:54:18 +01:00
.should("have.css", "transform", "matrix(1, 0, 0, 1, 520, 500)");
2020-07-04 14:38:15 +02:00
});
it("should flip item", () => {
// Check before
cy.get("img[src='/games/JC.jpg']")
.siblings("img[src='/games/Red_back.jpg']")
.should("have.css", "opacity", "0");
cy.get("img[src='/games/JC.jpg']").should("have.css", "opacity", "1");
// Select card
cy.get("img[src='/games/JC.jpg']")
.parents(".item")
.click(500, 500, { force: true });
2020-11-14 21:29:47 +01:00
cy.get('[title = "Reveal/Hide"]').click({ force: true });
2020-07-04 14:38:15 +02:00
// Check after
cy.get("img[src='/games/JC.jpg']").should("have.css", "opacity", "0");
cy.get("img[src='/games/JC.jpg']")
.siblings("img[src='/games/Red_back.jpg']")
.should("have.css", "opacity", "1");
});
it("should tap item", () => {
// Check before
cy.get("img[src='/games/JC.jpg']")
.parents(".item")
.should("have.css", "transform", "matrix(1, 0, 0, 1, 0, 0)");
// Select card
cy.get("img[src='/games/JC.jpg']")
.parents(".item")
.click(500, 500, { force: true });
2020-11-14 21:29:47 +01:00
cy.get('[title = "Tap/Untap"]').click({ force: true });
2020-07-04 14:38:15 +02:00
// Check after
cy.get("img[src='/games/JC.jpg']")
.parents(".item")
.should(
"have.css",
"transform",
"matrix(6.12323e-17, 1, -1, 6.12323e-17, 0, 0)"
);
});
});