Initial
This commit is contained in:
commit
b43955e0d9
162 changed files with 15425 additions and 0 deletions
66
tests/e2e/history.spec.ts
Normal file
66
tests/e2e/history.spec.ts
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import { test, expect, type Page } from '@playwright/test';
|
||||
|
||||
async function login(page: Page) {
|
||||
await page.goto('/login/');
|
||||
await page.fill('#lg-username', 'demo');
|
||||
await page.fill('#lg-password', 'demo');
|
||||
await page.click('button[type=submit]');
|
||||
await expect(page.getByTestId('nav-menu')).toBeVisible();
|
||||
}
|
||||
|
||||
/** Every run is persisted server-side, so running one seeds the history. */
|
||||
async function runPrediction(page: Page) {
|
||||
await page.getByTestId('run-btn').click();
|
||||
await expect(page.getByTestId('flight-time')).toBeVisible({ timeout: 15000 });
|
||||
}
|
||||
|
||||
test('a run appears in history with its landing and flight time', async ({ page }) => {
|
||||
await login(page);
|
||||
await runPrediction(page);
|
||||
|
||||
await page.goto('/user/predictions/');
|
||||
await expect(page.getByTestId('history-table')).toBeVisible();
|
||||
const rows = page.getByTestId('history-table').locator('tbody tr');
|
||||
await expect(rows.first()).toBeVisible();
|
||||
// Mock history is shared across the run and may also hold ensemble rows, so
|
||||
// assert that at least one single-run row carries a derived flight time.
|
||||
await expect(rows.filter({ hasText: /\d+ч \d+мин|\dh \d+min/ }).first()).toBeVisible();
|
||||
|
||||
await page.getByTestId('history-detail').first().click();
|
||||
await expect(page.getByTestId('history-detail-card')).toContainText('complete');
|
||||
});
|
||||
|
||||
test('deleting a prediction offers undo and restores it', async ({ page }) => {
|
||||
await login(page);
|
||||
await runPrediction(page);
|
||||
await page.goto('/user/predictions/');
|
||||
|
||||
// The mock keeps history in dev-server state shared by the whole run, so
|
||||
// assert on the change rather than an absolute count.
|
||||
const rows = page.getByTestId('history-table').locator('tbody tr');
|
||||
await expect(rows.first()).toBeVisible();
|
||||
const before = await rows.count();
|
||||
|
||||
await page.getByTestId('history-delete').first().click();
|
||||
await expect(page.getByTestId('undo-bar')).toBeVisible();
|
||||
if (before === 1) {
|
||||
await expect(page.getByTestId('history-empty')).toBeVisible();
|
||||
} else {
|
||||
await expect(rows).toHaveCount(before - 1);
|
||||
}
|
||||
|
||||
// Undo cancels the pending server call and restores the row.
|
||||
await page.getByTestId('undo-delete').click();
|
||||
await expect(page.getByTestId('history-table').locator('tbody tr')).toHaveCount(before);
|
||||
});
|
||||
|
||||
test('a past run can be loaded back into a new scenario', async ({ page }) => {
|
||||
await login(page);
|
||||
await runPrediction(page);
|
||||
await page.goto('/user/predictions/');
|
||||
|
||||
await page.getByTestId('history-load').first().click();
|
||||
// It lands on the map view with an extra scenario built from the stored request.
|
||||
await expect(page).toHaveURL(/\/app/);
|
||||
await expect(page.getByTestId('select-scenario')).toHaveCount(2);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue