more login page tests
这个提交包含在:
父节点
e1f75906ee
当前提交
8ade6979df
共有 1 个文件被更改,包括 63 次插入 和 0 次删除
|
|
@ -19,4 +19,67 @@ describe("Login Test", () => {
|
||||||
cy.url().should("include", "/dashboard");
|
cy.url().should("include", "/dashboard");
|
||||||
cy.contains("Logout");
|
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");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用