返回 DeepSeek-Reasonix
community.test.ts
根目录 / workers / crash-report / src / community.test.ts
1 import { describe, expect, it } from "vitest";
2 import type { User } from "./auth";
3 import { renderCommunity } from "./community";
4 import type { PackageRow } from "./registry/types";
5
6 const admin: User = {
7 id: 1,
8 email: "admin@example.test",
9 role: "admin",
10 created_at: "2026-07-22T00:00:00.000Z",
11 approved_at: "2026-07-22T00:00:00.000Z",
12 };
13
14 const pending: PackageRow = {
15 id: 42,
16 kind: "plugin",
17 scope_handle: "publisher",
18 name: "devkit",
19 slug: "publisher/devkit",
20 summary: "Developer tools",
21 description: "",
22 source: "https://github.com/o/r",
23 install_kind: "plugin",
24 homepage: "",
25 repo_url: "https://github.com/o/r",
26 tags: "tool",
27 latest_version: "2.7.1",
28 install_count: 0,
29 star_count: 0,
30 verified: 0,
31 status: "pending",
32 publisher_id: 7,
33 created_at: "2026-07-22T00:00:00.000Z",
34 updated_at: "2026-07-22T00:30:00.000Z",
35 };
36
37 describe("renderCommunity", () => {
38 it("binds moderation forms to the rendered package revision", () => {
39 const html = renderCommunity(admin, [pending], "pending");
40
41 expect(html).toContain('name="expectedVersion" value="2.7.1"');
42 expect(html).toContain('name="expectedUpdatedAt" value="2026-07-22T00:30:00.000Z"');
43 expect(html).toContain('name="expectedStatus" value="pending"');
44 });
45 });
46
46 lines TYPESCRIPT