diff --git a/novalon-manage-web/e2e/smoke/login-logout.spec.ts b/novalon-manage-web/e2e/smoke/login-logout.spec.ts new file mode 100644 index 0000000..e1d9833 --- /dev/null +++ b/novalon-manage-web/e2e/smoke/login-logout.spec.ts @@ -0,0 +1,38 @@ +import { test, expect } from '@playwright/test'; + +test.describe('冒烟测试 - 基础流程', () => { + test('管理员登录和登出', async ({ page }) => { + await test.step('导航到登录页面', async () => { + await page.goto('/login'); + await page.waitForLoadState('networkidle'); + }); + + await test.step('输入登录信息', async () => { + await page.fill('input[type="text"]', 'admin'); + await page.fill('input[type="password"]', 'Test@123'); + }); + + await test.step('点击登录按钮', async () => { + await page.click('button:has-text("登录")'); + await page.waitForURL(/.*dashboard/, { timeout: 10000 }); + }); + + await test.step('验证登录成功', async () => { + await expect(page).toHaveURL(/.*dashboard/); + }); + + await test.step('点击用户菜单', async () => { + await page.click('[data-testid="user-menu"]'); + await page.waitForTimeout(500); + }); + + await test.step('点击退出登录', async () => { + await page.click('text=退出登录'); + await page.waitForURL(/.*login/, { timeout: 10000 }); + }); + + await test.step('验证登出成功', async () => { + await expect(page).toHaveURL(/.*login/); + }); + }); +});