27 lines
2.0 KiB
TypeScript
27 lines
2.0 KiB
TypeScript
import { test, expect } from "@playwright/test"
|
|
test("Evolution: HTTP 200 без ok=true не подтверждает соединение", async ({ page }) => {
|
|
let confirmed = false; let tests = 0;
|
|
const errors: string[] = []; let catalogs = 0; page.on("pageerror", error => errors.push(error.message))
|
|
await page.route("**/health", r => r.fulfill({ json: { ok: true } }))
|
|
await page.route("**/api/**", r => {
|
|
const path = new URL(r.request().url()).pathname
|
|
if (path === "/api/auth/config") return r.fulfill({ json: { required: false } })
|
|
if (path === "/api/evobgp/settings") return r.fulfill({ json: { baseUrl: "https://evo.example.test", enabled: true, secretConfigured: true } })
|
|
if (path === "/api/evobgp/test") { tests++; return r.fulfill({ json: { ok: confirmed } }) }
|
|
if (path === "/api/evobgp/catalog") { catalogs++; return r.fulfill({ json: {} }) }
|
|
return r.fulfill({ status: 503, json: { error: "outside catalogue fixture" } })
|
|
})
|
|
await page.goto("/data-collection"); await expect.poll(() => catalogs).toBeGreaterThan(0)
|
|
await expect(page.getByText("Журнал прогонов", { exact: true })).toBeVisible()
|
|
await page.goto("/settings"); await page.getByRole("button", { name: "EvoBGP", exact: true }).click(); await expect(page.getByText("Каталог Evolution не подтверждён: получен некорректный ответ сервера", { exact: true })).toBeVisible()
|
|
await page.getByRole("button", { name: "Проверить ключ", exact: true }).click()
|
|
await expect(page.getByText("Соединение с EvoBGP не подтверждено сервером", { exact: true })).toBeVisible()
|
|
await expect(page.getByText("Соединение с EvoBGP установлено", { exact: true })).toHaveCount(0)
|
|
expect(tests).toBe(1)
|
|
confirmed = true
|
|
await page.getByRole("button", { name: "Проверить ключ", exact: true }).click()
|
|
await expect(page.getByText("Соединение с EvoBGP установлено", { exact: true })).toBeVisible()
|
|
expect(tests).toBe(2)
|
|
expect(errors).toEqual([])
|
|
})
|