1 parent
43ddfce93d
commit
e9998e2806
21 files changed
+563
-7
No files matched your search
@@ -20,6 +20,25 @@ import type { AiConfigItem } from "@/types/ai";
|
||||
import { DATA_GRID_EXTRACTOR_OPTIONS_MIGRATION_VERSION } from "@/lib/dataGrid/dataGridCopyExtractor";
|
||||
|
||||
describe("normalizeEditorSettings", () => {
|
||||
it("defaults and sanitizes AI conversation typography independently", () => {
|
||||
expect(normalizeEditorSettings({})).toMatchObject({ aiFontFamily: "", aiFontSize: 12 });
|
||||
expect(
|
||||
normalizeEditorSettings({
|
||||
fontFamily: "SQL editor font",
|
||||
uiFontFamily: "Interface font",
|
||||
aiFontFamily: " 'Atkinson Hyperlegible', sans-serif\n",
|
||||
aiFontSize: 17.6,
|
||||
}),
|
||||
).toMatchObject({
|
||||
fontFamily: "SQL editor font",
|
||||
uiFontFamily: "Interface font",
|
||||
aiFontFamily: "'Atkinson Hyperlegible', sans-serif",
|
||||
aiFontSize: 18,
|
||||
});
|
||||
expect(normalizeEditorSettings({ aiFontFamily: null, aiFontSize: 999 } as any)).toMatchObject({ aiFontFamily: "", aiFontSize: 24 });
|
||||
expect(normalizeEditorSettings({ aiFontSize: "18" } as any).aiFontSize).toBe(12);
|
||||
});
|
||||
|
||||
it("defaults DDL viewing to a dialog and preserves the selected open mode", () => {
|
||||
expect(DEFAULT_EDITOR_SETTINGS.ddlOpenMode).toBe("dialog");
|
||||
expect(normalizeEditorSettings({}).ddlOpenMode).toBe("dialog");
|
||||
@@ -1157,6 +1176,49 @@ describe("settingsStore persisted settings initialization", () => {
|
||||
expect(saveEditorSettings).toHaveBeenLastCalledWith(expect.objectContaining({ tableCompletionSchemaQualification: "always" }));
|
||||
});
|
||||
|
||||
it("persists and resets AI typography without changing editor or interface fonts", async () => {
|
||||
const loadEditorSettings = vi.fn().mockResolvedValue({
|
||||
fontFamily: "SQL editor font",
|
||||
uiFontFamily: "Interface font",
|
||||
});
|
||||
const saveEditorSettings = vi.fn().mockResolvedValue(undefined);
|
||||
vi.doMock("@/lib/backend/api", () => ({ loadEditorSettings, saveEditorSettings }));
|
||||
|
||||
const { useSettingsStore } = await import("@/stores/settingsStore");
|
||||
const store = useSettingsStore();
|
||||
await store.initEditorSettings();
|
||||
saveEditorSettings.mockClear();
|
||||
|
||||
await store.updateEditorSettingsAndPersist({ aiFontFamily: " Georgia, serif ", aiFontSize: 18 });
|
||||
|
||||
expect(store.editorSettings).toMatchObject({
|
||||
fontFamily: "SQL editor font",
|
||||
uiFontFamily: "Interface font",
|
||||
aiFontFamily: "Georgia, serif",
|
||||
aiFontSize: 18,
|
||||
});
|
||||
expect(saveEditorSettings).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({
|
||||
fontFamily: "SQL editor font",
|
||||
uiFontFamily: "Interface font",
|
||||
aiFontFamily: "Georgia, serif",
|
||||
aiFontSize: 18,
|
||||
}),
|
||||
);
|
||||
|
||||
await store.updateEditorSettingsAndPersist({
|
||||
aiFontFamily: DEFAULT_EDITOR_SETTINGS.aiFontFamily,
|
||||
aiFontSize: DEFAULT_EDITOR_SETTINGS.aiFontSize,
|
||||
});
|
||||
|
||||
expect(store.editorSettings).toMatchObject({
|
||||
fontFamily: "SQL editor font",
|
||||
uiFontFamily: "Interface font",
|
||||
aiFontFamily: "",
|
||||
aiFontSize: 12,
|
||||
});
|
||||
});
|
||||
|
||||
it("loads and persists the substitution switch without discarding syntax overrides", async () => {
|
||||
const loadEditorSettings = vi.fn().mockResolvedValue({
|
||||
sqlVariableSubstitutionEnabled: false,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { normalizePluginShortcutSettings, type PluginShortcutSettings } from "@/
|
||||
import { defineStore } from "pinia";
|
||||
import { computed, ref } from "vue";
|
||||
import { aiConfigToItem, generateId, getConfigKey } from "@/lib/ai/aiConfigList";
|
||||
import { AI_CONVERSATION_FONT_FAMILY_DEFAULT, AI_CONVERSATION_FONT_SIZE_DEFAULT, normalizeAiConversationFontFamily, normalizeAiConversationFontSize } from "@/lib/ai/aiTypography";
|
||||
import { DEFAULT_DATA_GRID_FONT_FAMILY, DEFAULT_UI_FONT_FAMILY } from "@/lib/app/appFonts";
|
||||
import { emitAlwaysOnTopToolbarVisibilityChanged } from "@/lib/app/windowAlwaysOnTop";
|
||||
import { defaultBackgroundImageSettings, normalizeBackgroundImageSettings, type BackgroundImageSettings } from "@/lib/app/appBackgroundImage";
|
||||
@@ -827,6 +828,8 @@ export interface EditorSettings {
|
||||
fontFamily: string;
|
||||
fontSize: number;
|
||||
uiFontFamily: string;
|
||||
aiFontFamily: string;
|
||||
aiFontSize: number;
|
||||
uiScale: number;
|
||||
theme: EditorTheme;
|
||||
backgroundImage: BackgroundImageSettings;
|
||||
@@ -1113,6 +1116,8 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
|
||||
fontFamily: "'Fira Code', 'Cascadia Code', 'Cascadia Mono', 'JetBrains Mono', monospace",
|
||||
fontSize: 13,
|
||||
uiFontFamily: DEFAULT_UI_FONT_FAMILY,
|
||||
aiFontFamily: AI_CONVERSATION_FONT_FAMILY_DEFAULT,
|
||||
aiFontSize: AI_CONVERSATION_FONT_SIZE_DEFAULT,
|
||||
uiScale: 1,
|
||||
theme: "app",
|
||||
backgroundImage: defaultBackgroundImageSettings(),
|
||||
@@ -1642,6 +1647,8 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>, exist
|
||||
fontFamily: normalizeFontFamily(settings.fontFamily, DEFAULT_EDITOR_SETTINGS.fontFamily),
|
||||
fontSize: settings.fontSize ?? DEFAULT_EDITOR_SETTINGS.fontSize,
|
||||
uiFontFamily: normalizeFontFamily(settings.uiFontFamily, DEFAULT_EDITOR_SETTINGS.uiFontFamily),
|
||||
aiFontFamily: normalizeAiConversationFontFamily(settings.aiFontFamily),
|
||||
aiFontSize: normalizeAiConversationFontSize(settings.aiFontSize),
|
||||
uiScale: normalizeUiScale(settings.uiScale),
|
||||
theme: settings.theme && EDITOR_THEME_VALUES.has(settings.theme) ? settings.theme : DEFAULT_EDITOR_SETTINGS.theme,
|
||||
customThemeColors: {
|
||||
@@ -2486,6 +2493,8 @@ export const useSettingsStore = defineStore("settings", () => {
|
||||
if (partial.fontFamily !== undefined) editorSettings.value.fontFamily = normalizeFontFamily(partial.fontFamily, DEFAULT_EDITOR_SETTINGS.fontFamily);
|
||||
if (partial.fontSize !== undefined) editorSettings.value.fontSize = partial.fontSize;
|
||||
if (partial.uiFontFamily !== undefined) editorSettings.value.uiFontFamily = normalizeFontFamily(partial.uiFontFamily, DEFAULT_EDITOR_SETTINGS.uiFontFamily);
|
||||
if (partial.aiFontFamily !== undefined) editorSettings.value.aiFontFamily = normalizeAiConversationFontFamily(partial.aiFontFamily);
|
||||
if (partial.aiFontSize !== undefined) editorSettings.value.aiFontSize = normalizeAiConversationFontSize(partial.aiFontSize);
|
||||
if (partial.uiScale !== undefined) editorSettings.value.uiScale = normalizeUiScale(partial.uiScale);
|
||||
if (partial.backgroundImage !== undefined) editorSettings.value.backgroundImage = normalizeBackgroundImageSettings(partial.backgroundImage);
|
||||
if (partial.theme !== undefined) editorSettings.value.theme = partial.theme;
|
||||
|
||||
Reference in new issue
Block a user