refactor(e2e): remove outdated token-plan tests and add new route exports

- Deleted the `token-plan.e2e.test.ts` file as it contained outdated test cases.
- Introduced `TOKEN_PLAN_ROUTES` in `topic-routes.ts` to define new command routes for token-plan operations.
- This update streamlines the E2E testing structure and prepares for future enhancements.
This commit is contained in:
clh02467605
2026-07-10 17:11:20 +08:00
parent e8666b33ae
commit a0b4666940
2 changed files with 34 additions and 13 deletions
@@ -1,16 +1,22 @@
import { describe, expect, test } from "vite-plus/test";
import { makeE2eOutputDir, parseStdoutJson, runCli } from "./helpers.ts";
import { makeE2eOutputDir, parseStdoutJson, runCommandE2e } from "./helpers.ts";
import { TOKEN_PLAN_ROUTES } from "./topic-routes.ts";
describe("e2e: token-plan", () => {
test("token-plan help shows centralized OpenAPI auth flags", async () => {
const { stderr, exitCode } = await runCli(["token-plan", "list-seats", "--help"]);
const { stderr, exitCode } = await runCommandE2e(TOKEN_PLAN_ROUTES, [
"token-plan",
"list-seats",
"--help",
]);
expect(exitCode, stderr).toBe(0);
expect(stderr).toMatch(/--access-key-id/);
expect(stderr).toMatch(/--access-key-secret/);
});
test("token-plan dry-run does not require OpenAPI AK/SK", async () => {
const { stdout, stderr, exitCode } = await runCli(
const { stdout, stderr, exitCode } = await runCommandE2e(
TOKEN_PLAN_ROUTES,
["token-plan", "list-seats", "--dry-run", "--output", "json"],
{
ALIBABA_CLOUD_ACCESS_KEY_ID: "",
@@ -25,22 +31,30 @@ describe("e2e: token-plan", () => {
test("token-plan non-dry-run requires OpenAPI AK/SK", async () => {
const configDir = makeE2eOutputDir("token-plan-missing-openapi");
const { stderr, exitCode } = await runCli(["token-plan", "list-seats"], {
BAILIAN_CONFIG_DIR: configDir,
ALIBABA_CLOUD_ACCESS_KEY_ID: "",
ALIBABA_CLOUD_ACCESS_KEY_SECRET: "",
});
const { stderr, exitCode } = await runCommandE2e(
TOKEN_PLAN_ROUTES,
["token-plan", "list-seats"],
{
BAILIAN_CONFIG_DIR: configDir,
ALIBABA_CLOUD_ACCESS_KEY_ID: "",
ALIBABA_CLOUD_ACCESS_KEY_SECRET: "",
},
);
expect(exitCode).not.toBe(0);
expect(stderr).toMatch(/OpenAPI AK\/SK|access-key-id|ALIBABA_CLOUD_ACCESS_KEY_ID/);
});
test("token-plan partial OpenAPI env reports AK/SK hint without API key onboarding", async () => {
const configDir = makeE2eOutputDir("token-plan-partial-openapi-env");
const { stderr, exitCode } = await runCli(["token-plan", "list-seats"], {
BAILIAN_CONFIG_DIR: configDir,
ALIBABA_CLOUD_ACCESS_KEY_ID: "ak-e2e-placeholder",
ALIBABA_CLOUD_ACCESS_KEY_SECRET: "",
});
const { stderr, exitCode } = await runCommandE2e(
TOKEN_PLAN_ROUTES,
["token-plan", "list-seats"],
{
BAILIAN_CONFIG_DIR: configDir,
ALIBABA_CLOUD_ACCESS_KEY_ID: "ak-e2e-placeholder",
ALIBABA_CLOUD_ACCESS_KEY_SECRET: "",
},
);
expect(exitCode).not.toBe(0);
expect(stderr).toMatch(/Incomplete OpenAPI AK\/SK/);
expect(stderr).toMatch(/ALIBABA_CLOUD_ACCESS_KEY_ID/);
@@ -136,3 +136,10 @@ export const CONSOLE_FLAGS_DRY_RUN_ROUTES: E2eRouteExports = {
"mcp list": "mcpList",
"quota check": "quotaCheck",
};
export const TOKEN_PLAN_ROUTES: E2eRouteExports = {
"token-plan list-seats": "tokenPlanListSeats",
"token-plan create-key": "tokenPlanCreateKey",
"token-plan assign-seats": "tokenPlanAssignSeats",
"token-plan add-member": "tokenPlanAddMember",
};