Skip to content

Commit 7da9fba

Browse files
committed
test: keep survivor schema checks with the Discord plugin
1 parent 1354ba1 commit 7da9fba

4 files changed

Lines changed: 68 additions & 36 deletions

File tree

‎extensions/discord/src/config-schema.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Discord tests cover config schema plugin behavior.
2+
import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
23
import { describe, expect, it } from "vitest";
4+
import { resolveUpgradeSurvivorConfigStepsForBaseline } from "../../../scripts/e2e/lib/upgrade-survivor/config-recipe.mts";
5+
import { DiscordChannelConfigSchema } from "../channel-config-api.js";
36
import { DiscordConfigSchema } from "../config-api.js";
47

58
function expectValidDiscordConfig(config: unknown) {
@@ -21,6 +24,41 @@ function expectInvalidDiscordConfig(config: unknown) {
2124
}
2225

2326
describe("discord config schema", () => {
27+
it.each([
28+
["2026.3.13", true],
29+
["2026.7.1-2", true],
30+
["2026.7.2-beta.3", true],
31+
["2026.7.2-beta.4", false],
32+
["2026.8.1-beta.1", false],
33+
["2026.8.1-beta.2", false],
34+
["2026.8.1", false],
35+
[null, false],
36+
] as const)("preserves supported Discord DM input for baseline %s", (version, legacy) => {
37+
const step = resolveUpgradeSurvivorConfigStepsForBaseline("base", version).find(
38+
(entry) => entry.id === "channels-discord",
39+
);
40+
expect(step).toBeDefined();
41+
const discord = JSON.parse(step?.argv[3] ?? "{}");
42+
if (legacy) {
43+
expect(discord.dm).toEqual({ policy: "allowlist", allowFrom: ["111111111111111111"] });
44+
expect(discord.dmPolicy).toBeUndefined();
45+
expect(discord.allowFrom).toBeUndefined();
46+
} else {
47+
expect(discord.dm).toBeUndefined();
48+
expect(discord.dmPolicy).toBe("allowlist");
49+
expect(discord.allowFrom).toEqual(["111111111111111111"]);
50+
}
51+
// The public schema is the config-set boundary; runtime Zod preprocessing
52+
// would silently normalize the legacy specimen and miss a bad baseline cutoff.
53+
expect(
54+
validateJsonSchemaValue({
55+
schema: DiscordChannelConfigSchema.schema,
56+
cacheKey: "upgrade-survivor-discord-config",
57+
value: discord,
58+
}).ok,
59+
).toBe(!legacy);
60+
});
61+
2462
it('rejects dmPolicy="open" without allowFrom "*"', () => {
2563
const issues = expectInvalidDiscordConfig({
2664
dmPolicy: "open",

‎scripts/lib/release-version.d.mts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
type ParsedReleaseVersion = {
2+
version: string;
3+
baseVersion: string;
4+
channel: "stable" | "alpha" | "beta";
5+
year: number;
6+
month: number;
7+
patch: number;
8+
alphaNumber?: number;
9+
betaNumber?: number;
10+
correctionNumber?: number;
11+
};
12+
13+
type ReleaseTrain =
14+
| "alpha"
15+
| "beta"
16+
| "stable"
17+
| "extended-stable"
18+
| "unsupported-extended-stable-correction";
19+
20+
export function parseReleaseVersion(version: string): ParsedReleaseVersion | null;
21+
export function classifyReleaseTrain(parsedVersion: ParsedReleaseVersion): ReleaseTrain;
22+
export function collectReleaseVersionFloorErrors(
23+
version: string | ParsedReleaseVersion | null,
24+
): string[];
25+
export function compareReleaseVersions(left: string, right: string): number | null;

‎scripts/windows-cmd-helpers.d.mts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function resolvePathEnvKey(env: NodeJS.ProcessEnv): string;
2+
export function resolveWindowsSystem32Path(executableName: string, env?: NodeJS.ProcessEnv): string;
3+
export function resolveWindowsCmdExePath(env?: NodeJS.ProcessEnv): string;
4+
export function resolveWindowsPowerShellPath(env?: NodeJS.ProcessEnv): string;
5+
export function buildCmdExeCommandLine(command: string, args: readonly string[]): string;

‎test/scripts/upgrade-survivor-config-recipe.test.ts‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
import { tmpdir } from "node:os";
1313
import { join } from "node:path";
1414
import { describe, expect, it } from "vitest";
15-
import { DiscordChannelConfigSchema } from "../../extensions/discord/channel-config-api.js";
1615
import {
1716
CONFIG_COMMAND_MAX_BUFFER_BYTES,
1817
CONFIG_COMMAND_TIMEOUT_MS,
@@ -24,7 +23,6 @@ import {
2423
runUpgradeSurvivorOpenClawStep,
2524
} from "../../scripts/e2e/lib/upgrade-survivor/config-recipe.mts";
2625
import { AgentsSchema } from "../../src/config/zod-schema.agents.js";
27-
import { validateJsonSchemaValue } from "../../src/plugins/schema-validator.js";
2826

2927
const RECIPE_PATH = "scripts/e2e/lib/upgrade-survivor/config-recipe.mts";
3028
const RUN_PATH = "scripts/e2e/lib/upgrade-survivor/run.sh";
@@ -201,40 +199,6 @@ describe("upgrade survivor config recipe command resolution", () => {
201199
},
202200
);
203201

204-
it.each([
205-
["2026.3.13", true],
206-
["2026.7.1-2", true],
207-
["2026.7.2-beta.3", true],
208-
["2026.7.2-beta.4", false],
209-
["2026.8.1-beta.1", false],
210-
["2026.8.1-beta.2", false],
211-
["2026.8.1", false],
212-
[null, false],
213-
] as const)("preserves supported Discord DM input for baseline %s", (version, legacy) => {
214-
const step = resolveUpgradeSurvivorConfigStepsForBaseline("base", version).find(
215-
(entry) => entry.id === "channels-discord",
216-
);
217-
const discord = JSON.parse(step?.argv[3] ?? "{}");
218-
if (legacy) {
219-
expect(discord.dm).toEqual({ policy: "allowlist", allowFrom: ["111111111111111111"] });
220-
expect(discord.dmPolicy).toBeUndefined();
221-
expect(discord.allowFrom).toBeUndefined();
222-
} else {
223-
expect(discord.dm).toBeUndefined();
224-
expect(discord.dmPolicy).toBe("allowlist");
225-
expect(discord.allowFrom).toEqual(["111111111111111111"]);
226-
}
227-
// The public schema is the config-set boundary; runtime Zod preprocessing
228-
// would silently normalize the legacy specimen and miss a bad baseline cutoff.
229-
expect(
230-
validateJsonSchemaValue({
231-
schema: DiscordChannelConfigSchema.schema,
232-
cacheKey: "upgrade-survivor-discord-config",
233-
value: discord,
234-
}).ok,
235-
).toBe(!legacy);
236-
});
237-
238202
it.each(["2026.3.13", "2026.4.1", "2026.8.1-beta.1"])(
239203
"preserves the legacy agent contract for baseline %s",
240204
(version) => {

0 commit comments

Comments
 (0)