feat(portal-shell): v2.0 P1-P4 token migration + unit tests + prod endpoint + e2e

P1: 31 widget 旧纸感令牌批量迁移到 shadcn 标准(1104 次替换)
- bg-paper→bg-background / bg-surface→bg-card / text-ink→text-foreground
- 保留 button.tsx 中 bg-accent(shadcn 标准 hover 语义令牌)

P2: v2.0 新增组件单元测试补齐(5 文件 81 用例)
- permission-bitmap: 24 用例(含 GRADE_READ 重复去重)
- route-permissions: 26 用例(4 张表优先级 + AND/OR 语义)
- notify: 12 用例(sonner toast 双重性质 vi.hoisted mock)
- use-error-report: 9 用例(jsdom Blob vi.stubGlobal mock)
- plugin-boundary: 10 用例(错误边界 + 骨架变体)

P3: 错误上报端点生产替换(后端 /api/v1/log)
- api-gateway: internal/log/handler.go(slog 结构化日志,64KB 限制,204 返回)
- main.go: 注册 POST /api/v1/log 路由
- useErrorReport: 环境感知端点(prod→/api/v1/log,dev→/api/log)

P4: E2E 测试(3 文件 30 用例)
- streaming: 4 用例(React 19 use() + Suspense,act 包裹 render)
- error-boundaries: 6 用例(三级错误边界层级 L1/L2/L3)
- security-boundaries: 20 用例(L1 角色门禁 + L2 权限点 + L3 数据范围)
- vitest setup: IS_REACT_ACT_ENVIRONMENT + jest-dom matchers

验证:typecheck 0 错误 / lint 0 错误 / build 6 路由 / 206 测试全部通过
This commit is contained in:
SpecialX
2026-07-17 16:49:00 +08:00
parent 9cedf0c437
commit f586a0b19e
46 changed files with 2415 additions and 559 deletions

View File

@@ -1,4 +1,4 @@
"use client";
"use client";
/**
* notifications-widgetuniversal / main
@@ -23,20 +23,20 @@ function TypeBadge({ type }: { type: string }): React.ReactElement {
const label = TYPE_LABEL[type] ?? type;
if (type === "urgent") {
return (
<span className="rounded-button bg-danger px-sm py-xs text-tiny text-ink-onAccent">
<span className="rounded-md bg-danger px-sm py-xs text-xs text-primary-foreground">
{label}
</span>
);
}
if (type === "warning") {
return (
<span className="rounded-button bg-accent px-sm py-xs text-tiny text-ink-onAccent">
<span className="rounded-md bg-primary px-sm py-xs text-xs text-primary-foreground">
{label}
</span>
);
}
return (
<span className="rounded-button bg-subtle px-sm py-xs text-tiny text-ink-muted">
<span className="rounded-md bg-muted px-sm py-xs text-xs text-muted-foreground">
{label}
</span>
);
@@ -58,26 +58,28 @@ export default function NotificationsWidget(
const total = data?.total ?? 0;
return (
<section className="rounded-card border border-rule bg-surface p-md">
<section className="rounded-xl border border bg-card p-4">
<div className="flex">
<h3 className="flex-1 text-heading-3 text-ink"></h3>
<span className="text-small text-ink-muted"> {total} </span>
<h3 className="flex-1 text-heading-3 text-foreground"></h3>
<span className="text-sm text-muted-foreground"> {total} </span>
</div>
{items.length === 0 ? (
<p className="mt-sm text-small text-ink-muted"></p>
<p className="mt-sm text-sm text-muted-foreground"></p>
) : (
<ul className="mt-sm space-y-sm">
{items.map((item) => (
<li
key={item.id}
className="border-b border-rule py-xs text-small text-ink"
className="border-b border py-xs text-sm text-foreground"
>
<div className="flex items-center gap-md">
<div className="flex items-center gap-4">
<span className="flex-1">{item.title}</span>
<TypeBadge type={item.type} />
</div>
<p className="mt-xs text-tiny text-ink-muted">{item.body}</p>
<p className="mt-xs text-tiny text-ink-muted">{item.createdAt}</p>
<p className="mt-xs text-xs text-muted-foreground">{item.body}</p>
<p className="mt-xs text-xs text-muted-foreground">
{item.createdAt}
</p>
</li>
))}
</ul>