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>
97 lines
3.0 KiB
TypeScript
97 lines
3.0 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
import { render, screen, fireEvent } from "@testing-library/react";
|
|
import Button from "./Button";
|
|
|
|
const onClick = vi.fn();
|
|
const onKeyDown = vi.fn();
|
|
|
|
describe("Button", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("still supports the native disabled attribute", () => {
|
|
render(
|
|
<Button disabled onClick={onClick}>
|
|
Save
|
|
</Button>,
|
|
);
|
|
expect(screen.getByRole("button", { name: "Save" })).toBeDisabled();
|
|
});
|
|
|
|
it("stays in the accessibility tree when unavailable, and says why", () => {
|
|
render(
|
|
<Button unavailable unavailableReason="Stop the container first.">
|
|
Save
|
|
</Button>,
|
|
);
|
|
const button = screen.getByRole("button", { name: "Save" });
|
|
expect(button).not.toBeDisabled();
|
|
expect(button).toHaveAttribute("aria-disabled", "true");
|
|
expect(button).toHaveAccessibleDescription("Stop the container first.");
|
|
// The reason is a description, not part of the name.
|
|
expect(button).toHaveAccessibleName("Save");
|
|
});
|
|
|
|
it("guards clicks and Enter/Space while unavailable", () => {
|
|
render(
|
|
<Button unavailable unavailableReason="Stop the container first." onClick={onClick}>
|
|
Save
|
|
</Button>,
|
|
);
|
|
const button = screen.getByRole("button", { name: "Save" });
|
|
fireEvent.click(button);
|
|
fireEvent.keyDown(button, { key: "Enter" });
|
|
fireEvent.keyDown(button, { key: " " });
|
|
expect(onClick).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("still forwards keys that are not activation keys", () => {
|
|
render(
|
|
<Button
|
|
unavailable
|
|
unavailableReason="Stop the container first."
|
|
onKeyDown={onKeyDown}
|
|
>
|
|
Save
|
|
</Button>,
|
|
);
|
|
fireEvent.keyDown(screen.getByRole("button", { name: "Save" }), {
|
|
key: "Escape",
|
|
});
|
|
expect(onKeyDown).toHaveBeenCalled();
|
|
});
|
|
|
|
it("behaves like an ordinary button when available", () => {
|
|
render(
|
|
<Button unavailable={false} unavailableReason="Stop the container first." onClick={onClick}>
|
|
Save
|
|
</Button>,
|
|
);
|
|
const button = screen.getByRole("button", { name: "Save" });
|
|
expect(button).not.toHaveAttribute("aria-disabled");
|
|
expect(button).toHaveAccessibleDescription("");
|
|
fireEvent.click(button);
|
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("wraps a long label only when asked", () => {
|
|
render(
|
|
<>
|
|
<Button>Short</Button>
|
|
<Button wrap size="md">
|
|
Request an environment from an admin…
|
|
</Button>
|
|
</>,
|
|
);
|
|
const plain = screen.getByRole("button", { name: "Short" });
|
|
expect(plain.className).toContain("whitespace-nowrap");
|
|
expect(plain.className).toContain("h-6");
|
|
const long = screen.getByRole("button", { name: "Request an environment from an admin…" });
|
|
expect(long.className).toContain("whitespace-normal");
|
|
expect(long.className).toContain("min-h-8");
|
|
expect(long.className).toContain("max-w-full");
|
|
expect(long.className).not.toMatch(/(^|\s)h-8(\s|$)/);
|
|
});
|
|
});
|