45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest';
|
|
import fs from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
|
|
const DATA_DIR = path.join(process.cwd(), 'app', 'test_data_settings');
|
|
const draftPath = path.join(DATA_DIR, 'site.config.draft.json');
|
|
|
|
|
|
describe('Editor Property 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_hero_123', type: 'HeroSection', settings: { title: 'Alter Titel', subtitle: 'Alt' } }
|
|
]
|
|
}
|
|
]
|
|
};
|
|
await fs.writeFile(draftPath, JSON.stringify(dummyConfig, null, 2), 'utf-8');
|
|
});
|
|
|
|
it('soll Sektions-Settings im Entwurf erfolgreich aktualisieren', async () => {
|
|
const raw = await fs.readFile(draftPath, 'utf-8');
|
|
const config = JSON.parse(raw);
|
|
|
|
const hero = config.pages[0].sections[0];
|
|
hero.settings.title = 'Neuer Hero Titel';
|
|
hero.settings.subtitle = 'Neuer Untertitel';
|
|
|
|
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[0].settings.title).toBe('Neuer Hero Titel');
|
|
expect(updatedConfig.pages[0].sections[0].settings.subtitle).toBe('Neuer Untertitel');
|
|
});
|
|
});
|