All checks were successful
Production Build & Deploy / build-and-deploy (push) Successful in 50s
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest';
|
|
import { getDb } from '../src/db/index';
|
|
import { generateDraftConfig, publishLiveConfig } from '../src/services/file-generator';
|
|
import fs from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
|
|
describe('DB-Driven File Generation Service Test', () => {
|
|
it('soll Entwurf aus DB lesen und site.config.draft.json generieren', async () => {
|
|
const draftConfig = await generateDraftConfig();
|
|
expect(draftConfig).toBeDefined();
|
|
expect(draftConfig.pages).toBeDefined();
|
|
expect(Array.isArray(draftConfig.pages)).toBe(true);
|
|
|
|
const DATA_DIR = process.env.DATA_DIR || path.join(process.cwd(), 'app', 'data');
|
|
const draftPath = path.join(DATA_DIR, 'site.config.draft.json');
|
|
const exists = await fs.access(draftPath).then(() => true).catch(() => false);
|
|
expect(exists).toBe(true);
|
|
});
|
|
|
|
it('soll Live-Config aus DB freigeben und site.config.json atomar erstellen', async () => {
|
|
const liveConfig = await publishLiveConfig();
|
|
expect(liveConfig).toBeDefined();
|
|
expect(liveConfig.pages).toBeDefined();
|
|
|
|
const DATA_DIR = process.env.DATA_DIR || path.join(process.cwd(), 'app', 'data');
|
|
const livePath = path.join(DATA_DIR, 'site.config.json');
|
|
const exists = await fs.access(livePath).then(() => true).catch(() => false);
|
|
expect(exists).toBe(true);
|
|
});
|
|
});
|