* refactor: Stores barrel imports + SSR gates * refactor: Drop agenticStore wrapper exports * refactor: Drop chatStore wrapper exports * refactor: Drop modelsStore wrapper exports * refactor: Drop serverStore wrapper exports * refactor: Drop unused mcpStore wrapper exports * refactor: Drop mcpResourceStore wrapper exports * refactor: Drop conversationsStore wrapper exports + move buildConversationTree to utils * refactor: Drop settingsStore wrapper exports * refactor: Drop unused toolsStore wrapper exports * refactor: Fix lint errors from store wrapper removal * fix: Missing change * refactor: Cleanup * refactor: Context Stats store
65 lines
2.5 KiB
TypeScript
65 lines
2.5 KiB
TypeScript
// Guards the unfolding of `renderContentAsRawText` back onto the two
|
|
// per-surface render keys. The single toggle carried user content and
|
|
// thinking at once, so only the user key is restored from it and thinking
|
|
// returns to its own default. The toggle is removed from the persisted
|
|
// config so it does not stay orphaned in localStorage.
|
|
|
|
import { CONFIG_LOCALSTORAGE_KEY } from '$lib/constants';
|
|
import { MigrationService } from '$lib/services/migration.service';
|
|
import { settingsStore } from '$lib/stores/settings.svelte';
|
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
|
|
const RENDER_KEYS_MIGRATION_ID = 'render-keys-unfold-v1';
|
|
|
|
async function seedConfig(stored: Record<string, unknown>) {
|
|
localStorage.setItem(CONFIG_LOCALSTORAGE_KEY, JSON.stringify(stored));
|
|
|
|
const migration = MigrationService.getMigrations().find((m) => m.id === RENDER_KEYS_MIGRATION_ID);
|
|
|
|
await migration?.run();
|
|
settingsStore.initialize();
|
|
}
|
|
|
|
function persisted(): Record<string, unknown> {
|
|
return JSON.parse(localStorage.getItem(CONFIG_LOCALSTORAGE_KEY) ?? '{}');
|
|
}
|
|
|
|
describe('renderContentAsRawText unfolding', () => {
|
|
beforeEach(() => {
|
|
localStorage.removeItem(CONFIG_LOCALSTORAGE_KEY);
|
|
MigrationService.resetState();
|
|
settingsStore.initialize();
|
|
});
|
|
|
|
it('maps raw text to user content as plain text', async () => {
|
|
await seedConfig({ renderContentAsRawText: true });
|
|
expect(settingsStore.config.renderUserContentAsMarkdown).toBe(false);
|
|
});
|
|
|
|
it('maps markdown to user content as markdown', async () => {
|
|
await seedConfig({ renderContentAsRawText: false });
|
|
expect(settingsStore.config.renderUserContentAsMarkdown).toBe(true);
|
|
});
|
|
|
|
it('leaves thinking on its own default', async () => {
|
|
await seedConfig({ renderContentAsRawText: true });
|
|
expect(settingsStore.config.renderThinkingAsMarkdown).toBe(true);
|
|
});
|
|
|
|
it('keeps an explicit user preference over the toggle', async () => {
|
|
await seedConfig({ renderContentAsRawText: true, renderUserContentAsMarkdown: true });
|
|
expect(settingsStore.config.renderUserContentAsMarkdown).toBe(true);
|
|
});
|
|
|
|
it('drops the toggle from the persisted config', async () => {
|
|
await seedConfig({ renderContentAsRawText: true });
|
|
expect(persisted().renderContentAsRawText).toBeUndefined();
|
|
});
|
|
|
|
it('leaves both surfaces on markdown when nothing is stored', async () => {
|
|
await seedConfig({});
|
|
expect(settingsStore.config.renderUserContentAsMarkdown).toBe(true);
|
|
expect(settingsStore.config.renderThinkingAsMarkdown).toBe(true);
|
|
});
|
|
});
|