Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test(e2e): isolate the e2e data DB so suites don't pollute the dev database (#416)

Yudhi Armyndharis15e43fdea0d4
diff --git a/src/engine/adapters/baileys.adapter.ts b/src/engine/adapters/baileys.adapter.ts
index fe6c0c2fc..8f8de0b57 100644
--- a/src/engine/adapters/baileys.adapter.ts
+++ b/src/engine/adapters/baileys.adapter.ts
@@ -381,7 +381,7 @@ export class BaileysAdapter implements IWhatsAppEngine {
this.sock = null;
this.setStatus(EngineStatus.DISCONNECTED);
await this.config.messageStore?.clearSession(this.config.sessionId).catch(() => undefined);
- // ponytail: leaves the multi-file auth dir on disk; a fresh link overwrites it. Add fs cleanup if
+ // leaves the multi-file auth dir on disk; a fresh link overwrites it. Add fs cleanup if
// stale creds ever block re-linking.
}
diff --git a/test/setup-e2e.ts b/test/setup-e2e.ts
index c25a45317..917c95a8e 100644
--- a/test/setup-e2e.ts
+++ b/test/setup-e2e.ts
@@ -1,7 +1,17 @@
// e2e boot environment. Set BEFORE AppModule is imported (setupFiles phase) so the
// app boots against local SQLite with no Redis/queue and no production boot guard.
+import { join } from 'path';
+import { tmpdir } from 'os';
+import { rmSync } from 'fs';
+
process.env.NODE_ENV = 'test';
process.env.DATABASE_TYPE = 'sqlite';
+// Isolate the e2e data DB to a throwaway temp file so suites never pollute the developer's
+// ./data/openwa.sqlite. e2e creates sessions/webhooks and doesn't self-clean, so without this they
+// pile up across runs. Start each run from a fresh file.
+const e2eDataDb = join(tmpdir(), `openwa-e2e-${process.pid}.sqlite`);
+rmSync(e2eDataDb, { force: true });
+process.env.DATABASE_NAME = e2eDataDb;
process.env.QUEUE_ENABLED = 'false';
process.env.AUTO_START_SESSIONS = 'false';
// Keep the auth/audit + data schema zero-config for the test boot.