Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): say a templates search matched nothing

Yudhi Armyndharis18592d0b82d1
diff --git a/dashboard/src/pages/Templates.test.ts b/dashboard/src/pages/Templates.test.ts
index beed87b01..0e54ba97e 100644
--- a/dashboard/src/pages/Templates.test.ts
+++ b/dashboard/src/pages/Templates.test.ts
@@ -213,3 +213,17 @@ test('a selected session that disappears from the list is replaced by the first
screen.getByText('Saved under support-bot');
window.sessionStorage.setItem('openwa_user_role', 'viewer');
});
+
+// The count above the list still shows the library is not empty, so a search that matches nothing
+// must say so rather than claim no templates are saved.
+test('a search with no match says so instead of reporting an empty library', async () => {
+ const { screen, fireEvent } = rtl;
+ templatesStatus = 200;
+ templates = [{ id: 'tpl-1', name: 'invoice-reminder', body: 'Hi {{name}}' }];
+ renderTemplates();
+
+ await screen.findByText('invoice-reminder');
+ fireEvent.change(screen.getByPlaceholderText('Search'), { target: { value: 'no-such-template' } });
+ await screen.findByText('No templates match your search.');
+ assert.equal(screen.queryByText('No templates saved'), null);
+});
diff --git a/dashboard/src/pages/Templates.tsx b/dashboard/src/pages/Templates.tsx
index 34546f38a..8899eabdf 100644
--- a/dashboard/src/pages/Templates.tsx
+++ b/dashboard/src/pages/Templates.tsx
@@ -281,7 +281,7 @@ export function Templates() {
) : filteredTemplates.length === 0 ? (
<div className="templates-empty-list compact">
<Search size={32} strokeWidth={1.5} />
- <h3>{t('templates.empty.title')}</h3>
+ <h3>{t('templates.empty.noMatch', 'No templates match your search.')}</h3>
</div>
) : (
<div className="template-list" role="list">