History

Complete local custom tools picker e2e

Rhys Sullivan committed 4 months ago

Commit f876e231 parent 9b3e3561 file · +55 −2Browse files

Unified · Split

e2e/local/custom-tools-directory-picker.test.ts+55−2
@@ -1,7 +1,7 @@
11 // Local-only: custom tool local-directory sources can browse the user's own
22 // filesystem through the local app. The shared self-host target intentionally
33 // does not expose this source kind.
4−import { mkdtempSync, mkdirSync, rmSync } from "node:fs";
4+import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
55 import { homedir } from "node:os";
66 import { join } from "node:path";
77
@@ -23,7 +23,31 @@ scenario( · 15 unmodified lines
2323 const identity = yield* target.newIdentity();
2424 const fixtureRoot = mkdtempSync(join(homedir(), ".executor-picker-e2e-"));
2525 const fixtureDir = join(fixtureRoot, "picked-tools");
26− mkdirSync(fixtureDir);
26+ mkdirSync(join(fixtureDir, "tools"), { recursive: true });
27+ writeFileSync(
28+ join(fixtureDir, "package.json"),
29+ JSON.stringify({
30+ name: "picked-tools",
31+ version: "0.0.0",
32+ private: true,
33+ dependencies: { zod: "^4.1.13" },
34+ }),
35+ );
36+ writeFileSync(
37+ join(fixtureDir, "tools", "echo.ts"),
38+ `
39+import { z } from "zod";
40+import { defineTool } from "executor:app";
41+
42+export default defineTool({
43+ description: "Echo a picker message.",
44+ input: z.object({ message: z.string() }),
45+ handler(input) {
46+ return { echoed: \`local-picker:\${input.message}\` };
47+ },
48+});
49+`,
50+ );
2751
2852 yield* withLocalServer(cli, runDir, ({ url }) =>
2953 browser.session(identity, async ({ page, step }) => {
@@ -48,6 +72,35 @@ scenario( · 18 unmodified lines
4872 await dialog.getByRole("button", { name: "Select" }).click();
4973 expect(await pathInput.inputValue()).toBe(fixtureDir);
5074 });
75+
76+ await step("Sync the picked directory as a custom tools source", async () => {
77+ await page.getByRole("button", { name: "Sync source" }).click();
78+ await page.waitForURL(/\/integrations\/picked-tools(?:\?|$)/, { timeout: 90_000 });
79+ await page.getByLabel("Source").getByText("1 tool").waitFor({ timeout: 90_000 });
80+ });
81+
82+ await step("Run the published local tool from the console", async () => {
83+ await page.getByRole("tab", { name: "Tools" }).click();
84+ await page.getByRole("button", { name: /picked-tools\s+1/ }).click();
85+ await page.getByRole("button", { name: "echo", exact: true }).click();
86+ await page.getByRole("tab", { name: "Run" }).click();
87+ await page.getByLabel("message").fill("from directory picker");
88+ await page.getByRole("button", { name: "Run", exact: true }).click();
89+ await page
90+ .locator("pre")
91+ .filter({ hasText: "local-picker:from directory picker" })
92+ .last()
93+ .waitFor({ timeout: 90_000 });
94+ });
95+
96+ await step("Remove the local directory source", async () => {
97+ await page.goto(new URL("/integrations/picked-tools?tab=source", url).toString(), {
98+ waitUntil: "networkidle",
99+ });
100+ await page.getByRole("button", { name: "Remove" }).click();
101+ await page.getByRole("button", { name: "Remove source" }).click();
102+ await page.waitForURL(/\/integrations(?:\?|$)/, { timeout: 90_000 });
103+ });
51104 }),
52105 ).pipe(
53106 Effect.ensuring(Effect.sync(() => rmSync(fixtureRoot, { recursive: true, force: true }))),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t