feat(api/web): 实现API请求签名验证功能并优化测试环境配置
refactor(db): 重构查询条件类到query目录下 test: 添加登录流程测试脚本和测试数据 chore: 添加crypto-js依赖用于签名验证 ci: 配置测试环境数据库和端口设置
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { test, expect } from '@playwright/test'
|
||||
|
||||
test.describe('登录签名测试', () => {
|
||||
test('登录功能应该正常工作', async ({ page }) => {
|
||||
page.on('console', msg => {
|
||||
console.log('BROWSER CONSOLE:', msg.type(), msg.text())
|
||||
})
|
||||
|
||||
page.on('pageerror', error => {
|
||||
console.error('PAGE ERROR:', error.message)
|
||||
})
|
||||
|
||||
page.on('requestfailed', request => {
|
||||
console.error('REQUEST FAILED:', request.url(), request.failure()?.errorText)
|
||||
})
|
||||
|
||||
await page.goto('/login')
|
||||
|
||||
await page.fill('input[placeholder="请输入用户名"]', 'admin')
|
||||
await page.fill('input[placeholder="请输入密码"]', 'admin123')
|
||||
|
||||
await page.click('button:has-text("登录")')
|
||||
|
||||
await page.waitForURL('**/dashboard', { timeout: 10000 })
|
||||
|
||||
console.log('Current URL after login:', page.url())
|
||||
|
||||
const token = await page.evaluate(() => localStorage.getItem('token'))
|
||||
console.log('Token in localStorage:', token ? 'exists' : 'not found')
|
||||
|
||||
expect(page.url()).toContain('/dashboard')
|
||||
expect(token).toBeTruthy()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user