airboardgame/cypress/integration/session.spec.js

87 lines
1.8 KiB
JavaScript
Raw Normal View History

describe("Session management", () => {
2021-05-13 21:06:38 +02:00
beforeEach(() => {
cy.viewport(1000, 600);
cy.intercept(
{
method: "GET",
url: "/airboardgame/store/game*",
},
// eslint-disable-next-line quotes
"[]"
);
2021-05-24 15:20:31 +02:00
2021-05-13 21:06:38 +02:00
cy.visit("/");
2021-05-24 15:20:31 +02:00
2022-03-27 20:20:32 +02:00
cy.contains("0 Test game", { timeout: 10000 })
.parent()
.find(".img-wrapper")
.click();
2021-05-13 21:06:38 +02:00
// Way board loading
cy.get(".board-pane", { timeout: 10000 }).should(
"have.css",
"transform",
2022-04-02 13:48:10 +02:00
"matrix(0.48, 0, 0, 0.48, -11693, -11917)"
2021-05-13 21:06:38 +02:00
);
cy.get(".item")
.first()
.children()
.first()
.should("have.css", "transform", "none");
});
2021-05-24 15:20:31 +02:00
it("should autosave session", () => {
2021-05-13 21:06:38 +02:00
cy.get("img[src='/game_assets/JC.jpg']")
.parents(".item")
.parent()
.should("have.css", "transform", "matrix(1, 0, 0, 1, 420, 400)");
2021-08-07 17:13:00 +02:00
cy.wait(300);
2021-05-13 21:06:38 +02:00
// Select card
cy.get("img[src='/game_assets/JC.jpg']")
.parents(".item")
.click(500, 500, { force: true });
cy.intercept(
{
method: "POST",
url: "/airboardgame/store/session/*",
},
// eslint-disable-next-line quotes
(req) => {
expect(req.body).to.have.property("items");
req.reply(req.body);
}
).as("postSession");
2021-08-07 17:13:00 +02:00
cy.wait(300);
2021-05-24 15:20:31 +02:00
2021-05-13 21:06:38 +02:00
cy.get("img[src='/game_assets/JC.jpg']")
.parents(".item")
.trigger("pointerdown", {
2022-06-11 15:28:37 +02:00
buttons: 1,
2021-05-13 21:06:38 +02:00
clientX: 430,
clientY: 430,
force: true,
pointerId: 1,
});
cy.get("img[src='/game_assets/JC.jpg']")
.parents(".item")
.trigger("pointermove", {
2022-06-11 15:28:37 +02:00
buttons: 1,
2021-05-13 21:06:38 +02:00
clientX: 530,
clientY: 530,
force: true,
pointerId: 1,
})
.trigger("pointerup", {
force: true,
pointerId: 1,
});
cy.wait("@postSession");
});
});