feat(editor): add section manipulation APIs and interactive sidebar controls
All checks were successful
Production Build & Deploy / build-and-deploy (push) Successful in 1m3s
All checks were successful
Production Build & Deploy / build-and-deploy (push) Successful in 1m3s
This commit is contained in:
38
tests/editorSections.test.ts
Normal file
38
tests/editorSections.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
const DATA_DIR = process.env.DATA_DIR || path.join(process.cwd(), 'app', 'data');
|
||||
const draftPath = path.join(DATA_DIR, 'site.config.draft.json');
|
||||
|
||||
describe('Editor Sections API Test', () => {
|
||||
beforeEach(async () => {
|
||||
await fs.mkdir(DATA_DIR, { recursive: true });
|
||||
const dummyConfig = {
|
||||
site_info: { title: 'Test Site', homepage_id: 'page_1' },
|
||||
pages: [
|
||||
{
|
||||
id: 'page_1',
|
||||
slug: '/',
|
||||
title: 'Home',
|
||||
sections: [{ id: 'sec_1', type: 'HeroSection', settings: { title: 'Old Hero' } }]
|
||||
}
|
||||
]
|
||||
};
|
||||
await fs.writeFile(draftPath, JSON.stringify(dummyConfig, null, 2), 'utf-8');
|
||||
});
|
||||
|
||||
it('soll Sektionen in site.config.draft.json erfolgreich überschreiben', async () => {
|
||||
const raw = await fs.readFile(draftPath, 'utf-8');
|
||||
const config = JSON.parse(raw);
|
||||
|
||||
config.pages[0].sections.push({ id: 'sec_2', type: 'BentoGrid', settings: {} });
|
||||
await fs.writeFile(draftPath, JSON.stringify(config, null, 2), 'utf-8');
|
||||
|
||||
const updatedRaw = await fs.readFile(draftPath, 'utf-8');
|
||||
const updatedConfig = JSON.parse(updatedRaw);
|
||||
|
||||
expect(updatedConfig.pages[0].sections).toHaveLength(2);
|
||||
expect(updatedConfig.pages[0].sections[1].type).toBe('BentoGrid');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user