fix: phase 1 refactor
This commit is contained in:
@@ -3,12 +3,19 @@
|
||||
* Validates state management behavior for posts, dirty tracking, and UI state
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { useAppStore, PostData } from '../../../src/renderer/store/appStore';
|
||||
import { describe, it, expect, expectTypeOf, beforeEach } from 'vitest';
|
||||
import { useAppStore, ProjectData, PostData, MediaData, TaskProgress } from '../../../src/renderer/store/appStore';
|
||||
import type {
|
||||
ProjectData as SharedProjectData,
|
||||
PostData as SharedPostData,
|
||||
MediaData as SharedMediaData,
|
||||
TaskProgress as SharedTaskProgress,
|
||||
} from '../../../src/main/shared/electronApi';
|
||||
|
||||
// Helper to create a mock post
|
||||
const createMockPost = (overrides: Partial<PostData> = {}): PostData => ({
|
||||
id: `post-${Date.now()}-${Math.random().toString(36).substring(7)}`,
|
||||
projectId: 'project-1',
|
||||
title: 'Test Post',
|
||||
slug: 'test-post',
|
||||
content: '# Test Content',
|
||||
@@ -160,4 +167,13 @@ describe('AppStore', () => {
|
||||
expect(getStore().preferredEditorMode).toBe('markdown');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Type Contract', () => {
|
||||
it('should keep store data types aligned with the shared Electron API contract', () => {
|
||||
expectTypeOf<ProjectData>().toEqualTypeOf<SharedProjectData>();
|
||||
expectTypeOf<PostData>().toEqualTypeOf<SharedPostData>();
|
||||
expectTypeOf<MediaData>().toEqualTypeOf<SharedMediaData>();
|
||||
expectTypeOf<TaskProgress>().toEqualTypeOf<SharedTaskProgress>();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useAppStore, PostData, MediaData, Tab } from '../../../src/renderer/sto
|
||||
// Helper to create a mock post
|
||||
const createMockPost = (overrides: Partial<PostData> = {}): PostData => ({
|
||||
id: `post-${Date.now()}-${Math.random().toString(36).substring(7)}`,
|
||||
projectId: 'project-1',
|
||||
title: 'Test Post',
|
||||
slug: 'test-post',
|
||||
content: '# Test Content',
|
||||
@@ -23,6 +24,7 @@ const createMockPost = (overrides: Partial<PostData> = {}): PostData => ({
|
||||
// Helper to create a mock media
|
||||
const createMockMedia = (overrides: Partial<MediaData> = {}): MediaData => ({
|
||||
id: `media-${Date.now()}-${Math.random().toString(36).substring(7)}`,
|
||||
projectId: 'project-1',
|
||||
filename: 'test.jpg',
|
||||
originalName: 'test.jpg',
|
||||
mimeType: 'image/jpeg',
|
||||
|
||||
@@ -13,6 +13,7 @@ import type { PostData } from '../../../src/renderer/store/appStore';
|
||||
function createTestPost(overrides: Partial<PostData>): PostData {
|
||||
return {
|
||||
id: 'test-id',
|
||||
projectId: 'project-1',
|
||||
title: 'Test Post',
|
||||
slug: 'test-post',
|
||||
excerpt: 'Test excerpt',
|
||||
|
||||
Reference in New Issue
Block a user