|
@@ -1,4 +1,5 @@
|
|
|
// import { describe, it } from 'node:test';
|
|
|
+import { mockLoginFail, mockLoginSuccess } from '../support/mock/handlers/user';
|
|
|
import LoginPage from '../support/pageObjects/LoginPage';
|
|
|
// import "cypress";
|
|
|
|
|
@@ -6,19 +7,31 @@ describe('Login Page', () => {
|
|
|
const loginPage = new LoginPage();
|
|
|
|
|
|
beforeEach(() => {
|
|
|
+ // loginPage.visit();
|
|
|
+ // loginPage.getUsernameInput().should('be.visible');
|
|
|
+ // loginPage.getPasswordInput().should('be.visible');
|
|
|
+ // loginPage.getSubmitButton().should('be.visible');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should successfully log in with correct credentials', () => {
|
|
|
+ mockLoginSuccess();
|
|
|
loginPage.visit();
|
|
|
loginPage.getUsernameInput().should('be.visible');
|
|
|
loginPage.getPasswordInput().should('be.visible');
|
|
|
loginPage.getSubmitButton().should('be.visible');
|
|
|
- });
|
|
|
-
|
|
|
- it('should successfully log in with correct credentials', () => {
|
|
|
loginPage.login('admin', '123456');
|
|
|
+ cy.wait('@loginSuccess');
|
|
|
cy.contains('登录成功').should('be.visible', { timeout: 10000 });
|
|
|
});
|
|
|
|
|
|
it('should show an error message for incorrect credentials', () => {
|
|
|
+ mockLoginFail();
|
|
|
+ loginPage.visit();
|
|
|
+ loginPage.getUsernameInput().should('be.visible');
|
|
|
+ loginPage.getPasswordInput().should('be.visible');
|
|
|
+ loginPage.getSubmitButton().should('be.visible');
|
|
|
loginPage.login('wronguser', 'wrongpassword');
|
|
|
+ cy.wait('@loginFail');
|
|
|
cy.contains('登录失败').should('be.visible', { timeout: 10000 });
|
|
|
});
|
|
|
});
|