






























@@ -9,6 +9,19 @@ import {
99import type { v2 } from "./protocol.js";
10101111describe("Codex plugin activation", () => {
12+function expectActivationResult(
13+result: Awaited<ReturnType<typeof ensureCodexPluginActivation>>,
14+expected: { ok: boolean; reason: string; installAttempted: boolean },
15+) {
16+expect(result.ok).toBe(expected.ok);
17+expect(result.reason).toBe(expected.reason);
18+expect(result.installAttempted).toBe(expected.installAttempted);
19+}
20+21+function expectBooleanParam(params: unknown, key: string, expected: boolean) {
22+expect((params as Record<string, unknown> | undefined)?.[key]).toBe(expected);
23+}
24+1225it("skips plugin/install when the migrated plugin is already active", async () => {
1326const calls: string[] = [];
1427const result = await ensureCodexPluginActivation({
@@ -22,7 +35,7 @@ describe("Codex plugin activation", () => {
2235},
2336});
243725-expect(result).toMatchObject({
38+expectActivationResult(result, {
2639ok: true,
2740reason: "already_active",
2841installAttempted: false,
@@ -60,7 +73,7 @@ describe("Codex plugin activation", () => {
6073},
6174});
627563-expect(result).toMatchObject({
76+expectActivationResult(result, {
6477ok: true,
6578reason: "already_active",
6679installAttempted: true,
@@ -97,7 +110,7 @@ describe("Codex plugin activation", () => {
97110return { authPolicy: "ON_USE", appsNeedingAuth: [] } satisfies v2.PluginInstallResponse;
98111}
99112if (method === "skills/list") {
100-expect(params).toMatchObject({ forceReload: true });
113+expectBooleanParam(params, "forceReload", true);
101114return { data: [] } satisfies v2.SkillsListResponse;
102115}
103116if (method === "hooks/list") {
@@ -107,14 +120,14 @@ describe("Codex plugin activation", () => {
107120return {};
108121}
109122if (method === "app/list") {
110-expect(params).toMatchObject({ forceRefetch: true });
123+expectBooleanParam(params, "forceRefetch", true);
111124return { data: [], nextCursor: null } satisfies v2.AppsListResponse;
112125}
113126throw new Error(`unexpected request ${method}`);
114127},
115128});
116129117-expect(result).toMatchObject({
130+expectActivationResult(result, {
118131ok: true,
119132reason: "installed",
120133installAttempted: true,
@@ -162,7 +175,7 @@ describe("Codex plugin activation", () => {
162175},
163176});
164177165-expect(result).toMatchObject({
178+expectActivationResult(result, {
166179ok: true,
167180reason: "installed",
168181installAttempted: true,
@@ -192,7 +205,7 @@ describe("Codex plugin activation", () => {
192205},
193206});
194207195-expect(result).toMatchObject({
208+expectActivationResult(result, {
196209ok: false,
197210reason: "refresh_failed",
198211installAttempted: true,
@@ -241,7 +254,7 @@ describe("Codex plugin activation", () => {
241254},
242255});
243256244-expect(result).toMatchObject({
257+expectActivationResult(result, {
245258ok: true,
246259reason: "installed",
247260installAttempted: true,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。