Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/components/CliOnlyScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
compiledRootCommand,
menuEntries,
renderScreen,
renderImperativeScreen,
IMPERATIVE_GLOBAL_CONFIG,
waitForText,
} from "../testing";
Expand Down Expand Up @@ -66,7 +65,7 @@ describe("menus list command-line-only subcommands below a divider", () => {
});

test("the harness menu", async () => {
const r = renderImperativeScreen("/agentcore/harness");
const r = renderScreen("/agentcore/harness", { globalConfig: IMPERATIVE_GLOBAL_CONFIG });

await waitForText(r.lastFrame, "command line only");
expect(menuEntries(r.lastFrame()!)).toEqual({
Expand All @@ -87,7 +86,9 @@ describe("menus list command-line-only subcommands below a divider", () => {
});

test("the divider is omitted when nothing is command line only", async () => {
const r = renderImperativeScreen("/agentcore/harness/endpoint");
const r = renderScreen("/agentcore/harness/endpoint", {
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "manage harness endpoints");
expect(r.lastFrame()).not.toContain("command line only");
Expand Down
83 changes: 66 additions & 17 deletions src/components/PaginatedTablePicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import { QueryClient } from "@tanstack/react-query";
import stringWidth from "string-width";
import {
cleanupScreens,
renderImperativeScreen,
renderScreen,
TestCoreClient,
waitFor,
waitForText,
IMPERATIVE_GLOBAL_CONFIG,
} from "../testing";

afterEach(cleanupScreens);
Expand Down Expand Up @@ -56,7 +57,10 @@ describe("paginated table picker contract", () => {
test("retries a failed query", async () => {
const core = new TestCoreClient();
core.harness.setError(new Error("access denied"));
const r = renderImperativeScreen("/agentcore/harness/list", { core });
const r = renderScreen("/agentcore/harness/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "access denied");
expect(r.lastFrame()).toContain("[r] retry");
Expand All @@ -80,7 +84,10 @@ describe("paginated table picker contract", () => {
if (args[0] === "t2") throw new Error("page unavailable");
return listHarnesses(...args);
};
const r = renderImperativeScreen("/agentcore/harness/list", { core });
const r = renderScreen("/agentcore/harness/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "page 1 · more →");
await r.write("l");
Expand All @@ -96,7 +103,10 @@ describe("paginated table picker contract", () => {
const core = new TestCoreClient();
const pending = Promise.withResolvers<ListHarnessesResponse>();
core.harness.listHarnesses = async () => pending.promise;
const r = renderImperativeScreen("/agentcore/harness/list", { core });
const r = renderScreen("/agentcore/harness/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "loading harnesses");
await r.press("escape");
Expand All @@ -106,15 +116,20 @@ describe("paginated table picker contract", () => {
test("keeps Escape active after a query fails", async () => {
const core = new TestCoreClient();
core.harness.setError(new Error("access denied"));
const r = renderImperativeScreen("/agentcore/harness/list", { core });
const r = renderScreen("/agentcore/harness/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "access denied");
await r.press("escape");
await waitForText(r.lastFrame, "manage AgentCore harnesses");
});

test("distinguishes first-page and later-page empty states", async () => {
const firstPage = renderImperativeScreen("/agentcore/harness/list");
const firstPage = renderScreen("/agentcore/harness/list", {
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});
await waitForText(firstPage.lastFrame, "No harnesses found in this Region.");
expect(firstPage.lastFrame()).not.toContain("page 1");
await firstPage.press("escape");
Expand All @@ -127,7 +142,10 @@ describe("paginated table picker contract", () => {
nextToken: "t2",
});
core.harness.setListResponse({ harnesses: [] }, "t2");
const laterPage = renderImperativeScreen("/agentcore/harness/list", { core });
const laterPage = renderScreen("/agentcore/harness/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(laterPage.lastFrame, "page 1 · more →");
await laterPage.write("l");
Expand All @@ -153,7 +171,10 @@ describe("paginated table picker contract", () => {
"t2",
);
core.harness.setGetResponse(getResponse(first));
const r = renderImperativeScreen("/agentcore/harness/list", { core });
const r = renderScreen("/agentcore/harness/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "page 1 · more →");
expect(r.lastFrame()).toContain("[←→/hl] page");
Expand Down Expand Up @@ -211,7 +232,11 @@ describe("paginated table picker contract", () => {
queries: { retry: false, gcTime: Infinity, staleTime: 0 },
},
});
const r = renderImperativeScreen("/agentcore/harness/list", { core, queryClient });
const r = renderScreen("/agentcore/harness/list", {
core,
queryClient,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "page 1 · more →");
await r.write("l");
Expand Down Expand Up @@ -261,7 +286,10 @@ describe("paginated table picker contract", () => {
"t2",
);
core.harness.setGetResponse(getResponse(first));
const r = renderImperativeScreen("/agentcore/harness/list", { core });
const r = renderScreen("/agentcore/harness/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "page 1 · more →");
await r.write("l");
Expand All @@ -286,7 +314,10 @@ describe("paginated table picker contract", () => {
const core = coreWith([alpha, beta]);
core.harness.setListResponse({ harnesses: [alpha, beta], nextToken: "t2" });
core.harness.setGetResponse(getResponse(alpha));
const r = renderImperativeScreen("/agentcore/harness/list", { core });
const r = renderScreen("/agentcore/harness/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "beta");
await r.press("down");
Expand Down Expand Up @@ -323,7 +354,10 @@ describe("paginated table picker contract", () => {
}),
],
});
const r = renderImperativeScreen("/agentcore/runtime/list", { core });
const r = renderScreen("/agentcore/runtime/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "orders-beta");
await r.write("/");
Expand Down Expand Up @@ -379,7 +413,10 @@ describe("paginated table picker contract", () => {
},
"t2",
);
const r = renderImperativeScreen("/agentcore/runtime/list", { core });
const r = renderScreen("/agentcore/runtime/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "matching-page-one");
await r.write("/");
Expand All @@ -406,7 +443,10 @@ describe("paginated table picker contract", () => {
),
nextToken: "t2",
});
const r = renderImperativeScreen("/agentcore/harness/list", { core });
const r = renderScreen("/agentcore/harness/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "page 1 · more →");
let lines = (r.lastFrame() ?? "").split("\n");
Expand Down Expand Up @@ -437,7 +477,10 @@ describe("paginated table picker contract", () => {
}),
nextToken: "t2",
});
const r = renderImperativeScreen("/agentcore/runtime/list", { core });
const r = renderScreen("/agentcore/runtime/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await r.resize(60, 24);
await waitFor(() => {
Expand Down Expand Up @@ -465,7 +508,10 @@ describe("paginated table picker contract", () => {
}),
),
});
const r = renderImperativeScreen("/agentcore/runtime/list", { core });
const r = renderScreen("/agentcore/runtime/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, suffixes[0]!);
for (const width of [100, 80, 60]) {
Expand All @@ -492,7 +538,10 @@ describe("paginated table picker contract", () => {
test("filters against rendered timestamps and raw identifiers", async () => {
const core = new TestCoreClient();
core.runtime.setListResponse({ agentRuntimes: [runtime()] });
const r = renderImperativeScreen("/agentcore/runtime/list", { core });
const r = renderScreen("/agentcore/runtime/list", {
core,
globalConfig: IMPERATIVE_GLOBAL_CONFIG,
});

await waitForText(r.lastFrame, "AbCdEf1234");
await r.write("/");
Expand Down
6 changes: 3 additions & 3 deletions src/components/ProjectResourceCreateScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
cleanupScreens,
compiledRootCommand,
menuEntries,
renderImperativeScreen,
renderScreen,
IMPERATIVE_GLOBAL_CONFIG,
waitForText,
} from "../testing";
Expand Down Expand Up @@ -43,7 +43,7 @@ describe("project resource creation guidance", () => {
test.each(RESOURCES)(
"$resource lists create in its TUI menu and opens project instructions",
async ({ resource, label, parentDescription, addCommand }) => {
const r = renderImperativeScreen(`/agentcore/${resource}`);
const r = renderScreen(`/agentcore/${resource}`, { globalConfig: IMPERATIVE_GLOBAL_CONFIG });

await waitForText(r.lastFrame, "❯ create");
expect(menuEntries(r.lastFrame()!).screens[0]).toBe("create");
Expand Down Expand Up @@ -75,7 +75,7 @@ describe("project resource creation guidance", () => {
test.each(RESOURCES.filter(({ resource }) => resource !== "gateway"))(
"$resource keeps project guidance when Gateway mutations are enabled",
async ({ resource, label, addCommand }) => {
const r = renderImperativeScreen(`/agentcore/${resource}`, { globalConfig: MUTATION_CONFIG });
const r = renderScreen(`/agentcore/${resource}`, { globalConfig: MUTATION_CONFIG });
await waitForText(r.lastFrame, "type to choose a command");
const entries = menuEntries(r.lastFrame()!);
expect(entries.screens[0]).toBe("create");
Expand Down
4 changes: 2 additions & 2 deletions src/components/Root.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
cleanupScreens,
compiledRootCommand,
IMPERATIVE_GLOBAL_CONFIG,
renderImperativeScreen,
renderScreen,
waitFor,
} from "../testing";

Expand Down Expand Up @@ -62,7 +62,7 @@ describe("every command with a screen", () => {
test.each(SCREENS.map(([path, command]) => [path.join(" "), path, command] as const))(
"%s opens, and esc returns to a menu above it",
async (_label, path, command) => {
const r = renderImperativeScreen("/" + path.join("/"));
const r = renderScreen("/" + path.join("/"), { globalConfig: IMPERATIVE_GLOBAL_CONFIG });
// Wide and tall enough that the header never wraps.
await r.resize(220, 200);
const menus = ancestorMenuHeaders(path, command);
Expand Down
14 changes: 7 additions & 7 deletions src/components/RouterScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
cleanupScreens,
menuEntries,
renderScreen,
renderImperativeScreen,
tick,
waitForText,
IMPERATIVE_GLOBAL_CONFIG,
} from "../testing";

afterEach(cleanupScreens);
Expand All @@ -32,7 +32,7 @@ describe("menu rendering", () => {
});

test("lists standalone commands in the root menu when enabled", async () => {
const r = renderImperativeScreen("/agentcore");
const r = renderScreen("/agentcore", { globalConfig: IMPERATIVE_GLOBAL_CONFIG });
await waitForText(r.lastFrame, "type to choose a command");

const entries = menuEntries(r.lastFrame()!);
Expand All @@ -50,7 +50,7 @@ describe("menu rendering", () => {
});

test("renders the harness subcommands when mounted at the harness path", async () => {
const r = renderImperativeScreen("/agentcore/harness");
const r = renderScreen("/agentcore/harness", { globalConfig: IMPERATIVE_GLOBAL_CONFIG });
await waitForText(r.lastFrame, "list");

const frame = r.lastFrame()!;
Expand All @@ -71,7 +71,7 @@ describe("menu rendering", () => {

describe("filtering", () => {
test("typing narrows the options to matches", async () => {
const r = renderImperativeScreen("/agentcore/harness");
const r = renderScreen("/agentcore/harness", { globalConfig: IMPERATIVE_GLOBAL_CONFIG });
await waitForText(r.lastFrame, "list");

await r.write("cr"); // matches "create" only
Expand All @@ -85,7 +85,7 @@ describe("filtering", () => {
});

test("filtering is case-insensitive", async () => {
const r = renderImperativeScreen("/agentcore/harness");
const r = renderScreen("/agentcore/harness", { globalConfig: IMPERATIVE_GLOBAL_CONFIG });
await waitForText(r.lastFrame, "list");

await r.write("LIST");
Expand All @@ -94,7 +94,7 @@ describe("filtering", () => {
});

test("shows a no-matches message when nothing matches", async () => {
const r = renderImperativeScreen("/agentcore/harness");
const r = renderScreen("/agentcore/harness", { globalConfig: IMPERATIVE_GLOBAL_CONFIG });
await waitForText(r.lastFrame, "list");

await r.write("zzz");
Expand Down Expand Up @@ -151,7 +151,7 @@ describe("navigation", () => {
});

test("esc from a nested menu returns to the parent menu", async () => {
const r = renderImperativeScreen("/agentcore/harness");
const r = renderScreen("/agentcore/harness", { globalConfig: IMPERATIVE_GLOBAL_CONFIG });
await waitForText(r.lastFrame, "agentcore → harness");

await r.press("escape");
Expand Down
Loading
Loading