fix(maestro): spawn similar preselects the cloned project
Spawn similar dropped the session's cwd into the free-text directory hatch, so the project picker showed nothing selected. For a worktree session that cwd was the daemon-made checkout, and the worktree toggle defaulted on, so the clone asked for a worktree of a worktree. It now seeds the picker: the cloned project's box selected, the same worktree decision, base repo plus '+ new' when the source had a worktree. A seeded path that matches no project falls back to the raw input showing that path instead of an empty picker.
This commit is contained in:
@@ -240,4 +240,35 @@ describe("spawnForm worktree step (#95)", () => {
|
||||
expect(box(form, MAESTRO.path).classList.contains("is-active")).toBe(true);
|
||||
expect(toggle(form).checked).toBe(false);
|
||||
});
|
||||
|
||||
it("lands a 'spawn similar' seed on the cloned project with '+ new' active", async () => {
|
||||
urls = stubFetch([MAESTRO, WT_A, WT_B]);
|
||||
handle = createSpawnForm({
|
||||
onSuccess() {},
|
||||
seed: { cwd: MAESTRO.path, cwdRawVisible: false, worktreeEnabled: true },
|
||||
});
|
||||
document.body.appendChild(handle.el);
|
||||
await drain();
|
||||
const form = handle.el;
|
||||
|
||||
expect(box(form, MAESTRO.path).classList.contains("is-active")).toBe(true);
|
||||
expect(activeChoice(form)!.dataset.kind).toBe("new");
|
||||
expect(toggle(form).checked).toBe(true);
|
||||
expect(form.querySelector<HTMLElement>(".cwd-raw-wrap")!.hidden).toBe(true);
|
||||
});
|
||||
|
||||
it("falls back to the raw input when the seeded directory matches no project", async () => {
|
||||
urls = stubFetch([MAESTRO, WT_A]);
|
||||
handle = createSpawnForm({
|
||||
onSuccess() {},
|
||||
seed: { cwd: "/home/user/gone", cwdRawVisible: false, worktreeEnabled: false },
|
||||
});
|
||||
document.body.appendChild(handle.el);
|
||||
await drain();
|
||||
const form = handle.el;
|
||||
|
||||
const raw = form.querySelector<HTMLInputElement>(".cwd-raw")!;
|
||||
expect(form.querySelector<HTMLElement>(".cwd-raw-wrap")!.hidden).toBe(false);
|
||||
expect(raw.value).toBe("/home/user/gone");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user