authentication.spec.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. describe("Studio", () => {
  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. });
  13. it("Can see Log in button", () => {
  14. cy.contains("Log in");
  15. });
  16. it("Can ask to log in", () => {
  17. cy.intercept(
  18. {
  19. method: "POST",
  20. url: "/airboardgame/auth/",
  21. },
  22. (req) => {
  23. expect(req.body).to.deep.equal({ userEmail: "test@fake.fr" });
  24. req.reply(req.body);
  25. }
  26. );
  27. cy.contains("Log in").click();
  28. cy.get(".side-panel input").type("test@fake.fr");
  29. cy.contains("Ask an authentication link").click();
  30. cy.contains("Mail sent");
  31. cy.contains("Ok").click();
  32. cy.contains("Mail sent").should("not.exist");
  33. });
  34. it("Can verify login", () => {
  35. cy.intercept(
  36. {
  37. method: "GET",
  38. url: "/airboardgame/auth/verify/titi/toto",
  39. },
  40. (req) => {
  41. req.reply("Ok");
  42. }
  43. );
  44. cy.intercept(
  45. {
  46. method: "GET",
  47. url: "/airboardgame/auth/check",
  48. },
  49. // eslint-disable-next-line quotes
  50. '{"message":"success"}'
  51. );
  52. cy.visit("/login/titi/toto");
  53. cy.contains("Studio");
  54. });
  55. });