Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): count sessions without statistics

Yudhi Armyndharis2f3c49fba69c
diff --git a/dashboard/src/pages/Dashboard.test.ts b/dashboard/src/pages/Dashboard.test.ts
index 1c860c512..3430c02fc 100644
--- a/dashboard/src/pages/Dashboard.test.ts
+++ b/dashboard/src/pages/Dashboard.test.ts
@@ -173,6 +173,15 @@ test('a session last active a few hours ago reads in hours, not as a date', asyn
assert.equal(document.querySelector('.last-active')?.textContent, '5 hours ago');
});
+// The harness refuses the session statistics, as the gateway does a failed or unsent read: the count of sessions is
+// then the list's own, not a total of zero beside the rows on screen.
+test('a session list without statistics is counted by its own length', async () => {
+ sessionList = [READY_SESSION];
+ renderDashboard();
+ await rtl.screen.findByText('Main');
+ assert.equal(document.querySelector('.section-subtitle')?.textContent, 'Showing 1 of 1 sessions');
+});
+
test('a read-only key is offered no Disconnect', async () => {
webhooksStatus = 403;
sessionList = [READY_SESSION];
diff --git a/dashboard/src/pages/Dashboard.tsx b/dashboard/src/pages/Dashboard.tsx
index be8e062c1..db484e4bb 100644
--- a/dashboard/src/pages/Dashboard.tsx
+++ b/dashboard/src/pages/Dashboard.tsx
@@ -146,7 +146,7 @@ export function Dashboard() {
<div className="section-header">
<h2>{t('dashboard.sessionsOverview')}</h2>
<span className="section-subtitle">
- {t('dashboard.showingSessions', { shown: sessions.length, total: stats?.total ?? 0 })}
+ {t('dashboard.showingSessions', { shown: sessions.length, total: stats?.total ?? sessions.length })}
</span>
</div>