feat(ops): ECR-007 行为分析与 ECR-008 内容运营后台
ci / h5 (push) Canceled after 0s
ci / api (push) Canceled after 0s
ci / ess-docs (push) Canceled after 0s

落地埋点 ingest/数据看板、首页宫格 CMS 与测评上下架;含账号引导、问答流式与免责声明去重,以及 review P1 审计同事务修复。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-07 02:26:16 +08:00
co-authored by Cursor
parent 7e9023f0a8
commit 7ab9add5dd
132 changed files with 8276 additions and 491 deletions
+56 -7
View File
@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'
/** Admin Phase A: login → users → detail grant → audit (API mocked). */
/** Admin ops console: login → dashboard → users → detail grant → audit (API mocked). */
test('admin login users grant and audit with mocked API', async ({ page }) => {
const userId = '11111111-1111-1111-1111-111111111111'
let granted = false
@@ -29,10 +29,39 @@ test('admin login users grant and audit with mocked API', async ({ page }) => {
await ok({ ok: true })
return
}
if (url.includes('/stats')) {
await ok({
users_total: 1,
membership_active: granted ? 1 : 0,
orders_today: 0,
paid_cents_today: 0,
ask_replies_today: 0,
profiles_total: 1,
reports_total: 2,
series: [
{ day: '2026-08-01', new_users: 0, orders: 1, paid_cents: 990, ask_replies: 2 },
{ day: '2026-08-02', new_users: 1, orders: 0, paid_cents: 0, ask_replies: 1 },
{ day: '2026-08-03', new_users: 0, orders: 2, paid_cents: 1980, ask_replies: 3 },
{ day: '2026-08-04', new_users: 0, orders: 0, paid_cents: 0, ask_replies: 0 },
{ day: '2026-08-05', new_users: 0, orders: 1, paid_cents: 2500, ask_replies: 4 },
{ day: '2026-08-06', new_users: 0, orders: 0, paid_cents: 0, ask_replies: 2 },
{ day: '2026-08-07', new_users: 0, orders: 1, paid_cents: 990, ask_replies: 1 },
],
reports_by_type: [
{ type: 'portrait', count: 1 },
{ type: 'star', count: 1 },
],
})
return
}
if (url.endsWith('/me') || url.includes('/me?')) {
await ok({ id: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', username: 'admin' })
return
}
if (url.includes(`/users/${userId}/ask-quota/grant`) && method === 'POST') {
await ok({ ok: true, ask_paid_quota_left: 40 })
return
}
if (url.includes(`/users/${userId}/membership/grant`) && method === 'POST') {
granted = true
await ok({ ok: true })
@@ -42,13 +71,18 @@ test('admin login users grant and audit with mocked API', async ({ page }) => {
await ok({
id: userId,
status: 'active',
phone: '13800000000',
nickname: '测试用户',
ask_paid_quota_left: 0,
created_at: '2026-08-01T00:00:00Z',
profiles: [{ id: 'p1', relation: 'self', display_name: '我' }],
profiles: [{ id: 'p1', relation: 'self', display_name: '我', birth_date: '1990-01-01' }],
reports: [],
membership: {
active: granted,
plan: granted ? 'month' : undefined,
status: granted ? 'active' : 'none',
expires_at: granted ? '2026-09-01T00:00:00Z' : undefined,
ask_quota_left: granted ? 100 : 0,
},
recent_orders: [],
})
@@ -56,7 +90,19 @@ test('admin login users grant and audit with mocked API', async ({ page }) => {
}
if (url.includes('/users') && method === 'GET') {
await ok({
items: [{ id: userId, status: 'active', created_at: '2026-08-01T00:00:00Z' }],
items: [
{
id: userId,
status: 'active',
phone: '13800000000',
nickname: '测试用户',
ask_paid_quota_left: 0,
profile_count: 1,
membership_active: granted,
membership_plan: granted ? 'month' : null,
created_at: '2026-08-01T00:00:00Z',
},
],
})
return
}
@@ -86,17 +132,20 @@ test('admin login users grant and audit with mocked API', async ({ page }) => {
})
await page.goto('/login')
await expect(page.getByRole('heading', { name: '运营后台' })).toBeVisible()
await expect(page.getByRole('heading', { name: '愈心谷' })).toBeVisible()
await page.locator('input[type="password"]').fill('change-me')
await page.getByRole('button', { name: '登录' }).click()
await expect(page.getByRole('heading', { name: '概览' })).toBeVisible()
await page.getByRole('link', { name: '用户', exact: true }).click()
await expect(page.getByRole('heading', { name: '用户' })).toBeVisible()
await expect(page.getByText(userId)).toBeVisible()
await page.getByRole('link', { name: userId }).click()
await expect(page.getByText('测试用户')).toBeVisible()
await page.getByRole('link', { name: '测试用户' }).click()
await expect(page.getByRole('heading', { name: '用户详情' })).toBeVisible()
await page.getByRole('button', { name: '授予 / 延长' }).click()
await expect(page.getByText('已授予')).toBeVisible()
await expect(page.getByText('会员已授予')).toBeVisible()
await page.getByRole('link', { name: '审计' }).click()
await expect(page.getByRole('heading', { name: '审计' })).toBeVisible()