feat(admin): add global site settings API, tests and dashboard UI
All checks were successful
Production Build & Deploy / build-and-deploy (push) Successful in 35s
All checks were successful
Production Build & Deploy / build-and-deploy (push) Successful in 35s
This commit is contained in:
33
tests/siteSettings.test.ts
Normal file
33
tests/siteSettings.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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_site_settings');
|
||||
const configPath = path.join(DATA_DIR, 'site.config.json');
|
||||
|
||||
describe('Global Site Settings API Test', () => {
|
||||
beforeEach(async () => {
|
||||
await fs.mkdir(DATA_DIR, { recursive: true });
|
||||
const dummyConfig = {
|
||||
site_info: { title: 'Alte Firma', phone: '0123456' },
|
||||
navigation: [{ label: 'Home', page_id: 'page_1' }]
|
||||
};
|
||||
await fs.writeFile(configPath, JSON.stringify(dummyConfig, null, 2), 'utf-8');
|
||||
});
|
||||
|
||||
it('soll globale Stammdaten in site.config.json aktualisieren', async () => {
|
||||
const raw = await fs.readFile(configPath, 'utf-8');
|
||||
const config = JSON.parse(raw);
|
||||
|
||||
config.site_info.title = 'N&D IT Solutions GmbH';
|
||||
config.site_info.phone = '+49 7473 123456';
|
||||
|
||||
await fs.writeFile(configPath, JSON.stringify(config, null, 2), 'utf-8');
|
||||
|
||||
const updatedRaw = await fs.readFile(configPath, 'utf-8');
|
||||
const updatedConfig = JSON.parse(updatedRaw);
|
||||
|
||||
expect(updatedConfig.site_info.title).toBe('N&D IT Solutions GmbH');
|
||||
expect(updatedConfig.site_info.phone).toBe('+49 7473 123456');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user