IO-2327 tests for login and reset password

This commit is contained in:
swtmply
2023-06-14 04:17:25 +08:00
parent 058edca573
commit 8f8fdf7548
9 changed files with 96 additions and 7 deletions

View File

@@ -0,0 +1,32 @@
describe("logging in to the application", () => {
// FIXME error message
it("logs in the using wrong credentials", () => {
cy.login("fakeusername", "veryverylongpassword_123@#");
cy.contains("invalid-email");
});
it("logs in the using wrong password", () => {
cy.login("john@imex.dev", "veryverylongpassword_123@#");
cy.contains(
"The email and password combination you provided is incorrect."
);
});
it("logs in a non-existent credentials", () => {
cy.login("franz@imex.dev", "veryverylongpassword_123@#");
cy.contains("A user with this email does not exist.");
});
// TODO create disabled account
// it("logs in with a disabled account", () => {
// cy.login("disabled_account@imex.dev", "john123");
// cy.contains("User account disabled.");
// });
// TODO log in to the application
// it("logs in the using the right credentials", () => {
// cy.login("john@imex.dev", "john123");
// cy.url().should('include', '/manage')
// });
});

View File

@@ -0,0 +1,17 @@
describe("resetting user password", () => {
it("resets forgotten password with an invalid email", () => {
cy.passwordReset("franz");
cy.contains("Email is not a valid email");
});
// FIXME error message
it("resets forgotten password with a user that does not exist", () => {
cy.passwordReset("franz@imex.dev");
cy.contains("user-not-found");
});
it("resets forgotten password using the right credentials", () => {
cy.passwordReset("john@imex.dev");
cy.contains("A password reset link has been sent to you.");
});
});

View File

@@ -22,4 +22,30 @@
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
Cypress.Commands.add("goToSignInPage", () => {
cy.visit("/");
cy.contains("Sign In").click();
});
Cypress.Commands.add("login", (username, password) => {
cy.goToSignInPage();
cy.get('[data-cy="username"]').type(username);
cy.get('[data-cy="password"]').type(password);
cy.get('[data-cy="sign-in-button"]', { timeout: 2000 }).click();
});
Cypress.Commands.add("passwordReset", (email) => {
cy.goToSignInPage();
cy.get('[data-cy="reset-password"]').click();
cy.get('[data-cy="reset-password-email-input"]').type(email);
cy.get('[data-cy="reset-password-button"]').click();
});
Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false;
});

View File

@@ -14,7 +14,7 @@
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
import "./commands";
// Alternatively you can use CommonJS syntax:
// require('./commands')
// require('./commands')