import { test, expect, login } from './fixtures'; /** * The client must not invent a dataset. * * `predictionsApi.run` used to fall back to a client-side guess at which GFS run * the server held, and the guess had rotted into a hardcoded "2025-04-06T00:00:00Z" * — over a year stale. That was harmless only for as long as Django dropped the * parameter on the floor. Now that the predictor honours it and refuses a run it * does not hold, sending an invented epoch fails every prediction with * "dataset 2025-04-06T00:00:00Z is not stored". * * Which runs exist is server knowledge. An unchosen dataset must stay absent so * the server picks. */ test.beforeEach(async ({ context }) => { await login(context); }); test('a prediction request carries no dataset the operator did not choose', async ({ page }) => { test.setTimeout(120_000); const bodies: string[] = []; await page.route('**/predictions/', async (route) => { if (route.request().method() === 'POST') { bodies.push(route.request().postData() ?? ''); } await route.continue(); }); await page.goto('/'); await page.evaluate(() => { const ws = { id: crypto.randomUUID(), name: 'dataset-param', color: '#dc3545', opacity: 1, visible: true, flightParameters: { ascent_rate: 5, burst_altitude: 30000, dataset: '', // the UI's "choose automatically" descent_rate: 5, format: 'json', launch_altitude: 0, launch_latitude: 52.2, launch_longitude: 0.1, profile: 'standard_profile', version: 2, }, launchDate: new Date().toISOString().split('T')[0], launchTime: '12:00:00', result: null, }; localStorage.setItem('workspaces', JSON.stringify({ items: [ws], activeId: ws.id })); }); await page.goto('/predict'); await page .locator('.map-container canvas') .first() .waitFor({ state: 'attached', timeout: 60_000 }); await page .locator('.panel-container-right .workspace-row') .first() .getByRole('button', { name: /Рассчитать|Run/ }) .click(); await expect.poll(() => bodies.length, { timeout: 60_000 }).toBeGreaterThan(0); const payload = JSON.parse(bodies[0]); expect(payload).not.toHaveProperty('dataset'); // The rest of the request must still be intact. expect(payload.launch_latitude).toBe(52.2); expect(payload.launch_datetime).toBeTruthy(); });