test(cache): 修复CacheConfigTest边界值测试
- 修改 shouldVerifyCacheManager_withMaximumIntegerTtl 为 shouldVerifyCacheManager_withMaximumAllowedTtl - 使用正确的最大TTL值(10080分钟,7天)而不是 Integer.MAX_VALUE - 新增 shouldThrowException_whenTtlExceedsMaximum 测试验证边界检查 - 所有1266个测试用例通过 - 覆盖率: 指令81.89%, 行88.48%, 分支51.55% docs: 添加项目状态报告 - 生成 PROJECT_STATUS_REPORT.md 详细记录项目当前状态 - 包含质量指标、已完成功能、待办事项和技术债务
This commit is contained in:
91
frontend/e2e-admin/tests/admin.spec.ts
Normal file
91
frontend/e2e-admin/tests/admin.spec.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
import { test, expect } from '@playwright/test'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
const evidenceDir = process.env.E2E_EVIDENCE_DIR
|
||||
? path.resolve(process.env.E2E_EVIDENCE_DIR)
|
||||
: path.resolve(__dirname, '../../../evidence/run-unknown')
|
||||
|
||||
const ensureDir = (dir: string) => {
|
||||
fs.mkdirSync(dir, { recursive: true })
|
||||
}
|
||||
|
||||
const appendLog = (filePath: string, line: string) => {
|
||||
ensureDir(path.dirname(filePath))
|
||||
fs.appendFileSync(filePath, `${line}\n`, 'utf8')
|
||||
}
|
||||
|
||||
const consoleLogPath = path.join(evidenceDir, 'e2e/console.log')
|
||||
const networkLogPath = path.join(evidenceDir, 'e2e/network.log')
|
||||
|
||||
const logConsole = (type: string, text: string) => {
|
||||
appendLog(consoleLogPath, `[${new Date().toISOString()}] ${type}: ${text}`)
|
||||
}
|
||||
|
||||
const logNetwork = (line: string) => {
|
||||
appendLog(networkLogPath, `[${new Date().toISOString()}] ${line}`)
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
page.on('console', (msg) => logConsole(msg.type(), msg.text()))
|
||||
page.on('pageerror', (err) => logConsole('pageerror', err.message))
|
||||
page.on('requestfailed', (req) => {
|
||||
logNetwork(`requestfailed ${req.method()} ${req.url()} ${req.failure()?.errorText ?? ''}`)
|
||||
})
|
||||
page.on('response', (res) => {
|
||||
const url = res.url()
|
||||
if (url.includes('/api/')) {
|
||||
logNetwork(`response ${res.status()} ${res.request().method()} ${url}`)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
test.describe.serial('Admin E2E (real backend)', () => {
|
||||
test('dashboard renders without demo banner', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
await expect(page.getByRole('heading', { name: '运营概览' })).toBeVisible()
|
||||
await expect(page.getByText('演示模式')).toHaveCount(0)
|
||||
|
||||
const screenshotPath = path.join(evidenceDir, 'e2e/screenshots/dashboard.png')
|
||||
ensureDir(path.dirname(screenshotPath))
|
||||
await page.screenshot({ path: screenshotPath, fullPage: true })
|
||||
})
|
||||
|
||||
test('activity users list reflects backend response', async ({ page }) => {
|
||||
await page.goto('/users')
|
||||
await page.locator('[data-test="tab-activity"]').click()
|
||||
|
||||
const response = await page.waitForResponse((res) =>
|
||||
res.url().includes('/api/v1/me/invited-friends') && res.request().method() === 'GET'
|
||||
)
|
||||
|
||||
let payload: any = {}
|
||||
try {
|
||||
payload = await response.json()
|
||||
} catch {
|
||||
payload = {}
|
||||
}
|
||||
const data = Array.isArray(payload?.data) ? payload.data : []
|
||||
|
||||
if (data.length > 0) {
|
||||
await expect(page.locator('[data-test="activity-users-list"]')).toBeVisible()
|
||||
const rows = page.locator('[data-test="activity-user-row"]')
|
||||
await expect(rows).toHaveCount(data.length)
|
||||
} else {
|
||||
await expect(page.locator('[data-test="activity-users-empty"]')).toBeVisible()
|
||||
}
|
||||
|
||||
const screenshotPath = path.join(evidenceDir, 'e2e/screenshots/activity-users.png')
|
||||
ensureDir(path.dirname(screenshotPath))
|
||||
await page.screenshot({ path: screenshotPath, fullPage: true })
|
||||
})
|
||||
|
||||
test('forbidden page displays failure path', async ({ page }) => {
|
||||
await page.goto('/403')
|
||||
await expect(page.getByText('当前账号无权限访问该页面')).toBeVisible()
|
||||
|
||||
const screenshotPath = path.join(evidenceDir, 'e2e/screenshots/forbidden.png')
|
||||
ensureDir(path.dirname(screenshotPath))
|
||||
await page.screenshot({ path: screenshotPath, fullPage: true })
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user