Files
OmniRoute/tests/unit/api-manager-usage-command.test.ts
Diego Rodrigues de Sa e Souza ad6f33f66b Release v3.8.52
Release v3.8.52 — 1,442 documented changes (135 features, 1,112 fixes, 195 maintenance) from 1,386 cycle commits and 306 external contributors; full changelog in CHANGELOG.md → [3.8.52]. Local pre-flight on c754707d: check:release-green --quick --full-ci RELEASE-GREEN (0 HARD / 0 drift), webpack production build + build:cli OK; the release-PR ci.yml run was never dispatched (Actions FIFO backlog), merged with --admin by owner decision at STOP #1. ⚠️ base-red inherited: #15306 (i18n translation drift pinned by 3 unit tests + Docs Sync strict — translation backlog, not code).
2026-10-19 12:22:25 -03:00

49 lines
2.1 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
const repoRoot = process.cwd();
function read(relativePath: string) {
return fs.readFileSync(path.join(repoRoot, relativePath), "utf8");
}
test("api manager exposes allowUsageCommand in create, edit, and list UI", () => {
const src = read("src/app/(dashboard)/dashboard/api-manager/ApiManagerPageClient.tsx");
// Editing moved from the permissions modal to the access editor page (Behaviour tab).
const behaviourTab = read(
"src/app/(dashboard)/dashboard/api-manager/[id]/access/tabs/BehaviourTab.tsx"
);
const accessForm = read(
"src/app/(dashboard)/dashboard/api-manager/[id]/access/useApiKeyAccessForm.ts"
);
assert.ok(src.includes("newKeyAllowUsageCommand"), "create modal must keep command state");
assert.ok(
behaviourTab.includes("setAllowUsageCommand(!formState.allowUsageCommand)"),
"access editor must edit command state"
);
assert.ok(
accessForm.includes("allowUsageCommand: formState.allowUsageCommand"),
"access editor PATCH payload must include allowUsageCommand"
);
assert.ok(src.includes("allowUsageCommand"), "API payloads must include allowUsageCommand");
assert.ok(src.includes('t("localUsageCommand")'), "create toggle must use i18n title");
assert.ok(behaviourTab.includes('t("localUsageCommand")'), "edit toggle must use i18n title");
assert.ok(src.includes('t("localUsageCommandBadge")'), "key list must show enabled state");
});
test("api key routes and schemas accept allowUsageCommand", () => {
const schemas = read("src/shared/validation/schemas/keys.ts");
const createRoute = read("src/app/api/keys/route.ts");
const updateRoute = read("src/app/api/keys/[id]/route.ts");
assert.ok(
schemas.includes("allowUsageCommand: z.boolean().optional()"),
"zod schemas must accept the field"
);
assert.ok(createRoute.includes("allowUsageCommand"), "create route must persist the field");
assert.ok(updateRoute.includes("allowUsageCommand"), "update route must persist the field");
});