fix(etcd): preserve raw key identity in browser actions
This commit is contained in:
69 files changed
+6577
-742
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { classifyEtcdDashboardError, sanitizeEtcdDashboardError } from "@/lib/kv/etcdDashboardError";
|
||||
|
||||
describe("etcd dashboard errors", () => {
|
||||
it("recognizes legacy agents that do not implement kv_status", () => {
|
||||
expect(classifyEtcdDashboardError(new Error("Agent RPC error (-1): Unknown method: kv_status")).kind).toBe("unsupported");
|
||||
expect(classifyEtcdDashboardError("Agent RPC error (-32601): Method not found: kv_status").kind).toBe("unsupported");
|
||||
expect(classifyEtcdDashboardError("ETCD_STATUS_UNSUPPORTED: update the driver").kind).toBe("unsupported");
|
||||
});
|
||||
|
||||
it("removes unrelated agent stderr from the user-facing message", () => {
|
||||
const error = "Agent RPC error (-1): connection refused. recent stderr: SLF4J(W): No SLF4J providers were found. io.netty.resolver.dns.DnsServerAddressStreamProviders warning";
|
||||
expect(sanitizeEtcdDashboardError(error)).toBe("Agent RPC error (-1): connection refused");
|
||||
});
|
||||
|
||||
it("keeps ordinary request failures as request errors", () => {
|
||||
const result = classifyEtcdDashboardError(new Error("Agent RPC error (-1): etcdserver: request timed out"));
|
||||
expect(result).toEqual({
|
||||
kind: "request",
|
||||
message: "Agent RPC error (-1): etcdserver: request timed out",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,74 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { KvPrometheusMetrics } from "@/lib/backend/tauri";
|
||||
import { counterMapRates, counterRate, histogramAverageMilliseconds, histogramMapAverageMilliseconds, ratePercentage } from "@/lib/kv/etcdDashboardMetrics";
|
||||
|
||||
function snapshot(values: Partial<KvPrometheusMetrics>): KvPrometheusMetrics {
|
||||
return {
|
||||
available: true,
|
||||
sourceUrl: "http://localhost:2380/metrics",
|
||||
grpcMethodRequestsTotal: {},
|
||||
grpcMethodFailuresTotal: {},
|
||||
requestDurationSecondsSumByType: {},
|
||||
requestDurationSecondsCountByType: {},
|
||||
...values,
|
||||
};
|
||||
}
|
||||
|
||||
describe("etcd dashboard metrics", () => {
|
||||
it("converts cumulative counters to rates using adjacent snapshots", () => {
|
||||
const previous = snapshot({ collectedAtMs: 10_000, grpcRequestsTotal: 100 });
|
||||
const current = snapshot({ collectedAtMs: 20_000, grpcRequestsTotal: 160 });
|
||||
|
||||
expect(counterRate(current, previous, "grpcRequestsTotal")).toBe(6);
|
||||
});
|
||||
|
||||
it("does not report a misleading rate after a counter reset", () => {
|
||||
const previous = snapshot({ collectedAtMs: 10_000, grpcRequestsTotal: 100 });
|
||||
const current = snapshot({ collectedAtMs: 20_000, grpcRequestsTotal: 5 });
|
||||
|
||||
expect(counterRate(current, previous, "grpcRequestsTotal")).toBeNull();
|
||||
});
|
||||
|
||||
it("uses delta histogram observations after the first snapshot", () => {
|
||||
const previous = snapshot({
|
||||
collectedAtMs: 10_000,
|
||||
walFsyncDurationSecondsSum: 1,
|
||||
walFsyncDurationSecondsCount: 20,
|
||||
});
|
||||
const current = snapshot({
|
||||
collectedAtMs: 20_000,
|
||||
walFsyncDurationSecondsSum: 1.2,
|
||||
walFsyncDurationSecondsCount: 30,
|
||||
});
|
||||
|
||||
expect(histogramAverageMilliseconds(current, previous, "walFsyncDurationSecondsSum", "walFsyncDurationSecondsCount")).toBeCloseTo(20);
|
||||
});
|
||||
|
||||
it("computes a bounded failure percentage", () => {
|
||||
expect(ratePercentage(2, 20)).toBe(10);
|
||||
expect(ratePercentage(2, 0)).toBeNull();
|
||||
expect(ratePercentage(25, 20)).toBe(100);
|
||||
});
|
||||
|
||||
it("calculates rates for labeled counters", () => {
|
||||
const previous = snapshot({ collectedAtMs: 10_000, grpcMethodRequestsTotal: { Range: 100, Put: 4 } });
|
||||
const current = snapshot({ collectedAtMs: 20_000, grpcMethodRequestsTotal: { Range: 160, Put: 14 } });
|
||||
|
||||
expect(counterMapRates(current, previous, "grpcMethodRequestsTotal")).toEqual({ Range: 6, Put: 1 });
|
||||
});
|
||||
|
||||
it("calculates per-operation latency from labeled histogram deltas", () => {
|
||||
const previous = snapshot({
|
||||
collectedAtMs: 10_000,
|
||||
requestDurationSecondsSumByType: { Range: 1 },
|
||||
requestDurationSecondsCountByType: { Range: 20 },
|
||||
});
|
||||
const current = snapshot({
|
||||
collectedAtMs: 20_000,
|
||||
requestDurationSecondsSumByType: { Range: 1.2 },
|
||||
requestDurationSecondsCountByType: { Range: 30 },
|
||||
});
|
||||
|
||||
expect(histogramMapAverageMilliseconds(current, previous, "requestDurationSecondsSumByType", "requestDurationSecondsCountByType").Range).toBeCloseTo(20);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isKeyInKvExportScope, kvDirectoryPrefix, kvExportFilenameStem, kvValueByteIdentity } from "@/lib/kv/kvExportScope";
|
||||
|
||||
describe("KV export scope", () => {
|
||||
it("matches a directory itself and descendants without leaking into adjacent prefixes", () => {
|
||||
const scope = { path: "/dbx", kind: "prefix" as const };
|
||||
|
||||
expect(isKeyInKvExportScope("/dbx", scope)).toBe(true);
|
||||
expect(isKeyInKvExportScope("/dbx/app/name", scope)).toBe(true);
|
||||
expect(isKeyInKvExportScope("/dbx-other", scope)).toBe(false);
|
||||
});
|
||||
|
||||
it("matches only the selected key for a key export", () => {
|
||||
const scope = { path: "dbx/key", kind: "key" as const };
|
||||
|
||||
expect(isKeyInKvExportScope("dbx/key", scope)).toBe(true);
|
||||
expect(isKeyInKvExportScope("dbx/key/child", scope)).toBe(false);
|
||||
});
|
||||
|
||||
it("builds stable directory prefixes and safe filenames", () => {
|
||||
expect(kvDirectoryPrefix("/dbx")).toBe("/dbx/");
|
||||
expect(kvDirectoryPrefix("dbx/")).toBe("dbx/");
|
||||
expect(kvExportFilenameStem("/应用 配置/prod")).toBe("应用-配置-prod");
|
||||
expect(kvExportFilenameStem("/")).toBe("root");
|
||||
});
|
||||
|
||||
it("compares UTF-8 and Base64 representations by their original bytes", () => {
|
||||
expect(kvValueByteIdentity({ encoding: "utf8", data: "/dbx/app" })).toBe(kvValueByteIdentity({ encoding: "base64", data: "L2RieC9hcHA=" }));
|
||||
expect(kvValueByteIdentity({ encoding: "utf8", data: "/dbx/app" })).not.toBe(kvValueByteIdentity({ encoding: "utf8", data: "/dbx-other" }));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { filterKvKeysBySearch, kvKeyMatchesSearch } from "@/lib/kv/kvKeySearch";
|
||||
|
||||
describe("KV Key path search", () => {
|
||||
it("matches the query anywhere in the complete Key path", () => {
|
||||
const keys = ["/a/b/c", "/dbx/a", "/test/a", "/test/c", "a", "aaa", "bb"].map((key) => ({ key }));
|
||||
|
||||
expect(filterKvKeysBySearch(keys, "a").map((key) => key.key)).toEqual(["/a/b/c", "/dbx/a", "/test/a", "a", "aaa"]);
|
||||
});
|
||||
|
||||
it("matches case-insensitively and ignores surrounding whitespace", () => {
|
||||
expect(kvKeyMatchesSearch("/Apps/Production/Name", " production ")).toBe(true);
|
||||
expect(kvKeyMatchesSearch("/Apps/Production/Name", "staging")).toBe(false);
|
||||
});
|
||||
});
|
||||
+37
-1
@@ -1,7 +1,23 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildKvKeyTree, collectKvGroupIds, flattenVisibleKvKeyTree, preserveKvExpandedGroupIds } from "@/lib/kv/kvKeyTree";
|
||||
import { buildKvKeyTree, collectKvGroupIds, flattenVisibleKvKeyTree, kvKeyTreeNodePath, preserveKvExpandedGroupIds } from "@/lib/kv/kvKeyTree";
|
||||
|
||||
describe("kv key tree", () => {
|
||||
it("represents a key that is also a prefix as one expandable value node", () => {
|
||||
const tree = buildKvKeyTree([
|
||||
{ key: "/app", modRevision: "2" },
|
||||
{ key: "/app/name", modRevision: "3" },
|
||||
]);
|
||||
|
||||
expect(tree).toHaveLength(1);
|
||||
expect(tree[0]).toMatchObject({
|
||||
kind: "group",
|
||||
label: "app",
|
||||
key: "/app",
|
||||
modRevision: "2",
|
||||
children: [{ kind: "leaf", key: "/app/name" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps root keys as leaf nodes", () => {
|
||||
const tree = buildKvKeyTree([{ key: "/plain", version: 2 }, { key: "/" }]);
|
||||
|
||||
@@ -9,6 +25,21 @@ describe("kv key tree", () => {
|
||||
expect(tree[1]).toMatchObject({ kind: "leaf", key: "/plain", version: 2 });
|
||||
});
|
||||
|
||||
it("keeps colliding display keys as distinct raw-byte leaves", () => {
|
||||
const binaryBytes = { encoding: "base64" as const, data: "/w==" };
|
||||
const utf8Bytes = { encoding: "utf8" as const, data: "[base64:/w==]" };
|
||||
const tree = buildKvKeyTree([
|
||||
{ key: "[base64:/w==]", keyIdentity: "ff", keyBytes: binaryBytes },
|
||||
{ key: "[base64:/w==]", keyIdentity: "5b6261736536343a2f773d3d5d", keyBytes: utf8Bytes },
|
||||
]);
|
||||
|
||||
expect(tree).toHaveLength(1);
|
||||
expect(tree[0]).toMatchObject({ kind: "group", id: "group:[base64:", label: "[base64:" });
|
||||
if (tree[0].kind !== "group") throw new Error("expected colliding display keys under their shared virtual directory");
|
||||
expect(tree[0].children.map((node) => node.id)).toEqual(["leaf:ff", "leaf:5b6261736536343a2f773d3d5d"]);
|
||||
expect(tree[0].children).toEqual([expect.objectContaining({ keyIdentity: "ff", keyBytes: binaryBytes }), expect.objectContaining({ keyIdentity: "5b6261736536343a2f773d3d5d", keyBytes: utf8Bytes })]);
|
||||
});
|
||||
|
||||
it("groups slash-delimited keys and sorts groups before leaves", () => {
|
||||
const tree = buildKvKeyTree([
|
||||
{ key: "/app/config/name", modRevision: 3 },
|
||||
@@ -45,4 +76,9 @@ describe("kv key tree", () => {
|
||||
expect([...next]).toEqual(["group:app"]);
|
||||
expect([...preserveKvExpandedGroupIds(tree, new Set(), true)].sort()).toEqual(["group:app", "group:app\u0000config", "group:service"]);
|
||||
});
|
||||
|
||||
it("preserves whether a virtual directory has a leading slash", () => {
|
||||
expect(kvKeyTreeNodePath(buildKvKeyTree([{ key: "/app/config/name" }])[0])).toBe("/app");
|
||||
expect(kvKeyTreeNodePath(buildKvKeyTree([{ key: "app/config/name" }])[0])).toBe("app");
|
||||
});
|
||||
});
|
||||
+30
-4
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { KvGetResponse } from "@/lib/backend/api";
|
||||
import { decideKvMetadataRefresh, knownKvLeaseKeys, KvListRequestGuard, mergeKvKeyMetadata, mergeKvValueRefresh, nextKvLeaseRefreshDelay, removeMissingKvKey, updateKvResponseTtl } from "@/lib/kv/kvMetadataRefresh";
|
||||
import { decideKvMetadataRefresh, hasPositiveKvLease, knownKvLeaseSummaries, KvListRequestGuard, mergeKvKeyMetadata, mergeKvValueRefresh, nextKvLeaseRefreshDelay, removeMissingKvKey, updateKvResponseTtl } from "@/lib/kv/kvMetadataRefresh";
|
||||
|
||||
function found(metadata: NonNullable<KvGetResponse["metadata"]>): KvGetResponse {
|
||||
return {
|
||||
@@ -83,10 +83,26 @@ describe("decideKvMetadataRefresh", () => {
|
||||
});
|
||||
|
||||
it("tracks only known leased keys and excludes the selected key", () => {
|
||||
const keys = [{ key: "/no-lease", lease: 0 }, { key: "/leased", lease: 10 }, { key: "/selected", lease: 20 }, { key: "/unknown" }];
|
||||
const keys = [{ key: "/no-lease", lease: 0 }, { key: "/leased", lease: "10" }, { key: "/selected", lease: 20 }, { key: "/unknown" }];
|
||||
|
||||
expect(knownKvLeaseKeys(keys, "/selected")).toEqual(["/leased"]);
|
||||
expect(knownKvLeaseKeys(keys, null)).toEqual(["/leased", "/selected"]);
|
||||
expect(knownKvLeaseSummaries(keys, "/selected")).toEqual([keys[1]]);
|
||||
expect(knownKvLeaseSummaries(keys, null)).toEqual([keys[1], keys[2]]);
|
||||
});
|
||||
|
||||
it("excludes only the selected raw-byte identity from lease refresh", () => {
|
||||
const keys = [
|
||||
{ key: "[base64:/w==]", keyIdentity: "ff", lease: 10 },
|
||||
{ key: "[base64:/w==]", keyIdentity: "5b6261736536343a2f773d3d5d", lease: 20 },
|
||||
];
|
||||
|
||||
expect(knownKvLeaseSummaries(keys, "ff")).toEqual([keys[1]]);
|
||||
});
|
||||
|
||||
it("recognizes positive lease IDs in the string-based int64 transport", () => {
|
||||
expect(hasPositiveKvLease("9007199254740993")).toBe(true);
|
||||
expect(hasPositiveKvLease(10)).toBe(true);
|
||||
expect(hasPositiveKvLease("0")).toBe(false);
|
||||
expect(hasPositiveKvLease("")).toBe(false);
|
||||
});
|
||||
|
||||
it("merges refreshed metadata without replacing the known value size and removes expired keys", () => {
|
||||
@@ -102,6 +118,16 @@ describe("decideKvMetadataRefresh", () => {
|
||||
expect(mergeKvKeyMetadata(keys, "/expired", { found: false })).toEqual([{ key: "/leased", lease: 10, ttl: 4, valueSize: 12 }]);
|
||||
});
|
||||
|
||||
it("refreshes and removes only the matching raw-byte identity when display keys collide", () => {
|
||||
const keys = [
|
||||
{ key: "[base64:/w==]", keyIdentity: "ff", lease: 10, ttl: 4, valueSize: 12 },
|
||||
{ key: "[base64:/w==]", keyIdentity: "5b6261736536343a2f773d3d5d", lease: 20, ttl: 8, valueSize: 24 },
|
||||
];
|
||||
|
||||
expect(mergeKvKeyMetadata(keys, "[base64:/w==]", found({ lease: 11, ttl: 3, modRevision: 5 }), "ff")).toEqual([{ key: "[base64:/w==]", keyIdentity: "ff", lease: 11, ttl: 3, modRevision: 5, valueSize: 12 }, keys[1]]);
|
||||
expect(removeMissingKvKey(keys, "[base64:/w==]", "ff")).toEqual([keys[1]]);
|
||||
});
|
||||
|
||||
it("backs off after failures and resets after a successful cycle", () => {
|
||||
expect(nextKvLeaseRefreshDelay(2000, true)).toBe(4000);
|
||||
expect(nextKvLeaseRefreshDelay(4000, true)).toBe(8000);
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { classifyKvMutationError, sanitizeKvMutationError } from "@/lib/kv/kvMutationError";
|
||||
|
||||
describe("KV mutation errors", () => {
|
||||
const noisyConflict = "Agent RPC error (-1): ETCD_CAS_CONFLICT: key changed after it was loaded. recent stderr: SLF4J(W): No SLF4J providers were found. io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider warning";
|
||||
|
||||
it("turns a duplicate create conflict into an actionable message", () => {
|
||||
expect(
|
||||
classifyKvMutationError(noisyConflict, true, {
|
||||
keyAlreadyExists: "同名 Key 已存在,请更换名称,或编辑现有 Key。",
|
||||
}),
|
||||
).toEqual({
|
||||
kind: "keyAlreadyExists",
|
||||
message: "同名 Key 已存在,请更换名称,或编辑现有 Key。",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps edit conflicts distinct from duplicate creates", () => {
|
||||
expect(classifyKvMutationError(noisyConflict, false, { conflict: "Key 已被修改,请刷新后重试。" })).toEqual({
|
||||
kind: "conflict",
|
||||
message: "Key 已被修改,请刷新后重试。",
|
||||
});
|
||||
});
|
||||
|
||||
it("removes RPC wrappers and unrelated Agent stderr from request errors", () => {
|
||||
expect(sanitizeKvMutationError("Agent RPC error (-1): etcdserver: request timed out. recent stderr: noisy")).toBe("etcdserver: request timed out");
|
||||
});
|
||||
});
|
||||
@@ -1,15 +1,22 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { refreshedKvSelectionKey } from "@/lib/kv/kvRefreshSelection";
|
||||
import { refreshedKvSelectionSummary } from "@/lib/kv/kvRefreshSelection";
|
||||
import type { KvKeySummary } from "@/lib/backend/api";
|
||||
|
||||
describe("kv refresh selection", () => {
|
||||
const keys: KvKeySummary[] = [{ key: "/app/config" }, { key: "/app/feature" }];
|
||||
|
||||
it("keeps the previously selected key when it still exists after refresh", () => {
|
||||
expect(refreshedKvSelectionKey("/app/config", keys)).toBe("/app/config");
|
||||
expect(refreshedKvSelectionSummary("/app/config", keys)).toEqual({ key: "/app/config" });
|
||||
});
|
||||
|
||||
it("clears the selected key when it no longer exists after refresh", () => {
|
||||
expect(refreshedKvSelectionKey("/app/missing", keys)).toBeNull();
|
||||
expect(refreshedKvSelectionSummary("/app/missing", keys)).toBeNull();
|
||||
});
|
||||
|
||||
it("does not switch to a colliding display key when the selected byte identity disappears", () => {
|
||||
const collision: KvKeySummary[] = [{ key: "[base64:/w==]", keyIdentity: "5b6261736536343a2f773d3d5d" }];
|
||||
|
||||
expect(refreshedKvSelectionSummary("ff", collision)).toBeNull();
|
||||
expect(refreshedKvSelectionSummary("5b6261736536343a2f773d3d5d", collision)).toEqual(collision[0]);
|
||||
});
|
||||
});
|
||||
+16
-1
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseOptionalTtl } from "@/lib/kv/kvTtl";
|
||||
import { parseKvLeaseId, parseOptionalTtl } from "@/lib/kv/kvTtl";
|
||||
|
||||
describe("parseOptionalTtl", () => {
|
||||
it("treats an empty TTL as a permanent key", () => {
|
||||
@@ -23,3 +23,18 @@ describe("parseOptionalTtl", () => {
|
||||
expect(parseOptionalTtl("9007199254740992")).toEqual({ ok: false });
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseKvLeaseId", () => {
|
||||
it("preserves lease IDs above JavaScript's safe integer limit", () => {
|
||||
expect(parseKvLeaseId("9007199254740993")).toBe("9007199254740993");
|
||||
expect(parseKvLeaseId("9223372036854775807")).toBe("9223372036854775807");
|
||||
});
|
||||
|
||||
it("rejects empty, non-positive, decimal, and overflowing lease IDs", () => {
|
||||
expect(parseKvLeaseId("")).toBeNull();
|
||||
expect(parseKvLeaseId("0")).toBeNull();
|
||||
expect(parseKvLeaseId("-1")).toBeNull();
|
||||
expect(parseKvLeaseId("1.5")).toBeNull();
|
||||
expect(parseKvLeaseId("9223372036854775808")).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { detectKvValueFormat, formatKvValue, validateKvValue } from "@/lib/kv/kvValueFormat";
|
||||
|
||||
describe("kv value formats", () => {
|
||||
it("detects structured UTF-8 values", () => {
|
||||
expect(detectKvValueFormat('{"enabled":true}')).toBe("json");
|
||||
expect(detectKvValueFormat("service:\n port: 8080")).toBe("yaml");
|
||||
expect(detectKvValueFormat("port: 8080\nenabled: true")).toBe("yaml");
|
||||
expect(detectKvValueFormat("<root><value>1</value></root>")).toBe("xml");
|
||||
expect(detectKvValueFormat("apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: app")).toBe("kubernetes");
|
||||
expect(detectKvValueFormat("SELECT * FROM users;")).toBe("sql");
|
||||
expect(detectKvValueFormat("server.port=8080\nfeature.enabled=true")).toBe("properties");
|
||||
expect(detectKvValueFormat("#!/usr/bin/env bash\nset -euo pipefail")).toBe("shell");
|
||||
expect(detectKvValueFormat("FROM alpine:3.22\nRUN echo ok")).toBe("dockerfile");
|
||||
expect(detectKvValueFormat("server {\n listen 80;\n}")).toBe("nginx");
|
||||
expect(detectKvValueFormat("hello")).toBe("text");
|
||||
});
|
||||
|
||||
it("validates and formats JSON", () => {
|
||||
expect(validateKvValue('{"ok":true}', "json")).toBeNull();
|
||||
expect(validateKvValue("{", "json")).toBeTruthy();
|
||||
expect(formatKvValue('{"ok":true}', "json")).toBe('{\n "ok": true\n}');
|
||||
});
|
||||
|
||||
it("validates base64 without decoding it through UTF-8", () => {
|
||||
expect(validateKvValue("AP+A", "base64")).toBeNull();
|
||||
expect(validateKvValue("***", "base64")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("validates configuration-oriented formats", () => {
|
||||
expect(validateKvValue("apiVersion: v1\nkind: ConfigMap", "kubernetes")).toBeNull();
|
||||
expect(validateKvValue("kind: ConfigMap", "kubernetes")).toContain("apiVersion");
|
||||
expect(validateKvValue("server.port=8080", "properties")).toBeNull();
|
||||
expect(validateKvValue("server.port", "properties")).toContain("Properties");
|
||||
expect(validateKvValue("FROM alpine\nRUN echo ok", "dockerfile")).toBeNull();
|
||||
expect(validateKvValue("UNKNOWN value", "dockerfile")).toContain("Dockerfile");
|
||||
expect(validateKvValue("server {\n listen 80;\n}", "nginx")).toBeNull();
|
||||
expect(validateKvValue("server {", "nginx")).toContain("unbalanced");
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { alignedSidebarCommentLabelWidths, sidebarTreeNaturalContentWidth, trailingCommentAvailableWidth, treeLabelWidthClass, usesFullWidthTreeLabel } from "@/lib/sidebar/sidebarTreeItemLayout";
|
||||
import { alignedSidebarCommentLabelWidths, canTreeNodeShowExpander, sidebarTreeNaturalContentWidth, trailingCommentAvailableWidth, treeLabelWidthClass, usesFullWidthTreeLabel } from "@/lib/sidebar/sidebarTreeItemLayout";
|
||||
|
||||
describe("sidebar tree item layout", () => {
|
||||
it("keeps a table row constrained when it displays a comment", () => {
|
||||
@@ -11,6 +11,11 @@ describe("sidebar tree item layout", () => {
|
||||
expect(treeLabelWidthClass({ fullWidth: false, hasTrailingComment: true })).toBe("min-w-0 flex-1 truncate");
|
||||
});
|
||||
|
||||
it("renders etcd Keys and Dashboard as aligned leaf actions", () => {
|
||||
expect(canTreeNodeShowExpander({ type: "etcd-root", childCount: 0 })).toBe(false);
|
||||
expect(canTreeNodeShowExpander({ type: "etcd-dashboard", childCount: 0 })).toBe(false);
|
||||
});
|
||||
|
||||
it("aligns comments to the longest sibling name without crossing parent groups", () => {
|
||||
const widths = alignedSidebarCommentLabelWidths([
|
||||
{ id: "tables", depth: 1, alignable: false, hasComment: false, labelWidth: 0 },
|
||||
|
||||
Reference in new issue
Block a user