Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): center the templates page first-load spinner
Yudhi Armyndharis89ba5a96f5e4
diff --git a/dashboard/src/pages/Templates.css b/dashboard/src/pages/Templates.cssindex 17f5341d3..2e7b79bcd 100644--- a/dashboard/src/pages/Templates.css+++ b/dashboard/src/pages/Templates.css@@ -4,7 +4,7 @@overflow-x: hidden;}-.templates-page .templates-loading,+.templates-page.templates-loading,.templates-page .templates-loading-inline,.templates-page .templates-empty-page,.templates-page .templates-empty-list {@@ -13,7 +13,7 @@justify-content: center;}-.templates-page .templates-loading {+.templates-page.templates-loading {min-height: 400px;}diff --git a/dashboard/src/pages/Templates.test.ts b/dashboard/src/pages/Templates.test.tsindex c4f9b2d18..129b92c96 100644--- a/dashboard/src/pages/Templates.test.ts+++ b/dashboard/src/pages/Templates.test.ts@@ -4,11 +4,14 @@import '../test-helpers/register-hooks.ts';import { test, before, afterEach } from 'node:test';import assert from 'node:assert/strict';+import { readFileSync } from 'node:fs';import { createElement } from 'react';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';let templatesStatus = 200;let sessionsStatus = 200;+// When set, GET /api/sessions answers only once this settles, holding the page on its first load.+let sessionsGate: Promise<void> | null = null;let templates: Array<{ id: string; name: string; body: string }> = [];const deleted: string[] = [];@@ -21,6 +24,7 @@ function installFetchStub(): void {const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;const path = url.replace(/^https?:\/\/[^/]+/, '');if (path === '/api/sessions') {+ if (sessionsGate) return sessionsGate.then(() => jsonResponse([]));if (sessionsStatus !== 200) return Promise.resolve(jsonResponse({ message: 'gateway restarting' }, 502));return Promise.resolve(jsonResponse([@@ -152,3 +156,26 @@ test('a failed sessions read shows the error, not "no sessions available"', asynassert.equal(rtl.screen.queryByText('No sessions available'), null);assert.equal(rtl.screen.queryByRole('option', { name: 'No sessions' }), null);});++// The full-page loader puts both classes on the page root itself, so its rule must be a compound+// selector: a descendant one never matches, leaving the spinner in the top-left corner.+test('the first-load spinner is centered in a 400px block', async () => {+ const style = document.createElement('style');+ style.textContent = readFileSync(new URL('./Templates.css', import.meta.url), 'utf8');+ document.head.appendChild(style);+ let release!: () => void;+ sessionsGate = new Promise<void>(resolve => (release = resolve));+ try {+ renderTemplates();+ const loader = document.querySelector('.templates-loading') as HTMLElement;+ assert.ok(loader, 'the page did not render its loading state');+ const computed = getComputedStyle(loader);+ assert.equal(computed.display, 'flex');+ assert.equal(computed.justifyContent, 'center');+ assert.equal(computed.minHeight, '400px');+ } finally {+ release();+ sessionsGate = null;+ style.remove();+ }+});