test(waas-engine): add vitest suite and node ssr container adapter setup
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
// @ts-check
|
||||
import { defineConfig } from 'astro/config';
|
||||
|
||||
import tailwind from '@astrojs/tailwind';
|
||||
|
||||
import react from '@astrojs/react';
|
||||
import node from '@astrojs/node';
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
output: 'server',
|
||||
adapter: node({
|
||||
mode: 'standalone'
|
||||
}),
|
||||
integrations: [tailwind(), react()]
|
||||
});
|
||||
@@ -6,4 +6,11 @@ services:
|
||||
container_name: websitedummy_app
|
||||
restart: always
|
||||
ports:
|
||||
- "8080:8080"
|
||||
- "8080:4321"
|
||||
environment:
|
||||
- HOST=0.0.0.0
|
||||
- PORT=4321
|
||||
- DATA_DIR=/app/data
|
||||
volumes:
|
||||
- ./app/data:/app/data
|
||||
|
||||
|
||||
1412
package-lock.json
generated
1412
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,7 @@
|
||||
"astro": "astro"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/node": "^8.3.4",
|
||||
"@astrojs/react": "^3.6.3",
|
||||
"@astrojs/tailwind": "^5.1.4",
|
||||
"@fontsource/inter": "^5.2.8",
|
||||
@@ -19,9 +20,15 @@
|
||||
"@types/react": "^19.2.17",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"astro": "^4.16.0",
|
||||
"nodemailer": "^9.0.5",
|
||||
"react": "^19.2.7",
|
||||
"react-dom": "^19.2.7",
|
||||
"react-icons": "^5.7.0",
|
||||
"tailwindcss": "^3.4.19"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/nodemailer": "^8.0.1",
|
||||
"@vitest/coverage-v8": "^4.1.10",
|
||||
"vitest": "^4.1.10"
|
||||
}
|
||||
}
|
||||
|
||||
53
tests/waasEngine.test.ts
Normal file
53
tests/waasEngine.test.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { loadWaasConfigs, FALLBACK_SITE_CONFIG, FALLBACK_THEME_CONFIG, FALLBACK_SMTP_CONFIG } from '../src/utils/configLoader';
|
||||
import { THEME_PRESETS } from '../src/utils/themePresets';
|
||||
|
||||
describe('WaaS Engine Core Unit Tests', () => {
|
||||
const testDataDir = path.join(process.cwd(), 'app', 'test_data');
|
||||
|
||||
beforeEach(() => {
|
||||
process.env.DATA_DIR = testDataDir;
|
||||
if (fs.existsSync(testDataDir)) {
|
||||
fs.rmSync(testDataDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (fs.existsSync(testDataDir)) {
|
||||
fs.rmSync(testDataDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it('1. Should return fallbacks when JSON files do not exist (Zero-Crash Guarantee)', () => {
|
||||
const configs = loadWaasConfigs();
|
||||
expect(configs.siteConfig.siteName).toBe(FALLBACK_SITE_CONFIG.siteName);
|
||||
expect(configs.themeConfig.activePreset).toBe(FALLBACK_THEME_CONFIG.activePreset);
|
||||
expect(configs.smtpConfig.host).toBe(FALLBACK_SMTP_CONFIG.host);
|
||||
});
|
||||
|
||||
it('2. Should dynamically merge custom site.config.json', () => {
|
||||
fs.mkdirSync(testDataDir, { recursive: true });
|
||||
const customSite = { siteName: 'Custom Test Agency', hero: { title: 'Custom Title' } };
|
||||
fs.writeFileSync(path.join(testDataDir, 'site.config.json'), JSON.stringify(customSite), 'utf8');
|
||||
|
||||
const configs = loadWaasConfigs();
|
||||
expect(configs.siteConfig.siteName).toBe('Custom Test Agency');
|
||||
expect(configs.siteConfig.hero.title).toBe('Custom Title');
|
||||
expect(configs.siteConfig.hero.badge).toBe(FALLBACK_SITE_CONFIG.hero.badge);
|
||||
});
|
||||
|
||||
it('3. Should have 10 valid Theme Presets with root CSS color tokens', () => {
|
||||
const presetKeys = Object.keys(THEME_PRESETS);
|
||||
expect(presetKeys.length).toBe(10);
|
||||
expect(THEME_PRESETS.corporateDark.colors.bg).toBe('#0B0F19');
|
||||
expect(THEME_PRESETS.corporateDark.colors.accent).toBe('#38BDF8');
|
||||
});
|
||||
|
||||
it('4. Should support dynamic UIComponent elements in SectionConfig', () => {
|
||||
const heroElements = FALLBACK_SITE_CONFIG.hero.elements || [];
|
||||
expect(heroElements.length).toBeGreaterThan(0);
|
||||
expect(heroElements[0].type).toBe('badge');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user