import { readFileSync } from 'node:fs'; import { expect, it, vi } from 'vitest'; import { renderToStaticMarkup } from 'react-dom/server'; import { CatalogCheckNotice } from './catalog-check'; it('shows actual check time separately from later inventory cache reading without actions or requests', () => { const fetch = vi.fn(); vi.stubGlobal('fetch', fetch); try { const device = { inventory: JSON.parse(readFileSync(new URL('../../tests/agent_update/catalog-check-inventory.json', import.meta.url),'utf8')) }; const html = renderToStaticMarkup(); for (const expected of ['2026-11-15T10:00:00Z', '2026-11-15T12:00:00Z', '0.1.8', 'available', 'keine Installation']) expect(html).toContain(expected); expect(html).not.toMatch(/<(button|form|input|script)\b/); expect(fetch).not.toHaveBeenCalled(); device.inventory.observations[0]!.data.candidate.version = ''; expect(renderToStaticMarkup()).toContain('role="alert"'); expect(renderToStaticMarkup()).toBe(''); } finally { vi.unstubAllGlobals(); } });