Remove obsolete scripts and files, update site builder configurations
- Deleted the `import_plans.py`, `run_tests.py`, and `test_run.py` scripts as they are no longer needed. - Updated the initial migration dependency in `0001_initial.py` to reflect recent changes in the `igny8_core_auth` app. - Enhanced the implementation plan documentation to include new phases and updates on the site builder project. - Updated the `vite.config.ts` and `package.json` to integrate testing configurations and dependencies for the site builder.
This commit is contained in:
95
site-builder/src/state/__tests__/siteDefinitionStore.test.ts
Normal file
95
site-builder/src/state/__tests__/siteDefinitionStore.test.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { useSiteDefinitionStore } from '../siteDefinitionStore';
|
||||
import type { SiteStructure, PageBlueprint } from '../../types/siteBuilder';
|
||||
|
||||
describe('siteDefinitionStore', () => {
|
||||
beforeEach(() => {
|
||||
useSiteDefinitionStore.setState({
|
||||
structure: undefined,
|
||||
pages: [],
|
||||
selectedSlug: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it('initializes with empty state', () => {
|
||||
const state = useSiteDefinitionStore.getState();
|
||||
expect(state.pages).toEqual([]);
|
||||
expect(state.structure).toBeUndefined();
|
||||
expect(state.selectedSlug).toBeUndefined();
|
||||
});
|
||||
|
||||
it('sets structure and auto-selects first page', () => {
|
||||
const mockStructure: SiteStructure = {
|
||||
site: { name: 'Test Site' },
|
||||
pages: [
|
||||
{ slug: 'home', title: 'Home', type: 'home', blocks: [] },
|
||||
{ slug: 'about', title: 'About', type: 'about', blocks: [] },
|
||||
],
|
||||
};
|
||||
|
||||
useSiteDefinitionStore.getState().setStructure(mockStructure);
|
||||
|
||||
const state = useSiteDefinitionStore.getState();
|
||||
expect(state.structure).toEqual(mockStructure);
|
||||
expect(state.selectedSlug).toBe('home');
|
||||
});
|
||||
|
||||
it('sets pages and auto-selects first page if none selected', () => {
|
||||
const mockPages: PageBlueprint[] = [
|
||||
{
|
||||
id: 1,
|
||||
site_blueprint: 1,
|
||||
slug: 'services',
|
||||
title: 'Services',
|
||||
type: 'services',
|
||||
status: 'ready',
|
||||
order: 0,
|
||||
blocks_json: [],
|
||||
},
|
||||
];
|
||||
|
||||
useSiteDefinitionStore.getState().setPages(mockPages);
|
||||
|
||||
const state = useSiteDefinitionStore.getState();
|
||||
expect(state.pages).toEqual(mockPages);
|
||||
expect(state.selectedSlug).toBe('services');
|
||||
});
|
||||
|
||||
it('preserves selected slug when setting pages if already selected', () => {
|
||||
useSiteDefinitionStore.setState({ selectedSlug: 'about' });
|
||||
|
||||
const mockPages: PageBlueprint[] = [
|
||||
{
|
||||
id: 1,
|
||||
site_blueprint: 1,
|
||||
slug: 'home',
|
||||
title: 'Home',
|
||||
type: 'home',
|
||||
status: 'ready',
|
||||
order: 0,
|
||||
blocks_json: [],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
site_blueprint: 1,
|
||||
slug: 'about',
|
||||
title: 'About',
|
||||
type: 'about',
|
||||
status: 'ready',
|
||||
order: 1,
|
||||
blocks_json: [],
|
||||
},
|
||||
];
|
||||
|
||||
useSiteDefinitionStore.getState().setPages(mockPages);
|
||||
|
||||
const state = useSiteDefinitionStore.getState();
|
||||
expect(state.selectedSlug).toBe('about');
|
||||
});
|
||||
|
||||
it('selects page by slug', () => {
|
||||
useSiteDefinitionStore.getState().selectPage('contact');
|
||||
expect(useSiteDefinitionStore.getState().selectedSlug).toBe('contact');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user