fix: use investment stage names instead of internal reference labels
This commit is contained in:
@@ -24,8 +24,13 @@ function load(path, mocks = {}, exportName = 'default', extra = '') {
|
||||
(name) =>
|
||||
mocks[name] ??
|
||||
(name === '@/components/investment-step-help'
|
||||
? { HelpAtStep: () => null, InvestmentHelpGuide: ({ children }) => children }
|
||||
: name.startsWith('@/') ? { default: () => null } : require(name)),
|
||||
? {
|
||||
HelpAtStep: () => null,
|
||||
InvestmentHelpGuide: ({ children }) => children,
|
||||
}
|
||||
: name.startsWith('@/')
|
||||
? { default: () => null }
|
||||
: require(name)),
|
||||
module,
|
||||
module.exports,
|
||||
);
|
||||
@@ -60,7 +65,12 @@ function stateHooks() {
|
||||
const flat = (node) =>
|
||||
!node || typeof node !== 'object'
|
||||
? []
|
||||
: [node, ...(node.type?.name === 'InvestmentBudgetRange' ? flat(node.type(node.props)) : React.Children.toArray(node.props?.children).flatMap(flat))];
|
||||
: [
|
||||
node,
|
||||
...(node.type?.name === 'InvestmentBudgetRange'
|
||||
? flat(node.type(node.props))
|
||||
: React.Children.toArray(node.props?.children).flatMap(flat)),
|
||||
];
|
||||
void test('free navigation keeps every field mounted and reports resource work in the current group', () => {
|
||||
const state = stateHooks();
|
||||
const Component = load(
|
||||
@@ -307,7 +317,7 @@ void test('document entry leads to existing fillable preparation and keeps sourc
|
||||
assert.match(html, /Valor do investimento/);
|
||||
assert.match(html, /id="preparation-questions"/);
|
||||
});
|
||||
void test('investment stages expose readable next actions while internal codes and sources remain consultable', () => {
|
||||
void test('investment stages expose readable next actions and context without technical source labels', () => {
|
||||
const useForm = (data) => ({
|
||||
data,
|
||||
errors: {},
|
||||
@@ -359,7 +369,7 @@ void test('investment stages expose readable next actions while internal codes a
|
||||
assert.match(html, /<details[^>]*id="S01"[^>]*open/);
|
||||
assert.match(html, /<summary[^>]*>Sistematizar a ideia/);
|
||||
assert.doesNotMatch(html, /<summary[^>]*>S01/);
|
||||
assert.match(html, /Fonte e referência desta etapa/);
|
||||
assert.match(html, /Enquadramento desta etapa/);
|
||||
});
|
||||
|
||||
function preparationFixture() {
|
||||
@@ -508,40 +518,60 @@ function contextPreviewHarness(overrides = {}) {
|
||||
},
|
||||
};
|
||||
const pending = [];
|
||||
const Editor = load('../../resources/js/pages/investor-path/context.tsx', {
|
||||
react: hooks,
|
||||
'@inertiajs/react': { usePage: () => ({ props: { auth: { user: { id: 1 } } } }), Link: () => null, router: {} },
|
||||
'@/components/navigation-context': {
|
||||
useNavigationContext: () => ({ refresh() {} }),
|
||||
},
|
||||
'@/lib/operation-key': {
|
||||
createOperationKey: () => 'synthetic-operation',
|
||||
},
|
||||
'@/lib/investor-context': {
|
||||
contextFieldNames: {
|
||||
project_title: 'Título',
|
||||
project_summary: 'Resumo',
|
||||
const Editor = load(
|
||||
'../../resources/js/pages/investor-path/context.tsx',
|
||||
{
|
||||
react: hooks,
|
||||
'@inertiajs/react': {
|
||||
usePage: () => ({ props: { auth: { user: { id: 1 } } } }),
|
||||
Link: () => null,
|
||||
router: {},
|
||||
},
|
||||
contextApi: (url, body) =>
|
||||
new Promise((resolve, reject) =>
|
||||
pending.push({ url, body, resolve, reject }),
|
||||
'@/components/navigation-context': {
|
||||
useNavigationContext: () => ({ refresh() {} }),
|
||||
},
|
||||
'@/lib/operation-key': {
|
||||
createOperationKey: () => 'synthetic-operation',
|
||||
},
|
||||
'@/lib/investor-context': {
|
||||
contextFieldNames: {
|
||||
project_title: 'Título',
|
||||
project_summary: 'Resumo',
|
||||
},
|
||||
contextApi: (url, body) =>
|
||||
new Promise((resolve, reject) =>
|
||||
pending.push({ url, body, resolve, reject }),
|
||||
),
|
||||
},
|
||||
'@/pages/investment/shared': {
|
||||
Frame: () => null,
|
||||
card: 'card',
|
||||
input: 'input',
|
||||
button: 'button',
|
||||
},
|
||||
'@/components/investment-budget-range': {
|
||||
default: load(
|
||||
'../../resources/js/components/investment-budget-range.tsx',
|
||||
{
|
||||
'./currency-select': {
|
||||
default: function CurrencySelect() {},
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
'@/lib/preparation-intent': preparationIntent,
|
||||
'@/components/currency-select': {
|
||||
default: function CurrencySelect() {},
|
||||
},
|
||||
'@/components/investment-complements': {
|
||||
default: () => null,
|
||||
SelectedComplements: () => null,
|
||||
complementInput: (value) => value,
|
||||
},
|
||||
},
|
||||
'@/pages/investment/shared': {
|
||||
Frame: () => null,
|
||||
card: 'card',
|
||||
input: 'input',
|
||||
button: 'button',
|
||||
},
|
||||
'@/components/investment-budget-range': { default: load('../../resources/js/components/investment-budget-range.tsx', { './currency-select': { default: function CurrencySelect() {} } }) },
|
||||
'@/lib/preparation-intent': preparationIntent,
|
||||
'@/components/currency-select': { default: function CurrencySelect() {} },
|
||||
'@/components/investment-complements': {
|
||||
default: () => null,
|
||||
SelectedComplements: () => null,
|
||||
complementInput: (value) => value,
|
||||
},
|
||||
}, 'ScopedContextEditor', '\nexports.ScopedContextEditor = ScopedContextEditor;');
|
||||
'ScopedContextEditor',
|
||||
'\nexports.ScopedContextEditor = ScopedContextEditor;',
|
||||
);
|
||||
const props = {
|
||||
initial: {
|
||||
case: { id: 'synthetic', version: 1, title: 'Synthetic' },
|
||||
@@ -604,12 +634,21 @@ async function withDraftTimers(callback) {
|
||||
}
|
||||
}
|
||||
async function readyDraftHarness() {
|
||||
const harness = contextPreviewHarness({ territorySelection: [{ id: 'synthetic-province', name: 'Synthetic province', location_type: 'province' }] });
|
||||
const harness = contextPreviewHarness({
|
||||
territorySelection: [
|
||||
{
|
||||
id: 'synthetic-province',
|
||||
name: 'Synthetic province',
|
||||
location_type: 'province',
|
||||
},
|
||||
],
|
||||
});
|
||||
harness.render();
|
||||
harness.effects
|
||||
.find((effect) => effect.dependencies?.length === 4)
|
||||
.callback();
|
||||
if (harness.pending[0]) harness.pending[0].resolve({ corridors: [], parks: [] });
|
||||
if (harness.pending[0])
|
||||
harness.pending[0].resolve({ corridors: [], parks: [] });
|
||||
await settlePreview();
|
||||
harness.render();
|
||||
return harness;
|
||||
@@ -695,7 +734,14 @@ void test('large multi-opportunity draft is offered to the transport on exit wit
|
||||
};
|
||||
let cleanup;
|
||||
try {
|
||||
const harness = contextPreviewHarness({ requestedChoices: [{ opportunity: { key: 'opportunity:1', title: 'Synthetic' }, territory: null }] });
|
||||
const harness = contextPreviewHarness({
|
||||
requestedChoices: [
|
||||
{
|
||||
opportunity: { key: 'opportunity:1', title: 'Synthetic' },
|
||||
territory: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
const initial = harness.render();
|
||||
cleanup = harness.effects
|
||||
.find(
|
||||
@@ -749,7 +795,14 @@ void test('successful save followed by failed recovery offers read-only retry an
|
||||
};
|
||||
let cleanup;
|
||||
try {
|
||||
const harness = contextPreviewHarness({ requestedChoices: [{ opportunity: { key: 'opportunity:1', title: 'Synthetic' }, territory: null }] });
|
||||
const harness = contextPreviewHarness({
|
||||
requestedChoices: [
|
||||
{
|
||||
opportunity: { key: 'opportunity:1', title: 'Synthetic' },
|
||||
territory: null,
|
||||
},
|
||||
],
|
||||
});
|
||||
const initial = harness.render();
|
||||
cleanup = harness.effects
|
||||
.find(
|
||||
@@ -850,9 +903,8 @@ void test('failed save retains edits and permits retry without claiming that the
|
||||
);
|
||||
assert.equal(harness.pending.length, 2);
|
||||
assert.equal(
|
||||
flat(failed).find(
|
||||
(node) => node.props.label === 'Moeda do orçamento',
|
||||
).props.value,
|
||||
flat(failed).find((node) => node.props.label === 'Moeda do orçamento')
|
||||
.props.value,
|
||||
'MZN',
|
||||
);
|
||||
});
|
||||
@@ -888,9 +940,8 @@ void test('context comparison locks declaration and replacement controls until i
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
flat(ready).find(
|
||||
(node) => node.props.label === 'Moeda do orçamento',
|
||||
).props.disabled,
|
||||
flat(ready).find((node) => node.props.label === 'Moeda do orçamento')
|
||||
.props.disabled,
|
||||
false,
|
||||
);
|
||||
});
|
||||
@@ -922,9 +973,8 @@ void test('context comparison rejects a response for a draft changed while the r
|
||||
),
|
||||
);
|
||||
assert.equal(
|
||||
flat(stale).find(
|
||||
(node) => node.props.label === 'Moeda do orçamento',
|
||||
).props.value,
|
||||
flat(stale).find((node) => node.props.label === 'Moeda do orçamento')
|
||||
.props.value,
|
||||
'USD',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -128,6 +128,12 @@ test('S08 has one current state, a visible primary save action and no nested dis
|
||||
const tree = h.render();
|
||||
const nodes = flatten(tree);
|
||||
assert.equal(tree.type, 'section');
|
||||
assert.match(text(tree), /Etapa: Licenciamento prévio/);
|
||||
assert.doesNotMatch(
|
||||
text(tree),
|
||||
/Referência interna S08|Documento original,|parágrafo 8/,
|
||||
);
|
||||
|
||||
assert.equal(nodes.filter((n) => n.type === 'details').length, 0);
|
||||
assert.equal(
|
||||
nodes.filter(
|
||||
|
||||
Reference in New Issue
Block a user