feat: implement device-specific configurations for desktop, tablet, and mobile
All checks were successful
Production Build & Deploy / build-and-deploy (push) Successful in 57s

This commit is contained in:
Daniel S
2026-08-09 12:35:46 +02:00
parent eb4bb601d7
commit b159b061ae
14 changed files with 61 additions and 21 deletions

View File

@@ -21,7 +21,7 @@ describe('WaaS Engine Core Unit Tests', () => {
});
it('1. Should return fallbacks when JSON files do not exist (Zero-Crash Guarantee)', () => {
const configs = loadWaasConfigs();
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);
@@ -32,7 +32,7 @@ describe('WaaS Engine Core Unit Tests', () => {
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();
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);
@@ -50,4 +50,20 @@ describe('WaaS Engine Core Unit Tests', () => {
expect(heroElements.length).toBeGreaterThan(0);
expect(heroElements[0].type).toBe('badge');
});
it('5. Should load device-specific configs for desktop, mobile, tablet with fallback', () => {
fs.mkdirSync(testDataDir, { recursive: true });
fs.writeFileSync(path.join(testDataDir, 'site.mobile.config.json'), JSON.stringify({ siteName: 'Mobile Site' }), 'utf8');
fs.writeFileSync(path.join(testDataDir, 'site.tablet.config.json'), JSON.stringify({ siteName: 'Tablet Site' }), 'utf8');
fs.writeFileSync(path.join(testDataDir, 'site.desktop.config.json'), JSON.stringify({ siteName: 'Desktop Site' }), 'utf8');
const mobileConfig = loadWaasConfigs('Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)');
expect(mobileConfig.siteConfig.siteName).toBe('Mobile Site');
const tabletConfig = loadWaasConfigs('Mozilla/5.0 (iPad; CPU OS 14_0 like Mac OS X)');
expect(tabletConfig.siteConfig.siteName).toBe('Tablet Site');
const desktopConfig = loadWaasConfigs('Mozilla/5.0 (Windows NT 10.0; Win64; x64)');
expect(desktopConfig.siteConfig.siteName).toBe('Desktop Site');
});
});