test(funding): demonstrate B03 B06 with documentary institutions in QA
This commit is contained in:
@@ -23,7 +23,7 @@ const text = (tree) =>
|
||||
: '';
|
||||
|
||||
// Real page event handlers, simulated Inertia transport. Not a browser or visual acceptance.
|
||||
function harness(filters, errors = {}) {
|
||||
function harness(filters, errors = {}, items = []) {
|
||||
const memory = [];
|
||||
let cursor = 0;
|
||||
const state = (initial) => {
|
||||
@@ -114,7 +114,7 @@ function harness(filters, errors = {}) {
|
||||
const props = {
|
||||
filters,
|
||||
criteriaErrors: errors,
|
||||
items: { data: [], links: [] },
|
||||
items: { data: items, links: [] },
|
||||
options: { sectors: [], territories: [] },
|
||||
kinds: { institution: 'Instituição', fund: 'Fundo' },
|
||||
management: false,
|
||||
@@ -147,6 +147,69 @@ function harness(filters, errors = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
test('B03 broad coverage remains explicit and physical choice requests documented presence', () => {
|
||||
const h = harness({
|
||||
need: 'investment',
|
||||
territory: '7d908cf8-6e52-5141-8832-b1193985e39f',
|
||||
});
|
||||
assert.equal(h.select('Localização a pesquisar').props.value, 'coverage');
|
||||
h.select('Localização a pesquisar').props.onChange({
|
||||
target: { value: 'physical' },
|
||||
});
|
||||
h.render();
|
||||
assert.equal(h.form().data.location_mode, 'physical');
|
||||
assert.equal(h.form().data.certainty, 'documented');
|
||||
assert.match(
|
||||
text(h.tree()),
|
||||
/a cobertura indica onde o financiamento se aplica/,
|
||||
);
|
||||
});
|
||||
|
||||
test('B06 empty results omit institution alternatives and real result links keep exact identities', () => {
|
||||
const filters = {
|
||||
need: 'investment',
|
||||
territory: '4aa31470-997e-5c63-8fe0-ff2f62586f56',
|
||||
location_mode: 'physical',
|
||||
};
|
||||
const empty = harness(filters);
|
||||
assert.match(text(empty.tree()), /Não foram encontradas instituições/);
|
||||
assert.equal(
|
||||
nodes(empty.tree()).filter(
|
||||
(n) =>
|
||||
n.props?.href?.startsWith('/fundos/') &&
|
||||
n.props.href !== '/fundos/guardados',
|
||||
).length,
|
||||
0,
|
||||
);
|
||||
const fixture = JSON.parse(
|
||||
fs.readFileSync(
|
||||
'outputs/funding-b03-b06-20261120/fixture.json',
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
const originals = JSON.parse(
|
||||
fs.readFileSync(
|
||||
'database/data/funding-institutions-nov2026.json',
|
||||
'utf8',
|
||||
),
|
||||
).references;
|
||||
const items = Object.entries(fixture.records).map(([key, r]) => ({
|
||||
id: r.id,
|
||||
payload: originals[key].draft,
|
||||
}));
|
||||
const h = harness(filters, {}, items);
|
||||
for (const item of items) {
|
||||
const link = nodes(h.tree()).find(
|
||||
(n) =>
|
||||
text(n) === item.payload.title &&
|
||||
n.props?.href?.startsWith('/fundos/'),
|
||||
);
|
||||
assert.ok(link, item.payload.title);
|
||||
assert.ok(link.props.href.startsWith('/fundos/' + item.id + '?'));
|
||||
assert.match(link.props.href, /location_mode=physical/);
|
||||
}
|
||||
});
|
||||
|
||||
void test('searching another province resets only the search location and preserves the investment scope', () => {
|
||||
const filters = {
|
||||
category: 'banking',
|
||||
|
||||
Reference in New Issue
Block a user