// @vitest-environment jsdom // // `/dashboard` overview — the SSR overview page. It has no loader/hooks; it // renders a fixed set of stat cards + declares its render mode + meta. We assert // those config exports and the rendered card structure. import { afterEach, describe, expect, test } from 'vitest' import { act, createElement, type ReactNode } from 'react' import { createRoot, type Root } from 'react-dom/client' import { I18nProvider } from '@voltro/i18n' import enCatalog from '../../locales/en' const { default: Overview, meta, renderMode } = await import('./page') ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true let container: HTMLDivElement let root: Root // The page uses , so wrap renders in the framework's . const render = (node: ReactNode): void => { container = document.createElement('div') document.body.appendChild(container) act(() => { root = createRoot(container) root.render( createElement(I18nProvider, { locale: 'en', messages: enCatalog, defaultLocale: 'en', children: node }), ) }) } afterEach(() => { if (root) act(() => root.unmount()) container?.remove() document.body.innerHTML = '' }) describe('dashboard overview — config', () => { test('is an SSR page (so the parent gate runs per request) with an Overview title', () => { expect(renderMode).toBe('ssr') expect(meta({ locale: 'en' }).title).toBe('Overview') }) }) describe('dashboard overview — render', () => { test('renders one card per stat with its label and value', () => { render(createElement(Overview)) const cards = Array.from(container.querySelectorAll('.card')) expect(cards).toHaveLength(4) expect(container.textContent).toContain('Projects') expect(container.textContent).toContain('12') expect(container.textContent).toContain('Uptime') expect(container.textContent).toContain('99.9%') }) })