1 parent
b2cf487734
commit
fe269a28db
14 files changed
+209
-6
No files matched your search
@@ -43,6 +43,8 @@ const labels = computed(() => ({
|
||||
saved: t("zookeeper.saved"),
|
||||
deleted: t("zookeeper.deleted"),
|
||||
base64Readonly: t("zookeeper.base64Readonly"),
|
||||
utf8PreviewLossy: t("zookeeper.utf8PreviewLossy"),
|
||||
utf8PreviewUnavailable: t("zookeeper.utf8PreviewUnavailable"),
|
||||
createMode: t("zookeeper.createMode"),
|
||||
add: t("zookeeper.add"),
|
||||
value: t("zookeeper.value"),
|
||||
@@ -67,5 +69,5 @@ defineExpose({ focusSearch, refresh });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<KvKeyBrowser ref="browserRef" :connection-id="props.connectionId" :api="zookeeperApi" :labels="labels" supports-create-modes enable-node-actions metadata-style="zookeeper" lazy-hierarchy :create-mode-options="createModeOptions" />
|
||||
<KvKeyBrowser ref="browserRef" :connection-id="props.connectionId" :api="zookeeperApi" :labels="labels" supports-create-modes enable-node-actions enable-base64-utf8-preview metadata-style="zookeeper" lazy-hierarchy :create-mode-options="createModeOptions" />
|
||||
</template>
|
||||
@@ -0,0 +1,58 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { createApp, defineComponent, h, type App } from "vue";
|
||||
|
||||
vi.mock("vue-i18n", () => ({
|
||||
useI18n: () => ({ t: (key: string) => key }),
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/backend/api", () => ({
|
||||
zookeeperListPrefix: vi.fn(),
|
||||
zookeeperGet: vi.fn(),
|
||||
zookeeperPut: vi.fn(),
|
||||
zookeeperDelete: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/components/kv/KvKeyBrowser.vue", () => ({
|
||||
default: defineComponent({
|
||||
name: "KvKeyBrowserStub",
|
||||
props: {
|
||||
enableBase64Utf8Preview: { type: Boolean, default: false },
|
||||
labels: { type: Object, required: true },
|
||||
},
|
||||
setup(props) {
|
||||
return () =>
|
||||
h("div", {
|
||||
id: "kv-browser-stub",
|
||||
"data-base64-utf8-preview": String(props.enableBase64Utf8Preview),
|
||||
"data-lossy-label": (props.labels as Record<string, string>).utf8PreviewLossy,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
import ZooKeeperKeyBrowser from "@/components/zookeeper/ZooKeeperKeyBrowser.vue";
|
||||
|
||||
let app: App<Element> | null = null;
|
||||
let root: HTMLDivElement | null = null;
|
||||
|
||||
afterEach(() => {
|
||||
app?.unmount();
|
||||
root?.remove();
|
||||
app = null;
|
||||
root = null;
|
||||
});
|
||||
|
||||
describe("ZooKeeperKeyBrowser", () => {
|
||||
it("enables the Base64 UTF-8 preview with ZooKeeper labels", () => {
|
||||
root = document.createElement("div");
|
||||
document.body.appendChild(root);
|
||||
app = createApp(ZooKeeperKeyBrowser, { connectionId: "zookeeper-1" });
|
||||
app.mount(root);
|
||||
|
||||
const browser = root.querySelector("#kv-browser-stub");
|
||||
expect(browser?.getAttribute("data-base64-utf8-preview")).toBe("true");
|
||||
expect(browser?.getAttribute("data-lossy-label")).toBe("zookeeper.utf8PreviewLossy");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user