test(04-04): commit the CR13/CS5 shadow-law gate updates (missed in 54a2b54 staging)

This commit is contained in:
araharah-executor
2026-10-24 12:00:09 +08:00
parent 4212d1acd0
commit 7da7c2019c
2 changed files with 16 additions and 5 deletions
+5 -2
View File
@@ -393,8 +393,11 @@ test("CR13 the registration script derives the /cari scope from helpMenu", () =>
"utf8",
);
assert.ok(src.includes('["help", "privacy", "cari"]'), "the hardcoded command list gained cari");
const fetchCalls = src.match(/\bawait fetch\(/g) ?? [];
assert.equal(fetchCalls.length, 2, "still exactly two fetch calls (default + ms scopes)");
// Device-gate incident: all_private_chats SHADOWS default — /cari must be
// armed in the shadowing scope too, not only default.
const allPrivate = src.indexOf('"all_private_chats"');
assert.notEqual(allPrivate, -1, "all_private_chats scope must be armed explicitly (shadow law)");
assert.ok(src.includes("menuFor"), "every armed scope derives its set from helpMenu");
});
/* ————— CR14 — the alternates swap produces a new venue card ————— */
+11 -3
View File
@@ -154,14 +154,22 @@ test("CS5 D-03: helpMenu lists exactly /help, /privacy, and /cari — no future-
}
});
test("CS5 D-03: register-commands derives both scopes from helpMenu — two fetch calls, ms scope marked", () => {
test("CS5 D-03: register-commands derives every scope from helpMenu — single fetch site, all shadowing scopes armed", () => {
const source = readFileSync(
path.join(fileURLToPath(new URL(import.meta.url)), "..", "..", "scripts", "register-commands.mjs"),
"utf8",
);
// Device-gate incident (2026-10-24): a stale all_private_chats set shadowed
// the default scope and hid /cari — the script must arm EVERY scope that can
// shadow a private chat, not just default. One fetch site, scope table.
const fetchCalls = source.match(/\bawait fetch\(/g) ?? [];
assert.equal(fetchCalls.length, 2, "register-commands must issue exactly two setMyCommands fetch calls (default + ms)");
assert.equal(fetchCalls.length, 1, "register-commands must have a single fetch call site (scope loop)");
for (const scope of ["default", "all_private_chats"]) {
assert.ok(source.includes(`type: "${scope}"`), `the ${scope} scope must be armed explicitly`);
}
for (const scope of ["all_group_chats", "all_chat_administrators"]) {
assert.ok(source.includes(`type: "${scope}"`), `the stale ${scope} set must be explicitly cleared`);
}
assert.ok(source.includes('language_code: "ms"'), "the ms scope payload must set language_code 'ms'");
assert.ok(source.includes("menuFor(\"en\")"), "default scope derives from the en helpMenu");
assert.ok(source.includes("menuFor(\"ms\")"), "ms scope derives from the ms helpMenu");