fix: preserve transversal regression contracts and lock budget during confirmation
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -6,6 +6,7 @@ import { createRequire } from 'node:module';
|
||||
import React from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import ts from 'typescript';
|
||||
import * as preparationIntent from '../../resources/js/lib/preparation-intent.ts';
|
||||
import * as flow from '../../resources/js/lib/opportunity-fill-flow.ts';
|
||||
import { fiscalPreparationGuide } from '../../resources/js/lib/fiscal-preparation-guide.ts';
|
||||
const require = createRequire(import.meta.url);
|
||||
@@ -57,7 +58,7 @@ function stateHooks() {
|
||||
const flat = (node) =>
|
||||
!node || typeof node !== 'object'
|
||||
? []
|
||||
: [node, ...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(
|
||||
@@ -476,7 +477,7 @@ const preparationMocks = {
|
||||
},
|
||||
'@/pages/investment/shared': { card: 'card', input: 'input' },
|
||||
};
|
||||
function contextPreviewHarness() {
|
||||
function contextPreviewHarness(overrides = {}) {
|
||||
const memory = [];
|
||||
const effects = [];
|
||||
let cursor = 0;
|
||||
@@ -530,12 +531,15 @@ function contextPreviewHarness() {
|
||||
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;');
|
||||
const props = {
|
||||
initial: {
|
||||
case: { id: 'synthetic', version: 1, title: 'Synthetic' },
|
||||
@@ -562,7 +566,7 @@ function contextPreviewHarness() {
|
||||
render() {
|
||||
cursor = 0;
|
||||
effects.length = 0;
|
||||
return Editor(props);
|
||||
return Editor({ ...props, ...overrides });
|
||||
},
|
||||
result: {
|
||||
preview_hash: 'synthetic-preview',
|
||||
@@ -598,12 +602,12 @@ async function withDraftTimers(callback) {
|
||||
}
|
||||
}
|
||||
async function readyDraftHarness() {
|
||||
const harness = contextPreviewHarness();
|
||||
const harness = contextPreviewHarness({ territorySelection: [{ id: 'synthetic-province', name: 'Synthetic province', location_type: 'province' }] });
|
||||
harness.render();
|
||||
harness.effects
|
||||
.find((effect) => effect.dependencies?.length === 3)
|
||||
.find((effect) => effect.dependencies?.length === 4)
|
||||
.callback();
|
||||
harness.pending[0].resolve({ corridors: [], parks: [] });
|
||||
if (harness.pending[0]) harness.pending[0].resolve({ corridors: [], parks: [] });
|
||||
await settlePreview();
|
||||
harness.render();
|
||||
return harness;
|
||||
@@ -615,8 +619,8 @@ const runAutosaveEffect = (harness) =>
|
||||
const changeDraftCurrency = (harness, value) => {
|
||||
const tree = harness.render();
|
||||
flat(tree)
|
||||
.find((node) => node.type === 'input' && node.props.maxLength === 3)
|
||||
.props.onChange({ target: { value } });
|
||||
.find((node) => node.props.label === 'Moeda do orçamento')
|
||||
.props.onChange(value);
|
||||
return harness.render();
|
||||
};
|
||||
void test('stale autosave timer never sends an old body with a newer draft sequence', async () => {
|
||||
@@ -689,7 +693,7 @@ void test('large multi-opportunity draft is offered to the transport on exit wit
|
||||
};
|
||||
let cleanup;
|
||||
try {
|
||||
const harness = contextPreviewHarness();
|
||||
const harness = contextPreviewHarness({ requestedChoices: [{ opportunity: { key: 'opportunity:1', title: 'Synthetic' }, territory: null }] });
|
||||
const initial = harness.render();
|
||||
cleanup = harness.effects
|
||||
.find(
|
||||
@@ -743,7 +747,7 @@ void test('successful save followed by failed recovery offers read-only retry an
|
||||
};
|
||||
let cleanup;
|
||||
try {
|
||||
const harness = contextPreviewHarness();
|
||||
const harness = contextPreviewHarness({ requestedChoices: [{ opportunity: { key: 'opportunity:1', title: 'Synthetic' }, territory: null }] });
|
||||
const initial = harness.render();
|
||||
cleanup = harness.effects
|
||||
.find(
|
||||
@@ -803,7 +807,7 @@ void test('successful save followed by failed recovery offers read-only retry an
|
||||
);
|
||||
assert.equal(
|
||||
flat(recovered).find(
|
||||
(node) => node.type === 'input' && node.props.maxLength === 3,
|
||||
(node) => node.props.label === 'Moeda do orçamento',
|
||||
).props.value,
|
||||
'USD',
|
||||
);
|
||||
@@ -845,7 +849,7 @@ 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.type === 'input' && node.props.maxLength === 3,
|
||||
(node) => node.props.label === 'Moeda do orçamento',
|
||||
).props.value,
|
||||
'MZN',
|
||||
);
|
||||
@@ -883,7 +887,7 @@ void test('context comparison locks declaration and replacement controls until i
|
||||
);
|
||||
assert.equal(
|
||||
flat(ready).find(
|
||||
(node) => node.type === 'input' && node.props.maxLength === 3,
|
||||
(node) => node.props.label === 'Moeda do orçamento',
|
||||
).props.disabled,
|
||||
false,
|
||||
);
|
||||
@@ -897,8 +901,8 @@ void test('context comparison rejects a response for a draft changed while the r
|
||||
const busy = harness.render();
|
||||
// Simulate a queued state change, independently of native disabled controls.
|
||||
flat(busy)
|
||||
.find((node) => node.type === 'input' && node.props.maxLength === 3)
|
||||
.props.onChange({ target: { value: 'USD' } });
|
||||
.find((node) => node.props.label === 'Moeda do orçamento')
|
||||
.props.onChange('USD');
|
||||
harness.render();
|
||||
harness.pending[0].resolve(harness.result);
|
||||
await settlePreview();
|
||||
@@ -917,7 +921,7 @@ void test('context comparison rejects a response for a draft changed while the r
|
||||
);
|
||||
assert.equal(
|
||||
flat(stale).find(
|
||||
(node) => node.type === 'input' && node.props.maxLength === 3,
|
||||
(node) => node.props.label === 'Moeda do orçamento',
|
||||
).props.value,
|
||||
'USD',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user