34 lines
2.0 KiB
TypeScript
34 lines
2.0 KiB
TypeScript
import { test, expect } from "@playwright/test"
|
|
|
|
test("Рекурсивные маршруты: все группы и раскрытие после сортировки", async ({ page }) => {
|
|
const errors: string[] = []
|
|
page.on("pageerror", error => errors.push(error.message))
|
|
const routes = Array.from({ length: 12 }, (_, i) => ({
|
|
id: String(i + 1), dstAddress: `10.0.${i + 1}.0/24`, gateway: `192.0.2.${i + 1}`,
|
|
distance: 1, scope: 30, targetScope: 10, routingTable: "main", checkGateway: "ping",
|
|
comment: `Маршрут ${i + 1}`, disabled: false, country: "RU",
|
|
}))
|
|
await page.route("**/health", route => route.fulfill({ json: { ok: true } }))
|
|
await page.route("**/api/**", route => {
|
|
const path = new URL(route.request().url()).pathname
|
|
return route.fulfill({ json: path === "/api/recursive-routes" ? { routes }
|
|
: path === "/api/recursive-routes/gateways" ? { gateways: [] }
|
|
: path === "/api/auth/config" ? { required: false }
|
|
: path === "/api/servers" ? [{ id: 1, name: "Роутер", host: "192.0.2.100", type: "exit-node", site: "TEST", country: "RU", asn: "64512", enabled: true, status: "online", latency: 1 }]
|
|
: path === "/api/evobgp/settings" ? { enabled: false, baseUrl: "", secretConfigured: false } : {} })
|
|
})
|
|
await page.goto("/recursive-routes")
|
|
const rows = page.locator("tr[data-row-id]")
|
|
await expect(rows).toHaveCount(12)
|
|
await page.getByRole("button", { name: "Route / Comment", exact: true }).click()
|
|
await expect(rows.first()).toContainText("10.0.1.0/24")
|
|
await page.getByRole("button", { name: "Route / Comment", exact: true }).click()
|
|
await expect(rows.first()).toContainText("10.0.12.0/24")
|
|
await rows.first().click()
|
|
await expect(page.getByText("Endpoint 1", { exact: true })).toBeVisible()
|
|
await expect(page.getByText("check: ping", { exact: true })).toBeVisible()
|
|
await rows.first().click()
|
|
await expect(page.getByText("Endpoint 1", { exact: true })).toBeHidden()
|
|
expect(errors).toEqual([])
|
|
})
|