18 lines
1.2 KiB
TypeScript
18 lines
1.2 KiB
TypeScript
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(<CatalogCheckNotice device={device}/>);
|
|
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 = '<script>approve()</script>';
|
|
expect(renderToStaticMarkup(<CatalogCheckNotice device={device}/>)).toContain('role="alert"');
|
|
expect(renderToStaticMarkup(<CatalogCheckNotice device={{inventory:{}}}/>)).toBe('');
|
|
} finally { vi.unstubAllGlobals(); }
|
|
});
|