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,
|
||||
|
||||
Reference in new issue
Block a user