fix(web): preserve historical backtests with null configuration (CL25)

This commit is contained in:
Boki 2026-10-28 15:50:32 -04:00
parent 731acc41db
commit ed7429cfbc
10 changed files with 41 additions and 23 deletions

View file

@ -2082,12 +2082,15 @@ test('browser_reopen_and_switch', async () => {
).toEqual(beforeHistorySelection);
// A real missing row, not an invented empty result.
await f.page.goto(`${f.origin}/backtests/${definitionId}/run/${randomUUID()}`);
await visible(f.page, 'Failed to get run: Not Found');
await visible(f.page, 'Run not found');
await visible(f.page, 'Retry run');
// Transport failure has a visible retry; restoring the real endpoint recovers.
await f.page.route(`**/api/v2/runs/${secondId}`, route => route.abort('failed'));
await f.page.goto(secondUrl);
await visible(f.page, /Failed to fetch|Load failed/);
await visible(
f.page,
'The backtest response was lost. Check saved runs before submitting again.'
);
await f.page.unroute(`**/api/v2/runs/${secondId}`);
await f.page.getByRole('button', { name: 'Retry run', exact: true }).click();
await visible(f.page, 'Completed');

View file

@ -90,6 +90,14 @@ function respond(body: unknown, status = 200) {
return fetch;
}
test('historical templates with SQL-null configuration remain readable without rewriting them', async () => {
const mapped = mapBacktest({ ...row, config: null });
const wire = JSON.parse(JSON.stringify(mapped));
expect(backtestResponseSchema.parse(wire).config).toBeNull();
respond(mapped);
expect((await backtest.backtestApiV2.getBacktest(backtestId)).config).toBeNull();
});
test('real server backtest/run mappings survive JSON serialization and display the server clock field', async () => {
const mapped = mapBacktest(row);
respond(mapped);
@ -133,7 +141,7 @@ test('existing optional fields remain optional without accepting malformed rende
for (const bad of [
{ ...serialized, symbols: 'AAPL' },
{ ...serialized, initialCapital: '10000' },
{ ...serialized, config: null },
{ ...serialized, config: [] },
]) {
respond(bad);
await expect(backtest.backtestApiV2.getBacktest(backtestId)).rejects.toThrow(