test: drop source-text assertion tests and merge locale checks

This commit is contained in:
t8y2 committed 2026-09-23 22:10:06 +08:00
1 parent 349d77d180
commit 8897e12714
257 files changed
+166 -12815

No files matched your search

@@ -1,53 +0,0 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const browserSource = readFileSync(new URL("../KvKeyBrowser.vue", import.meta.url), "utf8");
const etcdBrowserSource = readFileSync(new URL("../../etcd/EtcdKeyBrowser.vue", import.meta.url), "utf8");
describe("KvKeyBrowser node export", () => {
it("keeps directory toggles out of the detail-loading path", () => {
expect(browserSource).toContain('if (node.kind === "lazy") return node.hasValue === true;');
expect(browserSource).toContain("if (props.enableNodeActions && nodeHasValue(node)) void loadSelectedKey(routeFromNode(node));");
expect(browserSource).not.toContain("function nodeMayHaveValue");
});
it("keeps an expanded virtual Consul directory open when its exact Key probe is absent", () => {
expect(browserSource).toContain("const lazyNode = lazyTreeState.nodeByKey.get(key);");
expect(browserSource).toContain("if (lazyNode?.hasChildren)");
expect(browserSource).toContain("lazyNode.hasValue = false;");
expect(browserSource).toContain("void refreshLazyParent(parentLazyKvPath(key, props.lazyPathStyle));");
});
it("shows export for both value keys and virtual directories", () => {
expect(browserSource).toContain("if (props.api.exportScope || nodeHasValue(node))");
expect(browserSource).toContain('kind: nodeIsExpandable(node) ? "prefix" : "key"');
expect(browserSource).toContain("await props.api.exportScope(props.connectionId, request)");
});
it("delegates etcd directory export to a fixed-revision recursive scan", () => {
expect(etcdBrowserSource).toContain("exportScope: exportEtcdNodeScope");
expect(etcdBrowserSource).toContain("const scan = await scanConnection(connectionId, request.path)");
expect(etcdBrowserSource).toContain("isKeyInKvExportScope(displayKey(keyValue(entry)), request)");
expect(etcdBrowserSource).toContain("const missingValue = entries.find((entry) => !entry.value)");
});
it("compares canonical Key bytes without exposing mirror-delete operations", () => {
expect(etcdBrowserSource).toContain("id: `source:${kvValueByteIdentity(source.key)}`");
expect(etcdBrowserSource).not.toContain("id: source.key.data");
expect(etcdBrowserSource).not.toContain("mirrorDeletes");
expect(etcdBrowserSource).not.toContain('operation: "delete"');
});
it("snapshots the target and invalidates stale transfer previews", () => {
expect(etcdBrowserSource).toContain("const targetId = targetConnectionId.value");
expect(etcdBrowserSource).toContain("const generation = ++transferPreviewGeneration");
expect(etcdBrowserSource).toContain("if (generation !== transferPreviewGeneration) return");
expect(etcdBrowserSource).toContain(':disabled="transferLoading || transferApplying"');
});
it("refreshes a partial batch before allowing the remaining operations to retry", () => {
expect(etcdBrowserSource).toContain('row.operation = "applied"');
expect(etcdBrowserSource).toContain("await previewTransfer()");
expect(etcdBrowserSource).toContain('t("etcd.transferPartiallyApplied"');
});
});
@@ -1,68 +0,0 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const browserSource = readFileSync(new URL("../KvKeyBrowser.vue", import.meta.url), "utf8");
describe("KvKeyBrowser search and split layout", () => {
it("uses the requested prefix for a server-side, paginated search", () => {
expect(browserSource).toContain("props.api.listPrefix(connectionId, searchQuery, pageSize, reset ? null : continuation.value");
expect(browserSource).not.toContain("async function searchAllKeys");
expect(browserSource).not.toContain("filterKvKeysBySearch(result.keys, query)");
});
it("focuses a matching Consul directory instead of nesting it beneath itself", () => {
expect(browserSource).toContain('const focusedDirectory = props.lazyPathStyle === "relative" && rootPath && !rootPath.endsWith("/")');
expect(browserSource).toContain("key.key === `${rootPath}/`");
expect(browserSource).toContain("const childResult = await props.api.listPrefix(context.connectionId, focusedDirectory.key, pageSize, null, { recursive: false });");
expect(browserSource).toContain("if (rootSummary?.hasValue !== true)");
expect(browserSource).toContain("hasValue: true");
});
it("offers debounced, server-backed prefix completion for lazy Consul trees", () => {
expect(browserSource).toContain("const remoteKeySuggestions = ref<KvKeySummary[]>([]);");
expect(browserSource).toContain("const keySuggestionDebounceMs = 300;");
expect(browserSource).toContain("function scheduleRemoteKeySuggestions(value: string)");
expect(browserSource).toContain("listPrefix(connectionId, query, 8, null, { recursive: false })");
expect(browserSource).toContain("const candidates = props.lazyHierarchy ? [...lazyTreeState.nodeByKey.values(), ...remoteKeySuggestions.value] : keys.value;");
expect(browserSource).toContain('autocomplete="off"');
expect(browserSource).toContain('<Popover :open="showKeySuggestions">');
expect(browserSource).toContain('<PopoverContent v-if="showKeySuggestions" id="kv-key-prefix-suggestions"');
expect(browserSource).toContain('if (props.lazyHierarchy && suggestion.key.endsWith("/"))');
expect(browserSource).toContain("scheduleRemoteKeySuggestions(suggestion.key);");
expect(browserSource).toContain('event.key !== "Enter" && event.key !== "Tab"');
});
it("drops stale lazy tree responses after a connection or root generation changes", () => {
expect(browserSource).toContain("generation: ++keyLoadGeneration");
expect(browserSource).toContain("function lazyLoadContextValid(context: LazyLoadContext)");
expect(browserSource).toContain("context.connectionId === props.connectionId");
expect(browserSource).toContain("lazyTreeState.nodeByKey.get(parentKey) !== node");
expect(browserSource).toContain("keyLoadGeneration++;");
});
it("shows list request errors instead of the empty-state message", () => {
expect(browserSource).toContain('const listError = ref("");');
expect(browserSource.match(/listError\.value = formatError\(error\);/g)).toHaveLength(2);
expect(browserSource.indexOf('v-else-if="listError"')).toBeLessThan(browserSource.indexOf('v-else-if="visibleRows.length === 0"'));
});
it("highlights the matching search query only for the selected search result", () => {
expect(browserSource).toContain("interface KvSearchHighlight");
expect(browserSource).toMatch(/const activeSearchHighlight = computed\(\(\) => \(?props\.searchHighlight\?\.key === selectedKey\.value/);
expect(browserSource).toContain("function highlightText(value: string, enabled: boolean)");
expect(browserSource).toContain("selectedValueHighlightSegments");
});
it("does not select Key text while opening its context menu", () => {
expect(browserSource).toContain("select-none items-center");
expect(browserSource).toContain("@mousedown.right.prevent");
});
it("uses a persisted draggable split between the Key tree and details", () => {
expect(browserSource).toContain('<Splitpanes class="kv-browser-splitpanes min-h-0 flex-1" @resized="handleKvBrowserSplitResized">');
expect(browserSource).toContain('<Pane :size="kvBrowserSplitSize" min-size="20" max-size="70">');
expect(browserSource).toContain('<Pane :size="100 - kvBrowserSplitSize" min-size="30">');
expect(browserSource).toContain("safeLocalStorageSet(kvBrowserSplitSizeStorageKey, String(size))");
expect(browserSource).toContain("cursor: col-resize");
});
});
@@ -1,19 +0,0 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const browserSource = readFileSync(new URL("../KvKeyBrowser.vue", import.meta.url), "utf8");
describe("KvKeyBrowser TTL details", () => {
it("renders the selected key TTL and refreshes it every second", () => {
expect(browserSource).toContain("const selectedTtlLabel = computed");
expect(browserSource).toContain('<Badge v-if="selectedTtlLabel" variant="outline">TTL {{ selectedTtlLabel }}</Badge>');
expect(browserSource).toContain("metadataRefreshTimer = setInterval");
expect(browserSource).toContain("void refreshSelectedMetadata(key, generation)");
});
it("stops TTL polling when the browser unmounts", () => {
expect(browserSource).toContain("onBeforeUnmount(() =>");
expect(browserSource).toContain("stopKeyListRefresh()");
expect(browserSource).toContain("stopMetadataRefresh()");
});
});