Skip to content

Instantly share code, notes, and snippets.

@DannyFeliz
Last active November 25, 2020 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DannyFeliz/84fe82b055ac838de332ed3827a5e574 to your computer and use it in GitHub Desktop.
Save DannyFeliz/84fe82b055ac838de332ed3827a5e574 to your computer and use it in GitHub Desktop.
/// <reference types="cypress" />
import LoginPageObject from "./page/LoginPageObject";
describe('Login Page', () => {
const invalidEmail = "invalid@email";
const validEmail = "fake@email.com";
const loginPage = new LoginPageObject();
beforeEach(() => {
cy.visit("https://memod.com");
cy.contains('Sign In').click();
})
describe("Email", () => {
it('should show an error if the user is not found', () => {
loginPage.getEmailInput().type(validEmail);
loginPage.getPasswordInput().type("somepassword");
cy.get('form > div > div > button').click();
cy.get('.notification-content').should("have.text", "No User Found");
})
it('should show an error if the email is invalid', () => {
loginPage.getEmailInput().type(invalidEmail).focus();
cy.get("label[for='email'] > span").should("have.text", "(Please enter a valid email address.)");
})
it('should show an error if the email is not privided', () => {
loginPage.getEmailInput().type(" ").focus();
cy.get("label[for='email'] > span").should("have.text", "(The email field is required.)");
})
})
describe("Password", () => {
it('should show an error if the password is not privided', () => {
loginPage.getPasswordInput().type(" ").focus();
cy.get("label[for='password'] > span").should("have.text", "(The password field is required.)");
})
it('should show an error if the password is too short', () => {
loginPage.getPasswordInput().type("abc").focus();
cy.get("label[for='password'] > span").should("have.text", "(password is not valid.)");
})
})
describe("Sign in Button", () => {
it('should disable the sign in button if there is an error', () => {
loginPage.getEmailInput().type(invalidEmail).focus();
cy.get('form > div > div > button').should("be.disabled");
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment