const fs = require('fs'); const path = require('path'); const e2eDir = 'tests/e2e'; const files = fs.readdirSync(e2eDir).filter(f => f.endsWith('.spec.ts')); files.forEach(file => { if (file === 'onboarding.spec.ts') return; const p = path.join(e2eDir, file); let content = fs.readFileSync(p, 'utf8'); // Remove the previous config.json injection logic content = content.replace(/\/\/ Pre-fill d3ro-voice-config\.json to bypass onboarding[\s\S]*?(?=electronApp = await electron\.launch)/g, ''); // Extract the original window waiting logic and append the IPC bypass // We can just find the end of `if (!found) { ... }` block const targetStr = ` }); }`; const injectStr = ` }); } // Bypass onboarding via IPC config set await window.evaluate(async () => { if (window.electronAPI && window.electronAPI.config) { await window.electronAPI.config.set({ key: 'onboardingCompleted', value: true }); await window.electronAPI.config.set({ key: 'appUsageMode', value: 'online' }); await window.electronAPI.config.set({ key: 'llmBackend', value: 'online' }); } }); // Wait for the config to propagate then reload the page await window.waitForTimeout(500); await window.reload(); await window.waitForLoadState('domcontentloaded'); // Wait for React to mount AppLayout await window.waitForTimeout(1000);`; if (content.includes(targetStr) && !content.includes('// Bypass onboarding via IPC config set')) { content = content.replace(targetStr, injectStr); } fs.writeFileSync(p, content); });