fix: update CLI e2e tests for Hub removal

- Delete auth.test.ts (login/logout removed)
- Update headless-anthropic-api-key test for new error message
- Update headless-org-flag test for removed --org validation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Patrick Erichsen 2026-03-24 13:18:16 -07:00
parent 376b35ca55
commit 5a7b104a9f
4 changed files with 4 additions and 117 deletions

View file

@ -1,74 +0,0 @@
import fs from "fs/promises";
import path from "path";
import {
cleanupTestContext,
createTestContext,
runCLI,
} from "../test-helpers/cli-helpers.js";
import { cleanupMocks } from "../test-helpers/mock-helpers.js";
describe("E2E: Authentication", () => {
let context: any;
beforeEach(async () => {
context = await createTestContext();
});
afterEach(async () => {
cleanupMocks();
await cleanupTestContext(context);
});
describe("logout command", () => {
it("should remove auth credentials", async () => {
const authPath = path.join(context.testDir, ".continue", "auth.json");
// Create auth file
await fs.mkdir(path.dirname(authPath), { recursive: true });
await fs.writeFile(
authPath,
JSON.stringify({
userId: "test-user",
userEmail: "test@example.com",
accessToken: "test-token",
refreshToken: "test-refresh-token",
expiresAt: Date.now() + 3600000,
organizationId: null,
}),
);
// Run logout
const result = await runCLI(context, {
args: ["logout"],
env: {
HOME: context.testDir,
CONTINUE_GLOBAL_DIR: path.join(context.testDir, ".continue"),
},
});
expect(result.exitCode).toBe(0);
expect(result.stdout).toContain("Successfully logged out");
// Check auth file is removed
const authExists = await fs
.access(authPath)
.then(() => true)
.catch(() => false);
expect(authExists).toBe(false);
});
it("should handle logout when not logged in", async () => {
const result = await runCLI(context, {
args: ["logout"],
env: {
HOME: context.testDir,
CONTINUE_GLOBAL_DIR: path.join(context.testDir, ".continue"),
},
});
expect(result.exitCode).toBe(0);
expect(result.stdout).toContain("No active session found");
});
});
});

View file

@ -47,24 +47,6 @@ describe("E2E: Basic Commands", () => {
const result = await runCLI(context, { args: ["--help"] });
expect(result.stdout).toContain("Commands:");
expect(result.stdout).toContain("login");
expect(result.stdout).toContain("logout");
});
});
describe("subcommand help", () => {
it("should show help for login command", async () => {
const result = await runCLI(context, { args: ["login", "--help"] });
expect(result.exitCode).toBe(0);
expect(result.stdout).toContain("Authenticate with Continue");
});
it("should show help for logout command", async () => {
const result = await runCLI(context, { args: ["logout", "--help"] });
expect(result.exitCode).toBe(0);
expect(result.stdout).toContain("Log out from Continue");
});
});

View file

@ -94,31 +94,10 @@ models:
timeout: 15000,
});
// The CLI should create config but fail due to invalid API key
// This is expected behavior - invalid API keys should cause authentication errors
// The CLI should fail because auto-config from ANTHROPIC_API_KEY no longer creates a model
expect(result.exitCode).toBe(1);
// Should contain authentication error (not service initialization error)
expect(result.stderr).toContain("authentication_error");
expect(result.stderr).toContain("invalid x-api-key");
// Should NOT contain the old error about service initialization
expect(result.stderr).not.toContain("Failed to initialize ConfigService");
// Verify config.yaml was automatically created
const configPath = path.join(context.testDir, ".continue", "config.yaml");
const configExists = await fs
.stat(configPath)
.then(() => true)
.catch(() => false);
expect(configExists).toBe(true);
if (configExists) {
const configContent = await fs.readFile(configPath, "utf-8");
expect(configContent).toContain("anthropic/claude-sonnet-4-6");
expect(configContent).toContain(
"ANTHROPIC_API_KEY: TEST-test-invalid-key-format",
);
}
// Should contain error about no model being specified
expect(result.stderr).toContain("No model specified in headless mode");
}, 20000);
});

View file

@ -48,7 +48,7 @@ models:
expect(result.exitCode).not.toBe(0);
expect(result.stderr).toContain(
"--org flag is only supported in headless mode (with -p/--print flag)",
"Cannot start TUI in TTY-less environment",
);
});