Build App (Preview) / compute-version (pull_request) Successful in 5s
Secret Scan / scan (push) Successful in 23s
Secret Scan / scan (pull_request) Successful in 9s
Build App (Preview) / create-release (pull_request) Successful in 3s
Build App (Preview) / build-macos (pull_request) Successful in 6m24s
Build App (Preview) / build-windows (pull_request) Successful in 11m28s
Build App (Preview) / build-linux (pull_request) Successful in 23m6s
Build App (Preview) / test (pull_request) Successful in 26m21s
Build App (Preview) / prune-previews (pull_request) Successful in 5s
Hosts settings live in a 224-320px sidebar; nowrap buttons and long ARNs, policy names and run summaries overflowed it. Button and StatusIndicator get an opt-in wrap prop; host, environment, progress and policy rows wrap with min-w-0 children; policy copy buttons sit in an auto-fill grid; pre blocks scroll; the Modal footer wraps. Deploy a new environment and self-join are offered to anyone after a scan. When the permission check didn't confirm environment-admin rights a note says AWS has the last word, and the policies and environment request sit under a 'Not an admin?' disclosure. The boundary note shows whenever the boundary is missing. AWS refusals show AWS's message (awsErrorMessage now names the denied action) and offer the admin bundle: in the deploy and join modals, and under a failed deploy/join run whose output reads as denied. The backend already had no tier check on onboard_aws_user; its comment is corrected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
102 lines
4.0 KiB
TypeScript
102 lines
4.0 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
import { act, render, renderHook, screen } from "@testing-library/react";
|
|
import DeployProgressView, { runKey, useDeployRuns } from "./DeployProgress";
|
|
import type { DeployProgress } from "../../../lib/types";
|
|
import { progress, tofuEvent } from "./testkit";
|
|
|
|
vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));
|
|
|
|
type Handler = (e: { payload: DeployProgress }) => void;
|
|
const handlers = new Set<Handler>();
|
|
vi.mock("@tauri-apps/api/event", () => ({
|
|
listen: vi.fn(async (_name: string, handler: Handler) => {
|
|
handlers.add(handler);
|
|
return () => handlers.delete(handler);
|
|
}),
|
|
}));
|
|
function emit(p: DeployProgress) {
|
|
act(() => {
|
|
for (const h of [...handlers]) h({ payload: p });
|
|
});
|
|
}
|
|
|
|
const KEY = "environments/main/terraform.tfstate";
|
|
|
|
describe("useDeployRuns", () => {
|
|
beforeEach(() => handlers.clear());
|
|
|
|
it("tracks runs for the same state key in two regions independently", async () => {
|
|
const onDone = vi.fn();
|
|
const { result } = renderHook(() => useDeployRuns(onDone));
|
|
await act(async () => {
|
|
await result.current.start(KEY, "eu-west-1", "Deploy of main", async () => "eu");
|
|
});
|
|
await act(async () => {
|
|
await result.current.start(KEY, "us-east-1", "Deploy of main", async () => "us");
|
|
});
|
|
expect(handlers.size).toBe(2);
|
|
emit(progress({ op_id: "eu", state_key: KEY, events: [tofuEvent("eu line")] }));
|
|
emit(progress({ op_id: "us", state_key: KEY, events: [tofuEvent("us line")] }));
|
|
emit(progress({ op_id: "us", state_key: KEY, done: true, cancellable: false, result: { ok: true, exit_code: 0, summary: "ok" } }));
|
|
|
|
const eu = result.current.runs[runKey("eu-west-1", KEY)];
|
|
const us = result.current.runs[runKey("us-east-1", KEY)];
|
|
expect(eu.events.map((e) => e.message)).toEqual(["eu line"]);
|
|
expect(eu.done).toBe(false);
|
|
expect(us.events.map((e) => e.message)).toEqual(["us line"]);
|
|
expect(us.done).toBe(true);
|
|
expect(onDone).toHaveBeenCalledTimes(1);
|
|
expect(onDone).toHaveBeenCalledWith({ stateKey: KEY, region: "us-east-1", result: { ok: true, exit_code: 0, summary: "ok" } });
|
|
// The finished run's listener is gone; the other region's is still there.
|
|
expect(handlers.size).toBe(1);
|
|
});
|
|
|
|
it("removes its progress listeners on unmount", async () => {
|
|
const { result, unmount } = renderHook(() => useDeployRuns());
|
|
await act(async () => {
|
|
await result.current.start(KEY, "eu-west-1", "Deploy of main", async () => "a");
|
|
await result.current.start("boundary/terraform.tfstate", "eu-west-1", "Boundary", async () => "b");
|
|
});
|
|
expect(handlers.size).toBe(2);
|
|
unmount();
|
|
expect(handlers.size).toBe(0);
|
|
});
|
|
|
|
it("a rejected start removes its listener and returns the AWS error", async () => {
|
|
const { result } = renderHook(() => useDeployRuns());
|
|
let err: unknown;
|
|
await act(async () => {
|
|
err = await result.current.start(KEY, "eu-west-1", "Deploy of main", async () => {
|
|
throw { kind: "other", message: "A deployment is already running" };
|
|
});
|
|
});
|
|
expect(err).toEqual({ kind: "other", message: "A deployment is already running" });
|
|
expect(handlers.size).toBe(0);
|
|
expect(result.current.runs).toEqual({});
|
|
});
|
|
});
|
|
|
|
describe("DeployProgress layout", () => {
|
|
it("wraps its header and a long failure summary", () => {
|
|
render(
|
|
<DeployProgressView
|
|
connectionId="h1"
|
|
run={{
|
|
stateKey: KEY,
|
|
region: "eu-west-1",
|
|
label: "Deploy of main",
|
|
opId: "x",
|
|
events: [],
|
|
done: true,
|
|
cancellable: false,
|
|
result: { ok: false, exit_code: 1, summary: "a very long summary ".repeat(10) },
|
|
}}
|
|
/>,
|
|
);
|
|
const header = screen.getByTestId("deploy-progress-header");
|
|
expect(header.className).toContain("flex-wrap");
|
|
expect(header.firstElementChild?.className).toContain("min-w-0");
|
|
expect(screen.getByRole("status").firstElementChild?.className).toContain("whitespace-normal");
|
|
});
|
|
});
|