board.spec.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. describe("Board interactions", () => {
  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("Load game page", () => {
  29. cy.contains("0 Test game");
  30. cy.get("[alt=Save]");
  31. cy.get("[alt='Help & info']");
  32. cy.get("[title='Add an item']");
  33. });
  34. it("Pan board with left click when move first", () => {
  35. cy.get(".board")
  36. .trigger("pointerdown", {
  37. force: true,
  38. clientX: 100,
  39. clientY: 100,
  40. pointerId: 1,
  41. buttons: 1,
  42. })
  43. .trigger("pointermove", {
  44. clientX: 200,
  45. clientY: 200,
  46. pointerId: 1,
  47. force: true,
  48. buttons: 1,
  49. })
  50. .trigger("pointerup", {
  51. force: true,
  52. pointerId: 1,
  53. isPrimary: true,
  54. buttons: 1,
  55. });
  56. cy.get(".board-pane").should(
  57. "have.css",
  58. "transform",
  59. "matrix(0.48, 0, 0, 0.48, -11593, -11817)"
  60. );
  61. });
  62. it("Pan board with left click and meta when in select mode", () => {
  63. cy.get("[title^='Switch to select mode']").click({
  64. scrollBehavior: false,
  65. });
  66. cy.get(".board")
  67. .trigger("pointerdown", {
  68. buttons: 1,
  69. clientX: 100,
  70. clientY: 100,
  71. pointerId: 1,
  72. altKey: true,
  73. })
  74. .trigger("pointermove", {
  75. button: 0,
  76. clientX: 200,
  77. clientY: 200,
  78. pointerId: 1,
  79. altKey: true,
  80. buttons: 1,
  81. force: true,
  82. })
  83. .trigger("pointerup", {
  84. force: true,
  85. pointerId: 1,
  86. buttons: 1,
  87. isPrimary: true,
  88. });
  89. cy.get(".board-pane").should(
  90. "have.css",
  91. "transform",
  92. "matrix(0.48, 0, 0, 0.48, -11593, -11817)"
  93. );
  94. });
  95. it("Pan board with middle click when select is main action", () => {
  96. cy.get("[title^='Switch to select mode']").click({
  97. scrollBehavior: false,
  98. });
  99. cy.get(".board")
  100. .trigger("pointerdown", {
  101. button: 0,
  102. x: 150,
  103. y: 200,
  104. clientX: 150,
  105. clientY: 200,
  106. pointerId: 1,
  107. force: true,
  108. scrollBehavior: false,
  109. buttons: 4,
  110. })
  111. .trigger("pointermove", {
  112. button: 0,
  113. x: 400,
  114. y: 400,
  115. clientX: 400,
  116. clientY: 400,
  117. pointerId: 1,
  118. force: true,
  119. buttons: 4,
  120. scrollBehavior: false,
  121. })
  122. .trigger("pointerup", {
  123. force: true,
  124. pointerId: 1,
  125. isPrimary: true,
  126. scrollBehavior: false,
  127. buttons: 4,
  128. });
  129. cy.get(".board-pane").should(
  130. "have.css",
  131. "transform",
  132. "matrix(0.48, 0, 0, 0.48, -11443, -11717)"
  133. );
  134. });
  135. });
  136. /* TODO
  137. - Change main navigation
  138. - show/Hide menu
  139. */