fix(test): repair readonly case table typing

This commit is contained in:
Peter Steinberger
2026-02-22 00:09:06 +01:00
parent 8394f0e30e
commit 843a037532
4 changed files with 45 additions and 12 deletions

View File

@@ -1,11 +1,19 @@
import { describe, expect, it } from "vitest";
import { SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
import { typedCases } from "../test-utils/typed-cases.js";
import { buildSubagentSystemPrompt } from "./subagent-announce.js";
import { buildAgentSystemPrompt, buildRuntimeLine } from "./system-prompt.js";
describe("buildAgentSystemPrompt", () => {
it("formats owner section for plain, hash, and missing owner lists", () => {
const cases = [
const cases = typedCases<{
name: string;
params: Parameters<typeof buildAgentSystemPrompt>[0];
expectAuthorizedSection: boolean;
contains: string[];
notContains: string[];
hashMatch?: RegExp;
}>([
{
name: "plain owner numbers",
params: {
@@ -16,14 +24,14 @@ describe("buildAgentSystemPrompt", () => {
contains: [
"Authorized senders: +123, +456. These senders are allowlisted; do not assume they are the owner.",
],
notContains: [] as string[],
notContains: [],
},
{
name: "hashed owner numbers",
params: {
workspaceDir: "/tmp/openclaw",
ownerNumbers: ["+123", "+456", ""],
ownerDisplay: "hash" as const,
ownerDisplay: "hash",
},
expectAuthorizedSection: true,
contains: ["Authorized senders:"],
@@ -36,10 +44,10 @@ describe("buildAgentSystemPrompt", () => {
workspaceDir: "/tmp/openclaw",
},
expectAuthorizedSection: false,
contains: [] as string[],
contains: [],
notContains: ["## Authorized Senders", "Authorized senders:"],
},
] as const;
]);
for (const testCase of cases) {
const prompt = buildAgentSystemPrompt(testCase.params);