feat: tab completions for file paths (#279)
Made a PR as was requested in the #113
This commit is contained in:
46
codex-cli/tests/terminal-chat-completions.test.tsx
Normal file
46
codex-cli/tests/terminal-chat-completions.test.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import React from "react";
|
||||
import { describe, it, expect } from "vitest";
|
||||
import type { ComponentProps } from "react";
|
||||
import { renderTui } from "./ui-test-helpers.js";
|
||||
import TerminalChatCompletions from "../src/components/chat/terminal-chat-completions.js";
|
||||
|
||||
describe("TerminalChatCompletions", () => {
|
||||
const baseProps: ComponentProps<typeof TerminalChatCompletions> = {
|
||||
completions: ["Option 1", "Option 2", "Option 3", "Option 4", "Option 5"],
|
||||
displayLimit: 3,
|
||||
selectedCompletion: 0,
|
||||
};
|
||||
|
||||
it("renders visible completions within displayLimit", async () => {
|
||||
const { lastFrameStripped } = renderTui(
|
||||
<TerminalChatCompletions {...baseProps} />,
|
||||
);
|
||||
const frame = lastFrameStripped();
|
||||
expect(frame).toContain("Option 1");
|
||||
expect(frame).toContain("Option 2");
|
||||
expect(frame).toContain("Option 3");
|
||||
expect(frame).not.toContain("Option 4");
|
||||
});
|
||||
|
||||
it("centers the selected completion in the visible list", async () => {
|
||||
const { lastFrameStripped } = renderTui(
|
||||
<TerminalChatCompletions {...baseProps} selectedCompletion={2} />,
|
||||
);
|
||||
const frame = lastFrameStripped();
|
||||
expect(frame).toContain("Option 2");
|
||||
expect(frame).toContain("Option 3");
|
||||
expect(frame).toContain("Option 4");
|
||||
expect(frame).not.toContain("Option 1");
|
||||
});
|
||||
|
||||
it("adjusts when selectedCompletion is near the end", async () => {
|
||||
const { lastFrameStripped } = renderTui(
|
||||
<TerminalChatCompletions {...baseProps} selectedCompletion={4} />,
|
||||
);
|
||||
const frame = lastFrameStripped();
|
||||
expect(frame).toContain("Option 3");
|
||||
expect(frame).toContain("Option 4");
|
||||
expect(frame).toContain("Option 5");
|
||||
expect(frame).not.toContain("Option 2");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user