feat: tests & bootstrap
This commit is contained in:
parent
4bd927bb4e
commit
79e20ca37c
19 changed files with 706 additions and 23 deletions
68
tests/e2e/workspaces.spec.ts
Normal file
68
tests/e2e/workspaces.spec.ts
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import { test, expect, openPredict, login } from './fixtures';
|
||||
|
||||
test.beforeEach(async ({ context, page }) => {
|
||||
await login(context);
|
||||
await page.goto('/');
|
||||
await page.evaluate(() => localStorage.removeItem('workspaces'));
|
||||
});
|
||||
|
||||
function workspacesPanel(page: import('@playwright/test').Page) {
|
||||
return page.locator('.panel-container-right');
|
||||
}
|
||||
|
||||
test('a workspace is auto-created on first visit to /predict', async ({ page }) => {
|
||||
await openPredict(page);
|
||||
const panel = workspacesPanel(page);
|
||||
await expect(panel.locator('.workspace-row').first()).toBeVisible({ timeout: 10_000 });
|
||||
await expect(panel.getByRole('button', { name: /Рассчитать|Run/ }).first()).toBeVisible();
|
||||
});
|
||||
|
||||
test('can add and remove workspaces', async ({ page }) => {
|
||||
await openPredict(page);
|
||||
const panel = workspacesPanel(page);
|
||||
await expect(panel.locator('.workspace-row')).toHaveCount(1, { timeout: 10_000 });
|
||||
|
||||
const addBtn = panel.getByRole('button', { name: /Добавить|Add/ }).first();
|
||||
await addBtn.click();
|
||||
await expect(panel.locator('.workspace-row')).toHaveCount(2);
|
||||
await addBtn.click();
|
||||
await expect(panel.locator('.workspace-row')).toHaveCount(3);
|
||||
|
||||
// Delete the last workspace via its row's delete button.
|
||||
const deleteBtn = panel.locator('.workspace-row').last().locator('button.btn-danger');
|
||||
await deleteBtn.click();
|
||||
// Confirm in the modal.
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByRole('button', { name: /^(Удалить|Delete)$/ })
|
||||
.click();
|
||||
await expect(panel.locator('.workspace-row')).toHaveCount(2);
|
||||
});
|
||||
|
||||
test('workspace render pipeline adds a map scene after a run', async ({ page }) => {
|
||||
test.setTimeout(90_000);
|
||||
await openPredict(page);
|
||||
|
||||
// Wait for the Run button to be enabled before clicking.
|
||||
const runBtn = workspacesPanel(page)
|
||||
.locator('.workspace-row')
|
||||
.first()
|
||||
.getByRole('button', { name: /Рассчитать|Run/ });
|
||||
await runBtn.click();
|
||||
|
||||
// Wait for the prediction request to complete and layers to be added.
|
||||
await expect
|
||||
.poll(
|
||||
async () =>
|
||||
page.evaluate(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const map: any = (window as any)._lsvMap;
|
||||
if (!map) return 0;
|
||||
return map
|
||||
.getStyle()
|
||||
.layers.filter((l: { id: string }) => l.id.startsWith('ws/')).length;
|
||||
}),
|
||||
{ timeout: 75_000, intervals: [1000, 2000, 3000] },
|
||||
)
|
||||
.toBeGreaterThan(0);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue