Files
ndsolutionswebsite/tests/editorSections.test.ts
Daniel S 0c073983e9
All checks were successful
Production Build & Deploy / build-and-deploy (push) Successful in 1m3s
feat(editor): add section manipulation APIs and interactive sidebar controls
2026-08-09 21:08:35 +02:00

39 lines
1.4 KiB
TypeScript

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');
});
});