Files
modelstudioai__cli/packages/runtime/tests/console-flags.e2e.test.ts
clh02467605 d646a4e780 refactor(e2e): update test routes and streamline command handling
- 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.
2026-07-10 15:55:53 +08:00

43 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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/);
});
});