25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(settings): hide the reveal toggle for a saved snippet passphrase (#12847)
Thanadon Kongkanunb20151829a4a
diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vueindex 4a4c2ae732..fb613aa621 100644--- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue+++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue@@ -11006,7 +11006,7 @@ LIMIT 100;</pre></div><div class="space-y-2 md:col-span-2"><Label for="snippet-sync-passphrase">{{ t("settings.syncSnippetPassphrase") }}</Label>- <PasswordInput id="snippet-sync-passphrase" v-model="snippetPassphrase" :placeholder="snippetHasSavedPassphrase ? '••••••••' : ''" autocomplete="new-password" />+ <PasswordInput id="snippet-sync-passphrase" v-model="snippetPassphrase" :placeholder="snippetHasSavedPassphrase ? '••••••••' : ''" :show-toggle="!snippetHasSavedPassphrase || !!snippetPassphrase" autocomplete="new-password" /><div class="flex items-center justify-between gap-3"><label class="flex items-center gap-2 text-xs text-muted-foreground"><input v-model="snippetRememberPassphrase" type="checkbox" class="h-4 w-4 shrink-0 accent-primary" />diff --git a/apps/desktop/src/components/editor/__tests__/EditorSettingsDialog.snippetPassphraseToggle.integration.spec.ts b/apps/desktop/src/components/editor/__tests__/EditorSettingsDialog.snippetPassphraseToggle.integration.spec.tsnew file mode 100644index 0000000000..04a0194c0e--- /dev/null+++ b/apps/desktop/src/components/editor/__tests__/EditorSettingsDialog.snippetPassphraseToggle.integration.spec.ts@@ -0,0 +1,115 @@+// @vitest-environment happy-dom++import { createApp, defineComponent, h, nextTick, type App } from "vue";+import { createPinia, setActivePinia } from "pinia";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import i18n from "@/i18n";+import { writeSyncMethod } from "@/lib/webdav/webdavAutoUploadConfig";+import { useSettingsStore } from "@/stores/settingsStore";+import EditorSettingsDialog from "../EditorSettingsDialog.vue";++const backend = vi.hoisted(() => ({ hasSavedPassphrase: false }));++vi.mock("@/lib/backend/api", async (importOriginal) => {+ const actual = await importOriginal<typeof import("@/lib/backend/api")>();+ return {+ ...actual,+ loadEditorSettings: async () => null,+ saveEditorSettings: async () => undefined,+ loadHistoryRetentionLimit: async () => 5000,+ loadMcpHistoryRetentionLimit: async () => 5000,+ loadMcpGlobalPolicy: async () => null,+ loadDesktopSettings: async () => null,+ loadAiConfigs: async () => [],+ loadAiConfig: async () => null,+ loadAiProviderConfigs: async () => ({}),+ loadAiChatSelection: async () => null,+ webdavSyncSecretsStatus: async () => ({}),+ webdavPasswordStatus: async () => ({}),+ snippetTokenStatus: async () => ({ hasSavedToken: false }),+ snippetPassphraseStatus: async () => ({ hasSavedPassphrase: backend.hasSavedPassphrase }),+ snippetSavedTokenStatus: async () => ({}),+ snippetSyncSettings: async () => ({}),+ getAppSupportInfo: async () => {+ throw new Error("unavailable in tests");+ },+ listInstalledAgentsLocal: async () => [],+ checkMcpServerStatus: async () => {+ throw new Error("unavailable in tests");+ },+ };+});++let app: App | undefined;+let host: HTMLElement;++async function settle() {+ for (let i = 0; i < 10; i++) {+ await Promise.resolve();+ await nextTick();+ }+}++beforeEach(() => {+ backend.hasSavedPassphrase = false;+ localStorage.clear();+ writeSyncMethod("snippet");+});++afterEach(() => {+ app?.unmount();+ host?.remove();+ document.body.innerHTML = "";+ app = undefined;+});++async function mountSyncTab() {+ const pinia = createPinia();+ setActivePinia(pinia);+ const store = useSettingsStore();+ await store.initEditorSettings();+ await store.initDesktopSettings();+ host = document.createElement("div");+ document.body.append(host);+ app = createApp(+ defineComponent({+ setup: () => () => h(EditorSettingsDialog, { variant: "page", open: true, initialTab: "sync", "onUpdate:open": () => undefined }),+ }),+ );+ app.use(pinia);+ app.use(i18n);+ app.mount(host);+ await settle();+}++function passphraseInput() {+ const input = host.querySelector<HTMLInputElement>("#snippet-sync-passphrase");+ expect(input).toBeTruthy();+ return input!;+}++function passphraseToggle() {+ return passphraseInput().parentElement!.querySelector<HTMLButtonElement>("button");+}++describe("EditorSettingsDialog snippet passphrase toggle", () => {+ it("shows the toggle for a passphrase typed in this session", async () => {+ await mountSyncTab();+ expect(passphraseToggle()).toBeTruthy();+ });++ it("hides the toggle while the field only shows the saved-passphrase placeholder", async () => {+ backend.hasSavedPassphrase = true;+ await mountSyncTab();+ await vi.waitFor(() => expect(passphraseInput().placeholder).toBe("••••••••"), { timeout: 5000 });+ expect(passphraseToggle()).toBeNull();++ const input = passphraseInput();+ input.value = "new-passphrase";+ input.dispatchEvent(new Event("input"));+ await settle();+ passphraseToggle()!.click();+ await settle();+ expect(passphraseInput().type).toBe("text");+ });+});