fix(tests): remove low-value source snapshots and define test standards

This commit is contained in:
t8y2 committed 2026-09-11 11:51:24 +08:00
1 parent ead906477f
commit 8186c697d5
80 files changed
+14 -2225

No files matched your search

@@ -1,44 +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 valueEditorSource = readFileSync(new URL("../KvValueEditor.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 || !editKeyWritable"');
});
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"');
});
it("keeps an accessible copy action in the upper-right corner of the value panel", () => {
expect(browserSource).toContain('class="absolute right-2 top-2 z-10 h-8 w-8');
expect(browserSource).toContain('@click="copySelectedValue"');
expect(browserSource).toContain('<Check v-if="selectedValueCopied"');
expect(browserSource).toContain('<Copy v-else class="h-4 w-4" />');
expect(browserSource).toMatch(/<pre\s+data-native-clipboard/);
});
it("keeps the selected value preview word wrapping aligned with the global editor setting", () => {
expect(browserSource).toContain(":class=\"settingsStore.editorSettings.wordWrap ? 'whitespace-pre-wrap break-words' : 'whitespace-pre'\"");
expect(browserSource).not.toContain("bg-muted/20 whitespace-pre-wrap break-words p-3");
});
it("keeps shared KV value editor word wrapping aligned with the global editor setting", () => {
expect(valueEditorSource).toContain("const wordWrapCompartment = new Compartment()");
expect(valueEditorSource).toContain("wordWrapCompartment.of(wordWrapExtension())");
expect(valueEditorSource).toContain("wordWrapCompartment.reconfigure(wordWrapExtension(wordWrap))");
expect(valueEditorSource).not.toContain("\n EditorView.lineWrapping,\n");
});
});
@@ -1,17 +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 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`);
});
});
@@ -1,26 +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 Base64 UTF-8 preview", () => {
it("keeps the preview opt-in for backend-specific wrappers", () => {
expect(browserSource).toContain("enableBase64Utf8Preview?: boolean");
expect(browserSource).toContain("enableBase64Utf8Preview: false");
});
it("copies the selected derived view while preserving the raw value path", () => {
expect(browserSource).toContain("selectedValueClipboardText");
expect(browserSource).toContain("copyToClipboard(selectedValueClipboardText.value)");
expect(browserSource.match(/selectedBase64ViewMode\.value = "utf8"/g)).toHaveLength(2);
expect(browserSource).toContain("editValue.value = selectedTextValue.value");
expect(browserSource).toContain("value: selectedValue.value.value");
});
it("offers explicit UTF-8 and Base64 view controls with error feedback", () => {
expect(browserSource).toContain('data-testid="kv-base64-utf8-view"');
expect(browserSource).toContain('data-testid="kv-base64-raw-view"');
expect(browserSource).toContain("labels.utf8PreviewLossy");
expect(browserSource).toContain("labels.utf8PreviewUnavailable");
});
});