import { describe, expect, it } from "vitest"; import {
resolveWhatsAppDirectSystemPrompt,
resolveWhatsAppGroupSystemPrompt,
} from "./system-prompt.js";
it("falls back to wildcard when specific group entry is absent", () => {
expect(
resolveWhatsAppGroupSystemPrompt({
groupId: "g1",
accountConfig: {
groups: { "*": { systemPrompt: "wildcard prompt" } },
},
}),
).toBe("wildcard prompt");
});
it("suppresses wildcard when specific group entry sets systemPrompt to empty string", () => {
expect(
resolveWhatsAppGroupSystemPrompt({
groupId: "g1",
accountConfig: {
groups: {
g1: { systemPrompt: "" }, "*": { systemPrompt: "wildcard prompt" },
},
},
}),
).toBeUndefined();
});
it("suppresses wildcard when specific group entry sets systemPrompt to whitespace-only string", () => {
expect(
resolveWhatsAppGroupSystemPrompt({
groupId: "g1",
accountConfig: {
groups: {
g1: { systemPrompt: " " }, "*": { systemPrompt: "wildcard prompt" },
},
},
}),
).toBeUndefined();
});
it("trims whitespace from specific group systemPrompt", () => {
expect(
resolveWhatsAppGroupSystemPrompt({
groupId: "g1",
accountConfig: { groups: { g1: { systemPrompt: " trimmed " } } },
}),
).toBe("trimmed");
});
it("returns undefined when specific group entry has no systemPrompt key and no wildcard", () => {
expect(
resolveWhatsAppGroupSystemPrompt({
groupId: "g1",
accountConfig: { groups: { g1: {} } },
}),
).toBeUndefined();
});
it("falls back to wildcard when specific group entry has no systemPrompt key", () => {
expect(
resolveWhatsAppGroupSystemPrompt({
groupId: "g1",
accountConfig: {
groups: {
g1: {}, "*": { systemPrompt: "wildcard prompt" },
},
},
}),
).toBe("wildcard prompt");
});
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.