selection.spec.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. describe("Selection action", () => {
  2. beforeEach(() => {
  3. cy.viewport(1000, 600);
  4. cy.intercept(
  5. {
  6. method: "GET",
  7. url: "/airboardgame/store/game*",
  8. },
  9. "[]"
  10. );
  11. cy.visit("/");
  12. cy.contains("0 Test game", { timeout: 10000 })
  13. .parent()
  14. .find(".img-wrapper")
  15. .click();
  16. // Way board loading
  17. cy.get(".board-pane", { timeout: 10000 }).should(
  18. "have.css",
  19. "transform",
  20. "matrix(0.48, 0, 0, 0.48, -11693, -11917)"
  21. );
  22. cy.get(".item")
  23. .first()
  24. .children()
  25. .first()
  26. .should("have.css", "transform", "none");
  27. });
  28. it("should select multiple items with right click ", () => {
  29. const posInit = {
  30. clientX: 400,
  31. clientY: 210,
  32. };
  33. cy.get(".board")
  34. .trigger("pointerdown", {
  35. buttons: 4,
  36. pointerId: 1,
  37. isPrimary: true,
  38. scrollBehavior: false,
  39. force: true,
  40. ...posInit,
  41. })
  42. .trigger("pointermove", {
  43. buttons: 4,
  44. force: true,
  45. pointerId: 1,
  46. isPrimary: true,
  47. scrollBehavior: false,
  48. clientX: posInit.clientX + 300,
  49. clientY: posInit.clientY + 250,
  50. });
  51. cy.get(".selection").should(
  52. "have.css",
  53. "transform",
  54. "matrix(1, 0, 0, 1, 499.04, 275.04)"
  55. );
  56. cy.get(".board").trigger("pointerup", {
  57. isPrimary: true,
  58. force: true,
  59. });
  60. cy.get("img[src='/game_assets/AS.jpg']")
  61. .parents(".item")
  62. .should("have.class", "selected");
  63. cy.get("img[src='/game_assets/JC.jpg']")
  64. .parents(".item")
  65. .should("have.class", "selected");
  66. cy.get("img[src='/game_assets/BH.jpg']")
  67. .parents(".item")
  68. .should("have.class", "selected");
  69. });
  70. });