more login page tests

pull/3066/head
Patrick Burns 2024-04-07 16:09:22 -05:00
rodzic e1f75906ee
commit 8ade6979df
1 zmienionych plików z 63 dodań i 0 usunięć

Wyświetl plik

@ -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");
});
});