torrust-index-gui
torrust-index-gui copied to clipboard
Cypress E2E tests need some refactoring
Some of the E2E tests have the same code for the registration and login of users:
let registration_form: RegistrationForm;
before(() => {
registration_form = random_user_registration_data();
cy.register_as_admin_and_login(registration_form);
});
after(() => {
cy.delete_user_from_database(registration_form.username);
});
We should refactor that code so we follow Cypress's best practices. The code in the after() hook, which should be executed before any tests, because if a test fails, the after() hook will never be executed.
Also all the logic regarding the signup and login of the users could be moved to a Cypress task or to a beforeAll() hook to name a couple of options.