feat(config): add interactive config editor and GitLab PR support (#4)
Build / bun-build (push) Successful in 32s
Build / bun-build (push) Successful in 32s
Revamp the configuration UI with an interactive editor that supports inline text editing, navigation, and field validation, replacing the previous sequential prompts. Add GitLab pull request creation support via the `glab` CLI, and extend back navigation to all interactive menus for a consistent user experience. Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { test, expect, describe } from "bun:test";
|
||||
|
||||
async function run(command: string[], cwd: string, env: Record<string, string> = {}) {
|
||||
const proc = Bun.spawn(command, {
|
||||
cwd,
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
env: {
|
||||
PATH: process.env.PATH ?? "",
|
||||
HOME: env.HOME ?? process.env.HOME ?? "",
|
||||
...env,
|
||||
},
|
||||
});
|
||||
|
||||
const [exitCode, stdout, stderr] = await Promise.all([
|
||||
proc.exited,
|
||||
new Response(proc.stdout).text(),
|
||||
new Response(proc.stderr).text(),
|
||||
]);
|
||||
|
||||
return { exitCode, stdout, stderr };
|
||||
}
|
||||
|
||||
describe("commit command", () => {
|
||||
test("clean repository exits without requiring API key", async () => {
|
||||
const repo = mkdtempSync(join(tmpdir(), "gai-clean-repo-"));
|
||||
const home = mkdtempSync(join(tmpdir(), "gai-empty-home-"));
|
||||
|
||||
const init = await run(["git", "init"], repo, { HOME: home });
|
||||
expect(init.exitCode).toBe(0);
|
||||
|
||||
const result = await run(
|
||||
["bun", "run", join(import.meta.dir, "..", "index.ts"), "commit"],
|
||||
repo,
|
||||
{
|
||||
HOME: home,
|
||||
GAI_API_KEY: "",
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain("Nothing to commit");
|
||||
expect(result.stdout).toContain("No staged or unstaged changes");
|
||||
expect(result.stderr).not.toContain("API key not set");
|
||||
expect(result.stderr).not.toContain("requires a TTY");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user