diff --git a/src/features/run/RunServices.module.css b/src/features/run/RunServices.module.css index ee0ece83c3..b914a21b78 100644 --- a/src/features/run/RunServices.module.css +++ b/src/features/run/RunServices.module.css @@ -36,6 +36,11 @@ min-height: 0; } +.importAll { + padding: var(--space-3) var(--space-3) var(--space-2); + border-bottom: 1px solid var(--border); +} + .importList { display: flex; flex-direction: column; diff --git a/src/features/run/serviceImport.test.tsx b/src/features/run/serviceImport.test.tsx new file mode 100644 index 0000000000..145fc4e961 --- /dev/null +++ b/src/features/run/serviceImport.test.tsx @@ -0,0 +1,29 @@ +import { afterEach, expect, it } from "vitest"; +import { cleanup, fireEvent, render, screen } from "@testing-library/react"; +import type { RunConfig } from "@/platform/ipc"; +import { pickServices, ServiceImportHost } from "./serviceImport"; + +afterEach(cleanup); + +const config = (id: string) => ({ id, name: id, kind: "spring-boot" }) as RunConfig; + +it("selects or clears every configuration with Select All", async () => { + render(); + const configs = ["a", "b", "c"].map(config); + const picked = pickServices("spring-boot", configs, new Set(["a", "b", "c"])); + const all = await screen.findByRole("checkbox", { name: "Select All" }); + expect(all).toBeChecked(); + + fireEvent.click(all); + for (const id of ["a", "b", "c"]) expect(screen.getByRole("checkbox", { name: id })).not.toBeChecked(); + expect(screen.getByRole("button", { name: "OK" })).toBeDisabled(); + + fireEvent.click(screen.getByRole("checkbox", { name: "b" })); + expect(all).toHaveAttribute("aria-checked", "mixed"); + + fireEvent.click(all); + expect(all).toBeChecked(); + fireEvent.click(screen.getByRole("checkbox", { name: "a" })); + fireEvent.click(screen.getByRole("button", { name: "OK" })); + expect(await picked).toEqual(new Set(["b", "c"])); +}); diff --git a/src/features/run/serviceImport.tsx b/src/features/run/serviceImport.tsx index e9791c2332..0e05a945ec 100644 --- a/src/features/run/serviceImport.tsx +++ b/src/features/run/serviceImport.tsx @@ -86,6 +86,14 @@ function ImportDialog(props: { { label: "Cancel", role: "cancel" }, ]} > +
+ 0 && picked.size < props.configs.length} + onChange={(checked) => setPicked(new Set(checked ? props.configs.map((c) => c.id) : []))} + label="Select All" + /> +
{props.configs.map((c) => ( toggle(c.id)} label={{c.name}} />