fix(research): preserve settings and capture across tabs (RP06)

This commit is contained in:
Boki 2026-10-27 09:31:46 -04:00
parent 6d549542a9
commit c838e3d05a
4 changed files with 405 additions and 46 deletions

View file

@ -1857,10 +1857,20 @@ test('canonical_native_smoke', async () => {
const f = await fixture(true);
try {
await f.login();
await createCanonicalInBrowser(f, 'Actual Rust browser smoke', true);
const { id } = await createCanonicalInBrowser(f, 'Actual Rust browser smoke');
await f.page.getByRole('button', { name: 'Settings', exact: true }).click();
await f.page.getByLabel('Backtest name', { exact: true }).fill('Unsaved native research draft');
await f.page.getByRole('button', { name: 'Runs', exact: true }).click();
await submitInBrowser(f.page);
const runId = f.page.url().split('/').at(-1)!;
f.dispatcher.start();
await visible(f.page, 'Completed');
await f.page.getByRole('button', { name: 'Settings', exact: true }).click();
expect(await f.page.getByLabel('Backtest name', { exact: true }).inputValue()).toBe(
'Unsaved native research draft'
);
expect((await f.request(`/api/v2/backtests/${id}`)).name).toBe('Actual Rust browser smoke');
await f.page.getByRole('button', { name: 'Details', exact: true }).click();
const result = await f.request(`/api/v2/runs/${runId}/results`);
expect(result.financialEngine).toBe('rust');
expect(result.request.strategy.origin).toBe('builtin');
@ -2473,7 +2483,7 @@ test('canonical_dataset_browser_reuses_older_pages_and_known_hash_without_new_ru
}
});
test('declared_session_source_browser_captures_two_windows_and_retains_without_requery', async () => {
test('declared_session_source_browser_preserves_capture_and_retention_retry_across_tabs', async () => {
const f = await fixture();
try {
await f.login();
@ -2558,11 +2568,52 @@ test('declared_session_source_browser_captures_two_windows_and_retains_without_r
}))
);
await visible(f.page, `Dataset hash: ${captured.preparation.hash}`);
await f.page.getByLabel('Backtest name', { exact: true }).fill('Unsaved session research');
await f.page.getByRole('button', { name: 'Runs', exact: true }).click();
expect(await f.page.getByRole('button', { name: 'Retain dataset', exact: true }).count()).toBe(
0
);
await f.page.getByRole('button', { name: 'Settings', exact: true }).click();
await visible(f.page, `Dataset hash: ${captured.preparation.hash}`);
expect(await f.page.getByLabel('Backtest name', { exact: true }).inputValue()).toBe(
'Unsaved session research'
);
f.setStoredEodBars('eodIntraday1M', []);
// Commit through the real route, then lose its response. Navigating within
// this backtest must preserve the exact retry even after source deletion.
let lostInput: unknown;
const committed = gate();
const retentionPath = '**/api/v2/datasets/canonical/retain';
await f.page.route(retentionPath, async route => {
lostInput = route.request().postDataJSON();
const response = await route.fetch();
if (response.status() !== 200) {
throw new Error(`Expected committed fixture retention, got ${response.status()}`);
}
committed.resolve();
await route.abort('failed');
});
await f.page.getByRole('button', { name: 'Retain dataset', exact: true }).click();
await committed.wait('retention committed before lost response');
await visible(f.page, /Retention is unconfirmed/);
await f.page.unroute(retentionPath);
expect(lostInput).toEqual({
input: captured.input,
expectedHash: captured.preparation.hash,
});
await f.page.getByRole('button', { name: 'Runs', exact: true }).click();
expect(
await f.page
.getByRole('button', { name: 'Retry retaining same dataset', exact: true })
.count()
).toBe(0);
await f.page.getByRole('button', { name: 'Settings', exact: true }).click();
await visible(f.page, /Retention is unconfirmed/);
expect(await f.page.getByLabel('Dataset input', { exact: true }).isDisabled()).toBe(true);
const retaining = f.page.waitForResponse(result =>
result.url().endsWith('/api/v2/datasets/canonical/retain')
);
await f.page.getByRole('button', { name: 'Retain dataset', exact: true }).click();
await f.page.getByRole('button', { name: 'Retry retaining same dataset', exact: true }).click();
const retained = await retaining;
expect(retained.status()).toBe(200);
expect(retained.request().postDataJSON()).toEqual({