diff --git a/src/cloneWindowBoot.test.ts b/src/cloneWindowBoot.test.ts new file mode 100644 index 0000000000..d5b5cdb60d --- /dev/null +++ b/src/cloneWindowBoot.test.ts @@ -0,0 +1,17 @@ +import { describe, expect, it, vi } from "vitest"; +import { bootCloneWindow } from "./cloneWindowBoot"; +import { embeddedTerminal } from "./workbench/contributions"; + +vi.mock("./features/app/locale", () => ({ installLocaleSync: () => () => {} })); +vi.mock("./features/settings/runtime", () => ({ trackRuntimeSettings: () => () => {} })); +vi.mock("./workbench/dialogWindow", () => ({ activateDialogWindow: () => () => {} })); +vi.mock("./features/github/clone/source", () => ({ githubCloneSource: { id: "github" } })); +vi.mock("./features/vcs/cloneWindow", () => ({ activateCloneLaunches: () => () => {}, CloneWindow: () => null })); + +describe("bootCloneWindow", () => { + it("provides the embedded terminal the GitHub Sign In dialog needs", () => { + expect(embeddedTerminal()).toBeUndefined(); + bootCloneWindow("main"); + expect(embeddedTerminal()).toBeTypeOf("function"); + }); +}); diff --git a/src/cloneWindowBoot.ts b/src/cloneWindowBoot.ts index 7e1bd3cd20..a615ba7aa2 100644 --- a/src/cloneWindowBoot.ts +++ b/src/cloneWindowBoot.ts @@ -3,15 +3,26 @@ import { installLocaleSync } from "./features/app/locale"; import { githubCloneSource } from "./features/github/clone/source"; import { trackRuntimeSettings } from "./features/settings/runtime"; import { activateCloneLaunches, CloneWindow } from "./features/vcs/cloneWindow"; -import { registerCloneSource } from "./workbench/contributions"; +import { provideEmbeddedTerminal, registerCloneSource } from "./workbench/contributions"; import { activateDialogWindow } from "./workbench/dialogWindow"; import { activateList } from "./windowBoot"; +/** The embedded terminal of the GitHub Sign In dialog, loaded on first use. */ +function embeddedTerminal(): () => void { + provideEmbeddedTerminal(async (host, options) => + (await import("./features/terminal/loader")) + .loadTerminalRuntime() + .then((rt) => rt.createEmbeddedTerminal(host, options)), + ); + return () => provideEmbeddedTerminal(undefined); +} + /** Get from VCS window of project window `parent`: the clone dialog and its sources, no workbench. */ export function bootCloneWindow(parent: string): ComponentType { activateList("clone window", [ ["locale", installLocaleSync], ["settings", trackRuntimeSettings], + ["terminal", embeddedTerminal], ["github", () => registerCloneSource(githubCloneSource)], ["dialog", () => activateDialogWindow(parent)], ["launch", activateCloneLaunches],