Improve investor quick search with typed counts, product categories and licensing guidance

This commit is contained in:
2026-11-13 15:06:11 +02:00
parent f53a308327
commit d325b72fad
11 changed files with 508 additions and 21 deletions
+47
View File
@@ -35,6 +35,53 @@ new Function('require', 'module', 'exports', compiled)(
);
const Search = module.exports.default;
test('product categories preserve the location filter and pagination even without a query', () => {
const results = { data: [{ title: 'Grafite', description: '', category: 'Produtos e localizações', url: '/sectores/mineracao' }], total: 6, current_page: 1, last_page: 2, per_page: 5, unavailable: [] };
const html = renderToStaticMarkup(React.createElement(Search, {
query: 'Nampula', results,
answer: { type: 'products', label: 'Produtos e localização', count: 6, filter: 'Nampula', category: 'physical' },
}));
assert.match(html, /q=Nampula&category=financial/);
assert.match(html, /q=Nampula&page=2&category=physical/);
assert.match(html, /name="category" value="physical"/);
const all = renderToStaticMarkup(React.createElement(Search, {
query: '', results, answer: { type: 'products', label: 'Produtos e localização', count: 6, filter: '', category: 'all' },
}));
assert.match(all, /href="\/sectores\/mineracao"/);
});
test('count answer is explicit and zero is distinct from an unavailable count', () => {
const results = { data: [], total: 0, current_page: 1, last_page: 1, per_page: 5, unavailable: [] };
const html = renderToStaticMarkup(React.createElement(Search, {
query: 'quantos corredores existem', results,
answer: { type: 'count', label: 'corredores', count: 0, filter: '' },
}));
assert.match(html, /0 corredores/);
assert.match(html, /registos publicados/);
const failed = renderToStaticMarkup(React.createElement(Search, {
query: 'quantos corredores existem', results,
answer: { type: 'count', label: 'corredores', count: null, filter: '' },
}));
assert.match(failed, /Contagem indisponível/);
assert.doesNotMatch(failed, /0 corredores/);
});
test('products show their location separately from financial coverage and guidance has no invented count', () => {
const results = { data: [{ title: 'Banco de ensaio', description: 'Crédito PME', location: 'Presença física: Maputo', coverage: 'Cobertura nacional', category: 'Produtos financeiros', url: '/fundos/qa' }], total: 1, current_page: 1, last_page: 1, per_page: 5, unavailable: [] };
const html = renderToStaticMarkup(React.createElement(Search, {
query: 'produtos financeiros', results, answer: { type: 'products', label: 'Produtos e localização', count: 1, filter: '' },
}));
assert.match(html, /Produtos financeiros/);
assert.match(html, /Presença física: Maputo/);
assert.match(html, /Cobertura nacional/);
assert.match(html, /não determina a cobertura/);
const guide = renderToStaticMarkup(React.createElement(Search, {
query: 'como licenciar empresa', results: { ...results, data: [] }, answer: { type: 'guide', label: 'Licenciamento da empresa', count: 2, filter: 'licenciamento' },
}));
assert.match(guide, /Licenciamento da empresa/);
assert.doesNotMatch(guide, /2 Licenciamento/);
});
test('shows five results in one sequence with numbered pagination and the query preserved', () => {
const results = {
data: [