Files
Triple-C/app/src/components/DockerInstallDialog.test.tsx
T
shadowdaoandClaude Opus 5.5 73eb507cfe
Secret Scan / scan (push) Successful in 15s
Build App (Preview) / compute-version (pull_request) Successful in 7s
Secret Scan / scan (pull_request) Successful in 15s
Build App (Preview) / test (pull_request) Successful in 11m20s
Build App (Preview) / create-release (pull_request) Successful in 5s
Build App (Preview) / build-macos (pull_request) Successful in 6m51s
Build App (Preview) / build-linux (pull_request) Successful in 13m0s
Build App (Preview) / build-windows (pull_request) Successful in 13m49s
Build App (Preview) / prune-previews (pull_request) Successful in 2s
feat(docker): tell "not running" apart from "not installed"
The app told a user whose Docker daemon had hit systemd start-limit-hit
to install Docker. New check_docker_status command classifies the ping
failure (io error kind in the bollard/hyper chain) plus cheap installed-
ness probes into running / not_running / no_permission / not_installed,
reports the endpoint tried (DOCKER_HOST respected), and the dialog, top
bar, welcome checklist and Docker settings show per-state guidance. The
dialog updates live from polling and closes when Docker comes up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 12:26:37 -08:00

92 lines
3.5 KiB
TypeScript

import { describe, it, expect, vi, beforeEach } from "vitest";
import { render, screen, act } from "@testing-library/react";
import DockerInstallDialog from "./DockerInstallDialog";
import { useAppState } from "../store/appState";
import type { DockerStatus } from "../lib/types";
vi.mock("../lib/tauri-commands", () => ({
getDockerStatus: vi.fn(),
checkImageExists: vi.fn(),
buildImage: vi.fn(),
pullImage: vi.fn(),
openUrlExternal: vi.fn(),
}));
vi.mock("../hooks/useInstallHelper", () => ({
useInstallHelper: () => ({
options: {
os: "linux",
product_name: "Docker Engine",
can_auto_install: false,
auto_install_method: null,
auto_install_blocker: "no pkexec",
docs_url: "https://docs.docker.com",
manual_steps: [],
post_install_notes: [],
},
loadOptions: vi.fn(),
runInstall: vi.fn(),
}),
}));
const status = (state: DockerStatus["state"], os: DockerStatus["os"] = "linux"): DockerStatus => ({
state,
endpoint: "unix:///var/run/docker.sock",
detail: state === "running" ? null : "connection refused",
os,
});
function setStatus(s: DockerStatus) {
act(() => useAppState.getState().setDockerStatus(s));
}
describe("DockerInstallDialog", () => {
beforeEach(() => {
useAppState.setState({ dockerStatus: null, dockerAvailable: null });
});
it("offers install guidance when Docker is not installed", () => {
setStatus(status("not_installed"));
render(<DockerInstallDialog onClose={vi.fn()} />);
expect(screen.getByRole("dialog", { name: "Docker is not installed" })).toBeTruthy();
expect(screen.getByText(/AWS projects don't need local Docker/)).toBeTruthy();
expect(screen.getByText("unix:///var/run/docker.sock")).toBeTruthy();
});
it("says installed-but-not-running with systemd steps on Linux, and offers no install", () => {
setStatus(status("not_running"));
render(<DockerInstallDialog onClose={vi.fn()} />);
expect(screen.getByRole("dialog", { name: "Docker is installed but not running" })).toBeTruthy();
expect(screen.getByText("sudo systemctl start docker")).toBeTruthy();
expect(screen.getByText("sudo systemctl reset-failed docker")).toBeTruthy();
expect(screen.getByText("journalctl -u docker -b")).toBeTruthy();
expect(screen.queryByText(/Install Docker Engine/)).toBeNull();
expect(screen.getByText(/AWS projects don't need local Docker/)).toBeTruthy();
});
it("tells macOS/Windows users to start Docker Desktop", () => {
setStatus(status("not_running", "macos"));
render(<DockerInstallDialog onClose={vi.fn()} />);
expect(screen.getByText("Docker Desktop")).toBeTruthy();
expect(screen.queryByText("sudo systemctl start docker")).toBeNull();
});
it("explains the docker group on permission denied", () => {
setStatus(status("no_permission"));
render(<DockerInstallDialog onClose={vi.fn()} />);
expect(screen.getByRole("dialog", { name: "Docker is running but not accessible" })).toBeTruthy();
expect(screen.getByText("sudo usermod -aG docker $USER")).toBeTruthy();
});
it("updates live and closes itself when Docker becomes available", () => {
setStatus(status("not_installed"));
const onClose = vi.fn();
render(<DockerInstallDialog onClose={onClose} />);
setStatus(status("not_running"));
expect(screen.getByRole("dialog", { name: "Docker is installed but not running" })).toBeTruthy();
expect(onClose).not.toHaveBeenCalled();
setStatus(status("running"));
expect(onClose).toHaveBeenCalled();
});
});