import { App, router } from '@inertiajs/react';
import { renderToStaticMarkup } from 'react-dom/server';
import { afterEach, expect, test, vi } from 'vitest';
import ProcurementSearch from '@/pages/search/procurement';
import type { SavedSearches } from '../../resources/js/components/saved-procurement-searches';
afterEach(() => vi.restoreAllMocks());
const saved: SavedSearches = {
max_active: 50,
active: [
{
id: 3,
name: '',
term: 'QA%_',
version: 4,
href: '/compras/pesquisa?q=QA%25_',
},
],
archived: {
data: [
{
id: 6,
name: 'Anterior',
term: 'Outro texto',
version: 2,
href: '/compras/pesquisa?q=Outro%20texto',
},
],
total: 1,
prev_page_url: null,
next_page_url: null,
},
};
function renderSearch(searches: SavedSearches | null, actorId = 7) {
return renderToStaticMarkup(
,
);
}
test('private saved criteria reopen a local live search and explain archival recovery without rendering supplied markup', () => {
const html = renderSearch(saved);
expect(html).toContain('As minhas pesquisas guardadas');
expect(html).toContain('pesquisa activa');
expect(html).toContain('href="/compras/pesquisa?q=QA%25_"');
expect(html).toContain('acesso actual');
expect(html).toContain('Arquivar pesquisa');
expect(html).toContain('Restaurar pesquisa Anterior');
expect(html).toContain('<script>Nome privado</script>');
expect(html).not.toContain('