Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): restore lost save-handler rationale comment, format new specs
Yudhi Armyndharis022438f96f2b
diff --git a/dashboard/src/pages/Infrastructure.test.ts b/dashboard/src/pages/Infrastructure.test.tsindex 28508f9fb..99145797e 100644--- a/dashboard/src/pages/Infrastructure.test.ts+++ b/dashboard/src/pages/Infrastructure.test.ts@@ -57,11 +57,22 @@ const SAVED_CONFIG: SavedConfig = {},// headless: false deliberately differs from the component's useState default (true) — asserting// it reads false is what proves this field came from /config, not from the initial state.- engine: { type: 'whatsapp-web.js', headless: false, sessionDataPath: '/data/custom-sessions', browserArgs: '--headless=new --custom-flag' },+ engine: {+ type: 'whatsapp-web.js',+ headless: false,+ sessionDataPath: '/data/custom-sessions',+ browserArgs: '--headless=new --custom-flag',+ },};const ENGINES: Engine[] = [- { id: 'whatsapp-web.js', name: 'WhatsApp Web (Puppeteer)', enabled: true, features: [], library: { name: 'whatsapp-web.js', version: '1.34.7' } },+ {+ id: 'whatsapp-web.js',+ name: 'WhatsApp Web (Puppeteer)',+ enabled: true,+ features: [],+ library: { name: 'whatsapp-web.js', version: '1.34.7' },+ },{ id: 'baileys', name: 'Baileys', enabled: true, features: [] },];@@ -117,7 +128,9 @@ function installFetchStub(): void {if (method === 'GET' && path === '/api/infra/engines') return Promise.resolve(jsonResponse(ENGINES));if (method === 'GET' && path === '/api/infra/engines/current') return Promise.resolve(jsonResponse(CURRENT_ENGINE));if (method === 'PUT' && path === '/api/infra/config') {- return Promise.resolve(jsonResponse({ message: 'Configuration saved', saved: true, envPath: '.env.generated', profiles: [] }));+ return Promise.resolve(+ jsonResponse({ message: 'Configuration saved', saved: true, envPath: '.env.generated', profiles: [] }),+ );}if (method === 'POST' && path === '/api/infra/restart') {return Promise.resolve(@@ -128,7 +141,9 @@ function installFetchStub(): void {return Promise.resolve(jsonResponse({ status: 'ok', details: {} }));}if (method === 'GET' && path === '/api/infra/export-data') {- return Promise.resolve(jsonResponse({ exportedAt: new Date(0).toISOString(), dataDbType: 'postgres', tables: {}, counts: {} }));+ return Promise.resolve(+ jsonResponse({ exportedAt: new Date(0).toISOString(), dataDbType: 'postgres', tables: {}, counts: {} }),+ );}if (method === 'POST' && path === '/api/infra/import-data') {return Promise.resolve(jsonResponse({ imported: true, counts: {} }));diff --git a/dashboard/src/pages/Infrastructure.tsx b/dashboard/src/pages/Infrastructure.tsxindex 93a289008..a0069c862 100644--- a/dashboard/src/pages/Infrastructure.tsx+++ b/dashboard/src/pages/Infrastructure.tsx@@ -57,9 +57,11 @@ export function Infrastructure() {const configSave = useConfigSave({buildPayload: configForm.buildSavePayload,onSaved: profiles => {- // Scope: this warns on a backend-TYPE change (local↔s3) and a built-in↔external flip — the cases- // that point at a different store. It does NOT warn on same-backend repointing (e.g. a new S3- // bucket/endpoint or a new local path); region/endpoint aren't on /status to compare reliably.+ // Flag a backend switch vs what's actually running so the restart modal can warn about the+ // empty-database / orphaned-media data move before it happens. A switch is: changing type;+ // flipping built-in↔external (different physical backend); OR retargeting an external Postgres+ // to a different host/port/database (also a different, empty DB). Host/port/db aren't all in+ // /status, so compare the edited form against the still-cached saved config.const dbExternalRetarget =configForm.dbConfig.type === 'postgres' &&!configForm.dbConfig.builtIn &&@@ -72,6 +74,9 @@ export function Infrastructure() {(configForm.dbConfig.type !== infraStatus.database.type ||(configForm.dbConfig.type === 'postgres' && configForm.dbConfig.builtIn !== infraStatus.database.builtIn) ||dbExternalRetarget);+ // Scope: this warns on a backend-TYPE change (local↔s3) and a built-in↔external flip — the cases+ // that point at a different store. It does NOT warn on same-backend repointing (e.g. a new S3+ // bucket/endpoint or a new local path); region/endpoint aren't on /status to compare reliably.const storageSwitch =!!infraStatus &&(configForm.storageConfig.type !== infraStatus.storage.type ||diff --git a/dashboard/src/pages/Sessions.test.ts b/dashboard/src/pages/Sessions.test.tsindex c637c18ad..a540d2e48 100644--- a/dashboard/src/pages/Sessions.test.ts+++ b/dashboard/src/pages/Sessions.test.ts@@ -108,7 +108,9 @@ function installFetchStub(): void {const sessionIdMatch = path.match(/^\/api\/sessions\/([^/]+)$/);if (method === 'GET' && sessionIdMatch) {const found = SESSIONS.find(s => s.id === sessionIdMatch[1]);- return found ? Promise.resolve(jsonResponse(found)) : Promise.resolve(jsonResponse({ message: 'not found' }, 404));+ return found+ ? Promise.resolve(jsonResponse(found))+ : Promise.resolve(jsonResponse({ message: 'not found' }, 404));}if (method === 'DELETE' && sessionIdMatch) {return Promise.resolve(new Response(null, { status: 204 }));