chore: phase 4 refactor

This commit is contained in:
2026-02-21 18:13:41 +01:00
parent 9df081965b
commit 78a163a0c9
4 changed files with 149 additions and 136 deletions

View File

@@ -0,0 +1,63 @@
import { describe, expect, it } from 'vitest';
import type { Tab } from '../../../src/renderer/store/appStore';
import {
EDITOR_TAB_ROUTE_REGISTRY,
resolveEditorRoute,
} from '../../../src/renderer/navigation/editorRouting';
describe('editorRouting', () => {
it('defines canonical tab-type to editor-route mapping', () => {
expect(EDITOR_TAB_ROUTE_REGISTRY).toEqual({
post: 'post',
media: 'media',
settings: 'settings',
style: 'style',
tags: 'tags',
chat: 'chat',
import: 'import',
'metadata-diff': 'metadata-diff',
'git-diff': 'git-diff',
documentation: 'documentation',
'site-validation': 'site-validation',
});
});
it('resolves dashboard route when no active tab is present', () => {
expect(resolveEditorRoute(undefined)).toEqual({
route: 'dashboard',
tabId: null,
gitDiffResource: null,
});
});
it('resolves post and media routes with active tab id', () => {
const postTab: Tab = { type: 'post', id: 'post-1', isTransient: true };
const mediaTab: Tab = { type: 'media', id: 'media-1', isTransient: false };
expect(resolveEditorRoute(postTab)).toEqual({
route: 'post',
tabId: 'post-1',
gitDiffResource: null,
});
expect(resolveEditorRoute(mediaTab)).toEqual({
route: 'media',
tabId: 'media-1',
gitDiffResource: null,
});
});
it('resolves git-diff route and extracts resource from tab id', () => {
const tab: Tab = {
type: 'git-diff',
id: 'git-diff:commit:abc123',
isTransient: true,
};
expect(resolveEditorRoute(tab)).toEqual({
route: 'git-diff',
tabId: 'git-diff:commit:abc123',
gitDiffResource: 'commit:abc123',
});
});
});