Files
oh-my-pi/packages/coding-agent/test/modes/components/oauth-selector.test.ts
T
can1357 42b79bc696 feat(coding-agent): added fuzzy token matching in coding-agent components
- Added fuzzy token matching in agent-dashboard, state-manager, and tree-selector, replacing lowercased checks.
- Added search-query state and fuzzy-filter helpers to hook, oauth, and user-message selectors for query filtering.
- Updated filtered selectors to render match results, status lines, no-match text, and move selection within results.
- Added `overflowSearch` and filter state to `SelectList`, switching overflowing list matching to fuzzy checks.
- Configured `SelectList` input flow and fixed cancel so Escape/Ctrl+C closes lists when no matches exist.
- Updated changelogs and added tests for fuzzy-filter behavior in hook, oauth, user-message, and list selectors.
2026-05-31 07:45:22 +02:00

49 lines
1.4 KiB
TypeScript

import { beforeAll, describe, expect, it } from "bun:test";
import { getOAuthProviders } from "@oh-my-pi/pi-ai/utils/oauth";
import { OAuthSelectorComponent } from "@oh-my-pi/pi-coding-agent/modes/components/oauth-selector";
import { initTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
import type { AuthStorage } from "@oh-my-pi/pi-coding-agent/session/auth-storage";
beforeAll(async () => {
await initTheme();
});
const authStorage = {
hasAuth: (_providerId: string) => false,
} as unknown as AuthStorage;
describe("OAuthSelectorComponent", () => {
it("fuzzy-filters overflowing provider lists from typed input", () => {
const providers = getOAuthProviders();
expect(providers.length).toBeGreaterThan(10);
const target =
providers.find(provider => provider.available && provider.id === "vllm") ??
providers.find(provider => provider.available) ??
providers[0];
expect(target).toBeDefined();
if (!target) return;
const selected: string[] = [];
const component = new OAuthSelectorComponent(
"login",
authStorage,
providerId => selected.push(providerId),
() => {},
);
for (const char of target.id) {
component.handleInput(char);
}
const rendered = component
.render(80)
.map(line => Bun.stripANSI(line))
.join("\n");
expect(rendered).toContain(target.name);
expect(rendered).toContain(`Search: ${target.id}`);
component.handleInput("\n");
expect(selected).toEqual([target.id]);
});
});