- Align portless code with storage branch's numeric workspace IDs and new field names - Update workspace kind comparisons (local_checkout → checkout/worktree) - Add missing services, supportsTerminalMode, terminal fields to test fixtures - Fix archive timestamp assertions to match dynamic archiveSnapshot flow - Fix dictation, voice runtime, and service health monitor test timing - Add xterm-addon-ligatures type declaration for terminal emulator
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
vi.mock("@react-native-async-storage/async-storage", () => {
|
|
const storage = new Map<string, string>();
|
|
return {
|
|
default: {
|
|
getItem: vi.fn(async (key: string) => storage.get(key) ?? null),
|
|
setItem: vi.fn(async (key: string, value: string) => {
|
|
storage.set(key, value);
|
|
}),
|
|
removeItem: vi.fn(async (key: string) => {
|
|
storage.delete(key);
|
|
}),
|
|
},
|
|
};
|
|
});
|
|
|
|
import { AGENT_PROVIDER_DEFINITIONS } from "@server/server/agent/provider-manifest";
|
|
import {
|
|
__providerRecencyStoreTestUtils,
|
|
sortProvidersByRecency,
|
|
useProviderRecencyStore,
|
|
} from "./provider-recency-store";
|
|
|
|
describe("provider-recency-store", () => {
|
|
beforeEach(() => {
|
|
useProviderRecencyStore.setState({
|
|
recentProviderIds: [],
|
|
recordUsage: useProviderRecencyStore.getState().recordUsage,
|
|
});
|
|
});
|
|
|
|
it("sorts used providers first and keeps unused providers in default order", () => {
|
|
const sorted = sortProvidersByRecency(AGENT_PROVIDER_DEFINITIONS, ["codex"]);
|
|
|
|
expect(sorted.map((provider) => provider.id)).toEqual([
|
|
"codex",
|
|
...AGENT_PROVIDER_DEFINITIONS.filter((provider) => provider.id !== "codex").map(
|
|
(provider) => provider.id,
|
|
),
|
|
]);
|
|
});
|
|
|
|
it("moves the latest provider to the front without duplicating prior entries", () => {
|
|
useProviderRecencyStore.getState().recordUsage("codex");
|
|
useProviderRecencyStore.getState().recordUsage("opencode");
|
|
useProviderRecencyStore.getState().recordUsage("codex");
|
|
|
|
expect(useProviderRecencyStore.getState().recentProviderIds).toEqual([
|
|
"codex",
|
|
"opencode",
|
|
]);
|
|
});
|
|
|
|
it("filters invalid and duplicate providers during migration", () => {
|
|
expect(
|
|
__providerRecencyStoreTestUtils.migratePersistedState({
|
|
recentProviderIds: ["codex", "invalid", "codex", "claude"],
|
|
}),
|
|
).toEqual({
|
|
recentProviderIds: ["codex", "claude"],
|
|
});
|
|
});
|
|
});
|