-
Notifications
You must be signed in to change notification settings - Fork 0
add test spec for login odule #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mahima-bh
wants to merge
4
commits into
master
Choose a base branch
from
GT-1/mahima
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "APP_EMAIL": "test@test.com", | ||
| "APP_PASSWORD": "test123" | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| const { getRandomEmail, getRandomString } = require("../../../utilites/helper"); | ||
| const forgotPassword_PO = require("../../page_objects/forgotPassword_PO"); | ||
| const loginPagePO = require("../../page_objects/login_PO"); | ||
|
|
||
| describe("authentication module", function () { | ||
| beforeEach(function () { | ||
| loginPagePO.visitLoginPage(); | ||
| }); | ||
| it("URL should be https://frontendbootcamp.proshore.eu/accounts/login", function () { | ||
| cy.url().should( | ||
| "eq", | ||
| "https://frontendbootcamp.proshore.eu/accounts/login" | ||
| ); | ||
| }); | ||
| it("verify valid login", function () { | ||
| cy.login(); | ||
| }); | ||
|
|
||
| it(" should not be submit with empty details", function () { | ||
| loginPagePO.clickOnLoginButton(); | ||
| loginPagePO.elements.loginBtn().should("be.disabled"); | ||
| }); | ||
|
|
||
| it("Verify the validation msg when login is attempted with less than 6 letter password", function () { | ||
| const randomGenerateEmail = getRandomEmail(); | ||
| const randomGenerateName = getRandomString(3); | ||
| loginPagePO.typeEmail(randomGenerateEmail); | ||
| loginPagePO.typePassword(randomGenerateName); | ||
| loginPagePO.clickOnLoginButton(); | ||
| loginPagePO.verifyPasswordLengthErrorMessage(); | ||
| }); | ||
| it("Verify the login process with invalidLogin credentials ", function () { | ||
| const randomGenerateEmail = getRandomEmail(); | ||
| const randomGenerateName = getRandomString(7); | ||
| loginPagePO.typeEmail(randomGenerateEmail); | ||
| loginPagePO.typePassword(randomGenerateName); | ||
| loginPagePO.clickOnLoginButton(); | ||
| loginPagePO.verifyInvalidCredentialAlertMessage(); | ||
| }); | ||
| it("Password should be visible by clicking the toggle_icon eye-slash", function () { | ||
| const randomGenerateName = getRandomString(5); | ||
| loginPagePO.typePassword(randomGenerateName); | ||
| cy.get("#showPassword").click(); | ||
| cy.get("#password").invoke("attr", "type").should("eq", "text"); | ||
| }); | ||
| it("It should not be submit with empty email address", function () { | ||
| const randomGenerateName = getRandomString(6); | ||
| loginPagePO.typePassword(randomGenerateName); | ||
| loginPagePO.clickOnLoginButton(); | ||
| loginPagePO.elements.loginBtn().should("be.disabled"); | ||
| }); | ||
| it("Should not be submit with empty password", function () { | ||
| const randomGenerateEmail = getRandomEmail(); | ||
| loginPagePO.typeEmail(randomGenerateEmail); | ||
| loginPagePO.clickOnLoginButton(); | ||
| loginPagePO.elements.loginBtn().should("be.disabled"); | ||
| }); | ||
| it("It should not be submit with correct email address and incorrect password", function () { | ||
| const randomGenerateName = getRandomString(7); | ||
| loginPagePO.typeEmail(Cypress.env("APP_EMAIL")); | ||
| loginPagePO.typePassword(randomGenerateName); | ||
| loginPagePO.clickOnLoginButton(); | ||
| loginPagePO.verifyInvalidCredentialAlertMessage(); | ||
| }); | ||
|
|
||
| it("It should not be submit with incorrect email address and correct password", function () { | ||
| const randomGenerateEmail = getRandomEmail(); | ||
| loginPagePO.typeEmail(randomGenerateEmail); | ||
| loginPagePO.typePassword(Cypress.env("APP_PASSWORD")); | ||
| loginPagePO.clickOnLoginButton(); | ||
| loginPagePO.verifyInvalidCredentialAlertMessage(); | ||
| }); | ||
| it("clicked on forget password redirected to forget password page", function () { | ||
| forgotPassword_PO.visitForgotPasswordPage(); | ||
| }); | ||
|
|
||
| it(" should be submit with empty emailaddress", function () { | ||
mahima-bh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| forgotPassword_PO.visitForgotPasswordPage(); | ||
| forgotPassword_PO.clickOnGetResetLink(); | ||
| // forgotPassword_PO.verifyEmptyCredentialAlertMessage(); | ||
|
|
||
| // cy.on(".window:alert", (txt) => { | ||
| // expect(txt).to.contains("Please fill out the field"); | ||
| }); | ||
|
|
||
| it(" should be submit with incorrect email address in reset password page", function () { | ||
| forgotPassword_PO.visitForgotPasswordPage(); | ||
| const randomGenerateEmail = getRandomEmail(); | ||
| forgotPassword_PO.typeEmail(randomGenerateEmail); | ||
| forgotPassword_PO.clickOnGetResetLink(); | ||
| forgotPassword_PO.verifyInvalidCredentialAlertMessage(); | ||
| }); | ||
| it(" should be submit with correct email address in reset password page", function () { | ||
| forgotPassword_PO.visitForgotPasswordPage(); | ||
| forgotPassword_PO.typeEmail("test@test.com"); | ||
| forgotPassword_PO.clickOnGetResetLink(); | ||
| forgotPassword_PO.getResetLink(); | ||
|
|
||
| // cy.get(".form-heading-title").should("have.text", "Check your mail"); | ||
| }); | ||
|
|
||
| it("Access admin portal via url", function () { | ||
| cy.url().should( | ||
| "eq", | ||
| "https://frontendbootcamp.proshore.eu/accounts/login" | ||
| ); | ||
|
|
||
| cy.location("origin").then((URL) => { | ||
| expect(URL).to.eq("https://frontendbootcamp.proshore.eu"); | ||
| cy.visit(URL + "/tracker"); | ||
| cy.get(".form-heading-title").should("have.text", "Log in"); | ||
| cy.url().should( | ||
| "eq", | ||
| "https://frontendbootcamp.proshore.eu/accounts/login?next=/tracker" | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| class forgotPassword_PO { | ||
| elements = { | ||
| emailInput: () => cy.get("#email.form-control"), | ||
| getResetLinkButton: () => cy.get('[data-cy="forgetPasswordResetButton"]'), | ||
| loginError: () => cy.get(".alert-message"), | ||
| getResetLink: () => cy.get(".form-heading-title"), | ||
| validationError: () => cy.on(".window:alert"), | ||
| }; | ||
| visitForgotPasswordPage() { | ||
| cy.get(".forgot-password").click(); | ||
| cy.url().should( | ||
| "eq", | ||
| "https://frontendbootcamp.proshore.eu/accounts/password-forgot" | ||
| ); | ||
| } | ||
|
|
||
| typeEmail(email) { | ||
| this.elements.emailInput().type(email); | ||
| } | ||
| clickOnGetResetLink() { | ||
| this.elements.getResetLinkButton().click(); | ||
| } | ||
| verifyInvalidCredentialAlertMessage() { | ||
| this.elements | ||
| .loginError() | ||
| .should("have.text", "User with given email address not found"); | ||
| } | ||
| getResetLink() { | ||
| this.elements.getResetLink().click(); | ||
| } | ||
| // verifyEmptyCredentialAlertMessage(){ | ||
| // this.elements.validationError. | ||
| // // on(".window:alert", (txt) => { | ||
| // should("contains","Please fill out the field"); | ||
| // } | ||
| } | ||
|
|
||
| module.exports = new forgotPassword_PO(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| class login_PO { | ||
| elements = { | ||
| emailInput: () => cy.get('[data-cy="emailInputField"]').eq(0), | ||
| passwordInput: () => cy.get('[data-cy="emailInputField"]').eq(1), | ||
| loginBtn: () => cy.get('[data-cy="loginButton"]'), | ||
| loginError: () => cy.get(".alert-message"), | ||
| validationError: () => cy.get(".text-danger"), | ||
| }; | ||
| visitLoginPage() { | ||
| cy.visit("https://frontendbootcamp.proshore.eu/accounts/login"); | ||
| cy.url().should( | ||
| "eq", | ||
| "https://frontendbootcamp.proshore.eu/accounts/login" | ||
| ); | ||
| } | ||
|
|
||
| typeEmail(email) { | ||
| this.elements.emailInput().type(email); | ||
| } | ||
| typePassword(password) { | ||
| this.elements.passwordInput().type(password); | ||
| } | ||
| clickOnLoginButton() { | ||
| this.elements.loginBtn().click({ force: true }); | ||
| } | ||
|
|
||
| verifyPasswordLengthErrorMessage() { | ||
| this.elements | ||
| .validationError() | ||
| .should("have.text", "Password length must be at least 6 characters."); | ||
| } | ||
| verifyInvalidCredentialAlertMessage() { | ||
| this.elements | ||
| .loginError() | ||
| .should("have.text", "Please enter valid email or password."); | ||
| } | ||
| } | ||
|
|
||
| module.exports = new login_PO(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| function getRandomString(length = 5) { | ||
| const characters = | ||
| "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
| let result = ""; | ||
| for (let i = 0; i < length; i++) { | ||
| result += characters.charAt(Math.floor(Math.random() * characters.length)); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| function getRandomEmail() { | ||
| const randomString = getRandomString(); | ||
| return randomString + "@gmail.com"; | ||
| } | ||
|
|
||
| module.exports = { | ||
| getRandomString, | ||
| getRandomEmail, | ||
| }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.