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(); }); });