mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
d646a4e780
- Replaced hardcoded command paths with dynamic route mappings in E2E tests. - Enhanced documentation for command testing, specifying minimum route requirements. - Consolidated command path management into `topic-routes.ts` for better maintainability. - Updated various E2E test cases to utilize the new routing structure, ensuring consistency across tests. - Removed redundant helper functions and improved test clarity by directly referencing route exports.
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { dirname, join } from "path";
|
||
import { fileURLToPath } from "url";
|
||
import { describe, expect, test } from "vite-plus/test";
|
||
import { runNodeMain } from "e2e/runner";
|
||
|
||
const runtimeRoot = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||
const harnessMainTs = join(runtimeRoot, "tests/harness/cross-domain-main.ts");
|
||
|
||
async function runRuntimeHarness(args: string[]) {
|
||
return runNodeMain(harnessMainTs, args, { cwd: runtimeRoot });
|
||
}
|
||
|
||
/**
|
||
* 跨域 flag 拒绝:runtime 凭证域与命令 flag 解析边界(synthetic command,不依赖 commands)。
|
||
*/
|
||
describe("e2e: console global flags (cross-domain rejection)", () => {
|
||
test("跨域 flag 拒绝:model 命令传 --console-region 报 Unknown flag", async () => {
|
||
const { stderr, exitCode } = await runRuntimeHarness([
|
||
"text",
|
||
"chat",
|
||
"--message",
|
||
"hi",
|
||
"--console-region",
|
||
"cn-hangzhou",
|
||
"--dry-run",
|
||
]);
|
||
expect(exitCode).not.toBe(0);
|
||
expect(stderr).toMatch(/Unknown flag.*--console-region/);
|
||
});
|
||
|
||
test("跨域 flag 拒绝:console 命令传 --api-key 报 Unknown flag", async () => {
|
||
const { stderr, exitCode } = await runRuntimeHarness([
|
||
"mcp",
|
||
"list",
|
||
"--api-key",
|
||
"sk-test",
|
||
"--dry-run",
|
||
]);
|
||
expect(exitCode).not.toBe(0);
|
||
expect(stderr).toMatch(/Unknown flag.*--api-key/);
|
||
});
|
||
});
|