mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-16 17:09:09 +00:00
Validated in a combined board with the other PRs of this wave on release/v3.8.52: the PR's own tests pass; typecheck:core, open-sse typecheck, api-typecheck, complexity, changelog-integrity, env-doc-sync, test-discovery, vitest-exclusions, error-helper, test-masking, lockfile, deps, gate-manifest, cli-i18n and i18n coverage green. Any file-size ceiling or stryker registration this wave needs lands in the wave's follow-up PR. Thank you for the contribution!
49 lines
2.1 KiB
TypeScript
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");
|
|
});
|