stratoflights-web/tests/e2e/library.spec.ts
2026-08-14 00:01:49 +09:00

41 lines
1.7 KiB
TypeScript

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();
}
test('loading a saved point links it, editing marks it modified', async ({ page }) => {
await login(page);
const chip = page.getByTestId('point-chip');
await expect(chip).toContainText(/Своя точка|Custom/);
await page.selectOption('#cp-point', '1'); // seeded "sjsa-start"
await expect(chip).toContainText('sjsa-start');
await expect(chip).not.toContainText(/изменено|modified/);
// Editing a linked value dirties it — the saved point itself is untouched.
await page.fill('#cp-lat', '63.5');
await expect(chip).toContainText(/изменено|modified/);
await expect(page.getByTestId('point-update')).toBeEnabled();
});
test('applying a template shows its provenance chip', async ({ page }) => {
await login(page);
await page.selectOption('#cp-template', '1'); // seeded "Высотный"
await expect(page.getByTestId('template-chip')).toContainText('Высотный');
// The template's burst altitude was copied into the live scenario.
await expect(page.locator('#cp-burst')).toHaveValue('33000');
});
test('save-as-new adds a point to the library', async ({ page }) => {
await login(page);
await page.getByTestId('point-save-as').click();
await page.getByTestId('point-name').fill('e2e-point');
await page.getByTestId('point-save').click();
await expect(page.getByTestId('point-chip')).toContainText('e2e-point');
await expect(page.locator('#cp-point option', { hasText: 'e2e-point' })).toHaveCount(1);
});