registration.cy.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // eslint-disable-next-line @typescript-eslint/triple-slash-reference
  2. /// <reference path="../support/index.d.ts" />
  3. import { adminUser } from '../support/e2e';
  4. // These tests assume the following defaults:
  5. // 1. No users exist in the database or that the test admin user is an admin
  6. // 2. Language is set to English
  7. // 3. The default role for new users is 'pending'
  8. describe('Registration and Login', () => {
  9. // Wait for 2 seconds after all tests to fix an issue with Cypress's video recording missing the last few frames
  10. after(() => {
  11. // eslint-disable-next-line cypress/no-unnecessary-waiting
  12. cy.wait(2000);
  13. });
  14. beforeEach(() => {
  15. cy.visit('/');
  16. });
  17. it('should register a new user as pending', () => {
  18. const userName = `Test User - ${Date.now()}`;
  19. const userEmail = `cypress-${Date.now()}@example.com`;
  20. // Toggle from sign in to sign up
  21. cy.contains('Sign up').click();
  22. // Fill out the form
  23. cy.get('input[autocomplete="name"]').type(userName);
  24. cy.get('input[autocomplete="email"]').type(userEmail);
  25. cy.get('input[type="password"]').type('password');
  26. // Submit the form
  27. cy.get('button[type="submit"]').click();
  28. // Wait until the user is redirected to the home page
  29. cy.contains(userName);
  30. // Expect the user to be pending
  31. cy.contains('Check Again');
  32. });
  33. it('can login with the admin user', () => {
  34. // Fill out the form
  35. cy.get('input[autocomplete="email"]').type(adminUser.email);
  36. cy.get('input[type="password"]').type(adminUser.password);
  37. // Submit the form
  38. cy.get('button[type="submit"]').click();
  39. // Wait until the user is redirected to the home page
  40. cy.contains(adminUser.name);
  41. // Dismiss the changelog dialog if it is visible
  42. cy.getAllLocalStorage().then((ls) => {
  43. if (!ls['version']) {
  44. cy.get('button').contains("Okay, Let's Go!").click();
  45. }
  46. });
  47. });
  48. });