4ec1a3f4dd
refactor(测试): 重构用户数据加载逻辑以支持数组格式 fix(数据库): 修正数据库连接配置和凭证 test: 添加新的导航和用户管理测试场景 docs: 生成UAT测试报告和最终报告 ci: 更新Woodpecker CI配置和测试命令 build: 添加application-test.yml配置文件 chore: 清理旧的测试场景文件
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { LoginPage } from '../../novalon-manage-web/e2e/pages/LoginPage';
|
|
|
|
test.describe('UAT - 登录功能验证', () => {
|
|
let loginPage: LoginPage;
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
loginPage = new LoginPage(page);
|
|
await loginPage.goto();
|
|
});
|
|
|
|
test('使用admin账户登录', async ({ page }) => {
|
|
await loginPage.login('admin', 'admin123');
|
|
|
|
const currentUrl = page.url();
|
|
console.log('登录后URL:', currentUrl);
|
|
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
const isLoggedIn = await loginPage.isLoggedIn();
|
|
expect(isLoggedIn).toBeTruthy();
|
|
});
|
|
|
|
test('登录失败显示错误信息', async ({ page }) => {
|
|
await loginPage.goto();
|
|
|
|
const usernameInput = page.locator('input[placeholder="请输入用户名"]');
|
|
const passwordInput = page.locator('input[placeholder="请输入密码"]');
|
|
const loginButton = page.locator('button:has-text("登录")');
|
|
|
|
await usernameInput.fill('wronguser');
|
|
await passwordInput.fill('wrongpassword');
|
|
await loginButton.click();
|
|
|
|
await page.waitForTimeout(3000);
|
|
|
|
const currentUrl = page.url();
|
|
console.log('当前URL:', currentUrl);
|
|
|
|
const loginFailed = currentUrl.includes('/login');
|
|
console.log('登录失败:', loginFailed);
|
|
|
|
expect(loginFailed).toBeTruthy();
|
|
});
|
|
});
|