feat: Change the dev mode defaults to include nested tags

This commit is contained in:
Mathy Vanvoorden
2026-07-29 19:52:31 +02:00
parent d52dfebad4
commit ea7892b497
4 changed files with 46 additions and 9 deletions
@@ -1,5 +1,5 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { useSettingsStore, DEFAULT_KEYWORDS, KEYWORD_PALETTE, KEYWORD_PALETTE_ROWS, getKeywordVisibility } from '../settings-store';
import { useSettingsStore, DEFAULT_KEYWORDS, DEV_KEYWORDS, KEYWORD_PALETTE, KEYWORD_PALETTE_ROWS, getKeywordVisibility } from '../settings-store';
import type { KeywordDefinition } from '../settings-store';
describe('settings-store keywords', () => {
@@ -24,6 +24,31 @@ describe('settings-store keywords', () => {
const ids = DEFAULT_KEYWORDS.map((k) => k.id);
expect(new Set(ids).size).toBe(ids.length);
});
it('ships no nested tag, which is opt-in', () => {
DEFAULT_KEYWORDS.forEach((kw) => expect(kw.id).not.toContain('/'));
});
});
describe('DEV_KEYWORDS', () => {
it('every nested tag has its parent defined, so the tree has no gaps', () => {
const ids = new Set(DEV_KEYWORDS.map((k) => k.id));
DEV_KEYWORDS.forEach((kw) => {
const cut = kw.id.lastIndexOf('/');
if (cut > 0) expect(ids, `orphan: ${kw.id}`).toContain(kw.id.slice(0, cut));
});
});
it('nests deeply enough to exercise the tree', () => {
const depths = DEV_KEYWORDS.map((k) => k.id.split('/').length);
expect(Math.max(...depths)).toBeGreaterThanOrEqual(3);
});
it('each dev keyword has a valid palette color and a unique id', () => {
const ids = DEV_KEYWORDS.map((k) => k.id);
expect(new Set(ids).size).toBe(ids.length);
DEV_KEYWORDS.forEach((kw) => expect(KEYWORD_PALETTE[kw.color]).toBeDefined());
});
});
describe('KEYWORD_PALETTE', () => {
+13 -2
View File
@@ -215,6 +215,17 @@ export const DEFAULT_KEYWORDS: KeywordDefinition[] = [
{ id: 'pink', label: 'Pink', color: 'pink' },
];
export const DEV_KEYWORDS: KeywordDefinition[] = [
{ id: 'work', label: 'Work', color: 'blue' },
{ id: 'work/clients', label: 'Clients', color: 'teal' },
{ id: 'work/clients/acme', label: 'Acme', color: 'green' },
{ id: 'personal', label: 'Personal', color: 'purple' },
{ id: 'personal/finance', label: 'Finance', color: 'amber' },
{ id: 'receipts', label: 'Receipts', color: 'gray' },
];
const USING_MOCK_SERVER = process.env.NEXT_PUBLIC_DEV_MOCK_JMAP === 'true';
interface SettingsState {
// Appearance
fontSize: FontSize;
@@ -557,8 +568,8 @@ const DEFAULT_SETTINGS = {
folderIcons: {} as Record<string, string>,
// Keywords
emailKeywords: DEFAULT_KEYWORDS,
nestedTags: false,
emailKeywords: USING_MOCK_SERVER ? DEV_KEYWORDS : DEFAULT_KEYWORDS,
nestedTags: USING_MOCK_SERVER,
// Attachment Reminder
attachmentReminderEnabled: true,