Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
105 lines
3.1 KiB
TypeScript
105 lines
3.1 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import React from "react";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
|
|
import { DistroAvatar } from "./DistroAvatar.tsx";
|
|
import { LINUX_DISTRO_OPTION_IDS } from "./HostDetailsPanel.helpers.ts";
|
|
import type { Host } from "../types.ts";
|
|
|
|
const baseHost: Pick<Host, "distro" | "manualDistro" | "distroMode" | "os" | "protocol" | "iconMode" | "iconId" | "iconColor"> = {
|
|
os: "linux",
|
|
protocol: "ssh",
|
|
};
|
|
|
|
test("DistroAvatar renders custom host icon before distro color", () => {
|
|
const markup = renderToStaticMarkup(
|
|
<DistroAvatar
|
|
host={{ ...baseHost, distro: "ubuntu", iconMode: "custom", iconId: "database", iconColor: "blue" }}
|
|
fallback="DB"
|
|
/>,
|
|
);
|
|
|
|
assert.match(markup, /background-color:#2563EB/i);
|
|
assert.doesNotMatch(markup, /bg-\[#E95420\]/);
|
|
});
|
|
|
|
test("DistroAvatar keeps serial hosts on the USB icon", () => {
|
|
const markup = renderToStaticMarkup(
|
|
<DistroAvatar
|
|
host={{ ...baseHost, protocol: "serial", iconMode: "custom", iconId: "database", iconColor: "blue" }}
|
|
fallback="S"
|
|
/>,
|
|
);
|
|
|
|
assert.match(markup, /bg-amber-600/);
|
|
assert.doesNotMatch(markup, /background-color:#2563EB/i);
|
|
});
|
|
|
|
test("DistroAvatar xs size uses compact corners without appearing circular", () => {
|
|
const markup = renderToStaticMarkup(
|
|
<DistroAvatar
|
|
host={{ ...baseHost, distro: "ubuntu" }}
|
|
fallback="U"
|
|
size="xs"
|
|
/>,
|
|
);
|
|
|
|
assert.match(markup, /h-4 w-4 rounded-\[4px\]/);
|
|
assert.doesNotMatch(markup, /rounded-full/);
|
|
});
|
|
|
|
test("DistroAvatar tree size uses compact host icon corners", () => {
|
|
const markup = renderToStaticMarkup(
|
|
<DistroAvatar
|
|
host={{ ...baseHost, distro: "ubuntu" }}
|
|
fallback="U"
|
|
size="tree"
|
|
/>,
|
|
);
|
|
|
|
assert.match(markup, /h-6 w-6 rounded-\[6px\]/);
|
|
});
|
|
|
|
test("DistroAvatar keeps distro icon and applies custom palette color when icon mode is automatic", () => {
|
|
const markup = renderToStaticMarkup(
|
|
<DistroAvatar
|
|
host={{ ...baseHost, distro: "ubuntu", iconMode: "auto", iconId: "database", iconColor: "blue" }}
|
|
fallback="U"
|
|
/>,
|
|
);
|
|
|
|
assert.match(markup, /background-color:#2563EB/i);
|
|
assert.match(markup, /src="\/distro\/ubuntu.svg"/);
|
|
assert.doesNotMatch(markup, /bg-\[#E95420\]/);
|
|
});
|
|
|
|
test("DistroAvatar renders H3C logo without monochrome inversion", () => {
|
|
const markup = renderToStaticMarkup(
|
|
<DistroAvatar
|
|
host={{ ...baseHost, distro: "h3c" }}
|
|
fallback="H"
|
|
/>,
|
|
);
|
|
|
|
assert.match(markup, /src="\/distro\/h3c.svg"/);
|
|
assert.match(markup, /bg-white/);
|
|
assert.doesNotMatch(markup, /invert brightness-0/);
|
|
});
|
|
|
|
test("DistroAvatar renders the FreeBSD logo for a detected FreeBSD host", () => {
|
|
const markup = renderToStaticMarkup(
|
|
<DistroAvatar
|
|
host={{ distro: "freebsd", os: "linux" }}
|
|
fallback="FB"
|
|
/>,
|
|
);
|
|
|
|
assert.match(markup, /src="\/distro\/freebsd\.svg"/);
|
|
assert.match(markup, /alt="freebsd"/);
|
|
});
|
|
|
|
test("FreeBSD is available as a manual host icon choice", () => {
|
|
assert.ok(LINUX_DISTRO_OPTION_IDS.includes("freebsd"));
|
|
});
|