mirror of
https://github.com/magicbug/Cloudlog
synced 2024-11-21 15:56:30 +00:00
more login page tests
This commit is contained in:
parent
e1f75906ee
commit
8ade6979df
@ -19,4 +19,67 @@ describe("Login Test", () => {
|
||||
cy.url().should("include", "/dashboard");
|
||||
cy.contains("Logout");
|
||||
});
|
||||
|
||||
it("Should display an error message on failed login", () => {
|
||||
// Define the username and password
|
||||
const username = "m0abc";
|
||||
const password = "wrongpassword";
|
||||
|
||||
// Visit the login page
|
||||
cy.visit("/index.php/user/login");
|
||||
|
||||
// Type the username and password into the input fields
|
||||
cy.get('input[name="user_name"]').type(username);
|
||||
cy.get('input[name="user_password"]').type(password);
|
||||
|
||||
// Click the login button
|
||||
cy.get('button[type="submit"]').click();
|
||||
|
||||
// Check if the login was successful
|
||||
// This could be checking/ for a URL change, looking for a log out button, etc.
|
||||
cy.url().should("include", "/login");
|
||||
|
||||
cy.get("body")
|
||||
.contains("Incorrect username or password!")
|
||||
.should("be.visible")
|
||||
.and("have.class", "alert-danger");
|
||||
});
|
||||
|
||||
it("Should display an error message on empty fields", () => {
|
||||
// Visit the login page
|
||||
cy.visit("/index.php/user/login");
|
||||
|
||||
// Click the login button
|
||||
cy.get('button[type="submit"]').click();
|
||||
|
||||
// Check if the login was successful
|
||||
// This could be checking/ for a URL change, looking for a log out button, etc.
|
||||
cy.url().should("include", "/login");
|
||||
|
||||
cy.get("body")
|
||||
.contains(`The "Username" field is required.`)
|
||||
.should("be.visible")
|
||||
.parent()
|
||||
.and("have.class", "alert-danger");
|
||||
|
||||
cy.get("body")
|
||||
.contains(`The "Password" field is required.`)
|
||||
.should("be.visible")
|
||||
.parent()
|
||||
.and("have.class", "alert-danger");
|
||||
});
|
||||
|
||||
it("Should display and open the forgot password page", () => {
|
||||
// Visit the login page
|
||||
cy.visit("/index.php/user/login");
|
||||
|
||||
// Click the "Forgot Password?" link
|
||||
cy.get("a")
|
||||
.contains("Forgot your password?")
|
||||
.should("be.visible")
|
||||
.click();
|
||||
|
||||
// Check if the correct page has been loaded by checking the URL
|
||||
cy.url().should("include", "/forgot_password");
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user