Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test: add the missing controls to the env template and storage gates

Yudhi Armyndharisc324bcef4e0a
diff --git a/src/common/storage/storage.service.spec.ts b/src/common/storage/storage.service.spec.ts
index 290c96f39..55536729f 100644
--- a/src/common/storage/storage.service.spec.ts
+++ b/src/common/storage/storage.service.spec.ts
@@ -322,4 +322,25 @@ describe('StorageService.createExportStream enumerates the whole store', () => {
expect(iterateFiles).toHaveBeenCalled();
expect(listFiles).not.toHaveBeenCalled();
});
+
+ /**
+ * The count is the OTHER half of the same fix and had no test of its own — reverting it to the
+ * capped listing left the suite green. It is the pre-check an operator runs before that migration,
+ * so a count truncated at the cap hides precisely the gap they are checking for, and hides it
+ * while agreeing with itself.
+ */
+ it('counts with the uncapped iterator too, so the pre-check cannot hide the gap', async () => {
+ const { service } = makeLocalService();
+ const listFiles = jest.spyOn(service, 'listFiles');
+ const iterateFiles = jest.spyOn(service, 'iterateFiles').mockImplementation(async function* () {
+ yield await Promise.resolve('media/a.bin');
+ yield await Promise.resolve('media/b.bin');
+ });
+
+ const { count } = await service.getFileCount();
+
+ expect(iterateFiles).toHaveBeenCalled();
+ expect(listFiles).not.toHaveBeenCalled();
+ expect(count).toBe(2); // the iterator's items are what was counted, not an unrelated walk
+ });
});
diff --git a/src/config/env-precedence.spec.ts b/src/config/env-precedence.spec.ts
index 2ee291e77..a6d93c46c 100644
--- a/src/config/env-precedence.spec.ts
+++ b/src/config/env-precedence.spec.ts
@@ -315,7 +315,16 @@ describe('every key the dashboard writes is commented out in .env.example', () =
it('ships the built-in datastore toggles commented out in .env.minimal', () => {
const toggles = ['POSTGRES_BUILTIN', 'REDIS_BUILTIN', 'MINIO_BUILTIN'];
expect(toggles.every(t => dashboardOwned().includes(t))).toBe(true); // control: they ARE dashboard-owned
- expect(uncommentedKeys('.env.minimal').filter(key => toggles.includes(key))).toEqual([]);
+
+ // Non-vacuity control on the OTHER side. The assertion below is a `.filter(...).toEqual([])`,
+ // which an empty parse satisfies just as well as a correct file — a renamed template, a parser
+ // that stops matching, or a file that became all comments would all read as "no pins found" and
+ // pass while binding nothing. Anchor on a key this template exists to pin.
+ const uncommented = uncommentedKeys('.env.minimal');
+ expect(uncommented.length).toBeGreaterThan(0);
+ expect(uncommented).toContain('REDIS_ENABLED');
+
+ expect(uncommented.filter(key => toggles.includes(key))).toEqual([]);
});
});