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,42 @@
|
||||
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("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), entry.key), request)");
|
||||
expect(etcdBrowserSource).toContain("const missingValue = entries.find((entry) => !entry.value)");
|
||||
});
|
||||
|
||||
it("keeps mirror deletes inside the exported directory and compares canonical Key bytes", () => {
|
||||
expect(etcdBrowserSource).toContain("if (!isKeyInKvExportScope(shown, mirrorScope)");
|
||||
expect(etcdBrowserSource).toContain("sourceKeys.has(kvValueByteIdentity(bytes))");
|
||||
expect(etcdBrowserSource).toContain("id: `source:${kvValueByteIdentity(source.key)}`");
|
||||
expect(etcdBrowserSource).not.toContain("id: source.key.data");
|
||||
expect(etcdBrowserSource).toContain('const mirrorDeleteAvailable = computed(() => transferBundle.value?.scopeKind === "prefix")');
|
||||
expect(etcdBrowserSource).toContain(':disabled="!mirrorDeleteAvailable || transferLoading || transferApplying"');
|
||||
});
|
||||
|
||||
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"');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const browserSource = readFileSync(new URL("../KvKeyBrowser.vue", import.meta.url), "utf8");
|
||||
|
||||
describe("KvKeyBrowser edit dialog layout", () => {
|
||||
it("keeps the value format label and selector together in the editor toolbar", () => {
|
||||
expect(browserSource).toContain('class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"');
|
||||
expect(browserSource).toContain('class="flex shrink-0 items-center gap-3"');
|
||||
expect(browserSource).toContain('<SelectTrigger class="h-9 w-44">');
|
||||
});
|
||||
|
||||
it("cancels the shared footer negative margin and preserves bottom safe spacing", () => {
|
||||
expect(browserSource).toContain('<DialogFooter class="mx-0 mb-0 shrink-0 gap-3 border-t bg-muted/10 px-6 py-5">');
|
||||
expect(browserSource).toContain('variant="outline" class="h-10 min-w-20"');
|
||||
expect(browserSource).toContain('<Button class="h-10 min-w-20" :disabled="saving || readOnly"');
|
||||
});
|
||||
|
||||
it("applies the same safe spacing to the history dialog footer", () => {
|
||||
expect(browserSource).toContain('<DialogFooter class="mx-0 mb-0 shrink-0 border-t px-6 py-5">');
|
||||
expect(browserSource).toContain('class="h-10 min-w-20" @click="showHistoryDialog = false"');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const browserSource = readFileSync(new URL("../KvKeyBrowser.vue", import.meta.url), "utf8");
|
||||
|
||||
describe("KvKeyBrowser mutation errors", () => {
|
||||
it("shows duplicate-key conflicts next to the Key field", () => {
|
||||
expect(browserSource).toContain("classifyKvMutationError(error, isCreating.value");
|
||||
expect(browserSource).toContain(`:aria-invalid="editErrorKind === 'keyAlreadyExists'"`);
|
||||
expect(browserSource).toContain(`v-if="editError && editErrorKind === 'keyAlreadyExists'"`);
|
||||
});
|
||||
|
||||
it("clears the duplicate warning after the Key name changes", () => {
|
||||
expect(browserSource).toContain("watch(editKey, () =>");
|
||||
expect(browserSource).toContain(`if (editErrorKind.value !== "keyAlreadyExists") return`);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
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("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");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
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()");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user