git-subtree-dir: extensions/cli git-subtree-mainline:1674c2aff1git-subtree-split:e27a5c87d5
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
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({
|
|
accessToken: "test-token",
|
|
user: { id: "test-user", email: "test@example.com" },
|
|
})
|
|
);
|
|
|
|
// Run logout
|
|
const result = await runCLI(context, { args: ["logout"] });
|
|
|
|
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"] });
|
|
|
|
expect(result.exitCode).toBe(0);
|
|
expect(result.stdout).toContain("No active session found");
|
|
});
|
|
});
|
|
});
|