1 parent
3232195e1f
commit
68b0ab0476
17 files changed
+146
-9
No files matched your search
@@ -279,6 +279,16 @@ describe("normalizeEditorSettings", () => {
|
||||
expect(invalid.dataGridBooleanDisplayMode).toBe("dropdown");
|
||||
});
|
||||
|
||||
it("defaults the cell detail hover button on and preserves only boolean values", () => {
|
||||
expect(normalizeEditorSettings({}).dataGridCellDetailButtonVisible).toBe(true);
|
||||
expect(normalizeEditorSettings({ dataGridCellDetailButtonVisible: true }).dataGridCellDetailButtonVisible).toBe(true);
|
||||
expect(normalizeEditorSettings({ dataGridCellDetailButtonVisible: false }).dataGridCellDetailButtonVisible).toBe(false);
|
||||
|
||||
for (const invalidValue of [0, 1, "false", null]) {
|
||||
expect(normalizeEditorSettings({ dataGridCellDetailButtonVisible: invalidValue as never }).dataGridCellDetailButtonVisible).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("defaults the data grid font and preserves a custom font family", () => {
|
||||
const defaultFontFamily = `"Geist Variable Tabular", "Geist Variable", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif`;
|
||||
expect(normalizeEditorSettings({}).tableFontFamily).toBe(defaultFontFamily);
|
||||
@@ -732,6 +742,28 @@ describe("settingsStore persisted settings initialization", () => {
|
||||
expect(saveEditorSettings).toHaveBeenLastCalledWith(expect.objectContaining({ openDataTabsNextToActive: false }));
|
||||
});
|
||||
|
||||
it("loads, persists, and reloads the cell detail button visibility", async () => {
|
||||
let persistedSettings: Record<string, unknown> = { dataGridCellDetailButtonVisible: false };
|
||||
const loadEditorSettings = vi.fn(async () => JSON.parse(JSON.stringify(persistedSettings)));
|
||||
const saveEditorSettings = vi.fn(async (settings: Record<string, unknown>) => {
|
||||
persistedSettings = JSON.parse(JSON.stringify(settings));
|
||||
});
|
||||
vi.doMock("@/lib/backend/api", () => ({ loadEditorSettings, saveEditorSettings }));
|
||||
|
||||
const { useSettingsStore } = await import("@/stores/settingsStore");
|
||||
const store = useSettingsStore();
|
||||
await store.initEditorSettings();
|
||||
|
||||
expect(store.editorSettings.dataGridCellDetailButtonVisible).toBe(false);
|
||||
await store.updateEditorSettingsAndPersist({ dataGridCellDetailButtonVisible: true });
|
||||
expect(saveEditorSettings).toHaveBeenLastCalledWith(expect.objectContaining({ dataGridCellDetailButtonVisible: true }));
|
||||
|
||||
setActivePinia(createPinia());
|
||||
const restartedStore = useSettingsStore();
|
||||
await restartedStore.initEditorSettings();
|
||||
expect(restartedStore.editorSettings.dataGridCellDetailButtonVisible).toBe(true);
|
||||
});
|
||||
|
||||
it("loads, persists, and reloads hidden query editor line numbers", async () => {
|
||||
let persistedSettings: Record<string, unknown> = { showLineNumbers: true };
|
||||
const loadEditorSettings = vi.fn(async () => JSON.parse(JSON.stringify(persistedSettings)));
|
||||
|
||||
Reference in new issue
Block a user