| 123456789101112131415161718192021222324252627282930313233343536373839 |
- // import { describe, it } from 'node:test';
- import { mockLoginFail, mockLoginSuccess } from '../support/mock/handlers/user';
- import { mockGetSoftwareInfoSuccess } from '../support/mock/handlers/system';
- import { mockI18nSuccess } from '../support/mock/handlers/i18n';
- import LoginPage from '../support/pageObjects/LoginPage';
- // import "cypress";
- describe('Login Page', () => {
- const loginPage = new LoginPage();
- beforeEach(() => {
- // Mock software_info API to prevent 404 errors
- mockGetSoftwareInfoSuccess();
- // Mock i18n translation file
- mockI18nSuccess('zh_CN');
- });
- 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');
- 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 });
- });
- });
|