feat: phase 1 of python scripting
This commit is contained in:
@@ -87,7 +87,20 @@ describe('activityBehavior', () => {
|
||||
});
|
||||
|
||||
it('supports all expected activity ids', () => {
|
||||
const ids: ActivityId[] = ['posts', 'pages', 'media', 'tags', 'chat', 'import', 'git', 'settings'];
|
||||
expect(ids).toHaveLength(8);
|
||||
const ids: ActivityId[] = ['posts', 'pages', 'media', 'scripts', 'tags', 'chat', 'import', 'git', 'settings'];
|
||||
expect(ids).toHaveLength(9);
|
||||
});
|
||||
|
||||
it('returns posts-style sidebar actions for scripts', () => {
|
||||
const hiddenSidebarSnapshot = createSnapshot({ activeView: 'posts', sidebarVisible: false });
|
||||
expect(getActivityClickActions(hiddenSidebarSnapshot, 'scripts')).toEqual([
|
||||
{ type: 'setActiveView', view: 'scripts' },
|
||||
{ type: 'toggleSidebar' },
|
||||
]);
|
||||
|
||||
const visibleSidebarSnapshot = createSnapshot({ activeView: 'posts', sidebarVisible: true });
|
||||
expect(getActivityClickActions(visibleSidebarSnapshot, 'scripts')).toEqual([
|
||||
{ type: 'setActiveView', view: 'scripts' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,6 +20,7 @@ describe('editorRouting', () => {
|
||||
'git-diff': 'git-diff',
|
||||
documentation: 'documentation',
|
||||
'site-validation': 'site-validation',
|
||||
scripts: 'scripts',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ describe('sidebarViewRegistry', () => {
|
||||
'posts',
|
||||
'pages',
|
||||
'media',
|
||||
'scripts',
|
||||
'settings',
|
||||
'tags',
|
||||
'chat',
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
getGitDiffCommitTabSpec,
|
||||
getGitDiffFileTabSpec,
|
||||
getImportTabSpec,
|
||||
getScriptTabSpec,
|
||||
parseGitDiffTabId,
|
||||
openChatTab,
|
||||
getSingletonToolTabSpec,
|
||||
@@ -12,6 +13,7 @@ import {
|
||||
openGitDiffCommitTab,
|
||||
openGitDiffFileTab,
|
||||
openImportTab,
|
||||
openScriptTab,
|
||||
openSingletonToolTab,
|
||||
} from '../../../src/renderer/navigation/tabPolicy';
|
||||
|
||||
@@ -20,6 +22,7 @@ describe('tabPolicy', () => {
|
||||
expect(getSingletonToolTabSpec('settings')).toEqual({ type: 'settings', id: 'settings', isTransient: false });
|
||||
expect(getSingletonToolTabSpec('tags')).toEqual({ type: 'tags', id: 'tags', isTransient: false });
|
||||
expect(getSingletonToolTabSpec('style')).toEqual({ type: 'style', id: 'style', isTransient: false });
|
||||
expect(getSingletonToolTabSpec('scripts')).toEqual({ type: 'scripts', id: 'scripts', isTransient: false });
|
||||
expect(getSingletonToolTabSpec('menu-editor')).toEqual({ type: 'menu-editor', id: 'menu-editor', isTransient: false });
|
||||
expect(getSingletonToolTabSpec('documentation')).toEqual({ type: 'documentation', id: 'documentation', isTransient: false });
|
||||
expect(getSingletonToolTabSpec('metadata-diff')).toEqual({ type: 'metadata-diff', id: 'metadata-diff', isTransient: false });
|
||||
@@ -93,6 +96,35 @@ describe('tabPolicy', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('provides canonical script tab spec for preview and pin intents', () => {
|
||||
expect(getScriptTabSpec('script-1', 'preview')).toEqual({
|
||||
type: 'scripts',
|
||||
id: 'script-1',
|
||||
isTransient: true,
|
||||
});
|
||||
|
||||
expect(getScriptTabSpec('script-1', 'pin')).toEqual({
|
||||
type: 'scripts',
|
||||
id: 'script-1',
|
||||
isTransient: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('opens script tabs from shared policy', () => {
|
||||
const opened: Array<{ type: string; id: string; isTransient: boolean }> = [];
|
||||
const openTab = (tab: { type: string; id: string; isTransient: boolean }) => {
|
||||
opened.push(tab);
|
||||
};
|
||||
|
||||
openScriptTab(openTab, 'script-preview', 'preview');
|
||||
openScriptTab(openTab, 'script-pin', 'pin');
|
||||
|
||||
expect(opened).toEqual([
|
||||
{ type: 'scripts', id: 'script-preview', isTransient: true },
|
||||
{ type: 'scripts', id: 'script-pin', isTransient: false },
|
||||
]);
|
||||
});
|
||||
|
||||
it('builds and parses git-diff file and commit tab specs', () => {
|
||||
expect(getGitDiffFileTabSpec('posts/first.md', 'preview')).toEqual({
|
||||
type: 'git-diff',
|
||||
|
||||
Reference in New Issue
Block a user