homepage.spec.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. describe("Homepage", () => {
  2. beforeEach(() => {
  3. cy.intercept(
  4. {
  5. method: "GET",
  6. url: "/airboardgame/store/game*",
  7. },
  8. "[]"
  9. );
  10. cy.visit("/games");
  11. });
  12. it("should show all available games by default", () => {
  13. cy.contains("0 Test game").should("be.visible");
  14. cy.contains("1 Performance game to test strange things and other").should(
  15. "be.visible"
  16. );
  17. });
  18. it("should show both default games if searching for 'test' string", () => {
  19. cy.get('input[name="game-search"').type("test");
  20. cy.contains("0 Test game").should("be.visible");
  21. cy.contains("1 Performance game to test strange things and other").should(
  22. "be.visible"
  23. );
  24. });
  25. it("should show only game 1 if searching for 'Performance' string", () => {
  26. cy.get('input[name="game-search"').type("Performance");
  27. cy.contains("0 Test game").should("not.exist");
  28. cy.contains("1 Performance game to test strange things and other").should(
  29. "be.visible"
  30. );
  31. });
  32. it("should not show any game for 'thisisafancystring' string", () => {
  33. cy.get('input[name="game-search"').type("thisisafancystring");
  34. cy.contains("0 Test game").should("not.exist");
  35. cy.contains("1 Performance game to test strange things and other").should(
  36. "not.exist"
  37. );
  38. });
  39. it("should not show unpublished game by default", () => {
  40. cy.contains("2 Unpublished game").should("not.exist");
  41. });
  42. it("should only show the Perf game (1-9+ playerds) and not the Test game (2-4 players) when selecting 5-9 players range", () => {
  43. // WARNING: this test is very fragile
  44. // By clicking on .rc-slider, it will put the slider min value at the middle of the interval (5 for a 1-9 interval),
  45. // which is what we need for this test.
  46. // Be aware that, if the total range of the slide decreases (1-5) for example, clicking on it will trigger a min value of
  47. // 3 (instead of the current 5), and this test will fail, as "0 Test game" will now appear.
  48. // I didn't find any better way yet, as there is no pre-defined markup to be able to precisely select a given step of the slider.
  49. cy.get(".rc-slider:first").click();
  50. cy.contains("0 Test game").should("not.exist");
  51. cy.contains("1 Performance game to test strange things and other").should(
  52. "be.visible"
  53. );
  54. });
  55. });