Files

37 lines
2.2 KiB
TypeScript

import { test, expect } from "@playwright/test"
import type { VxlanTunnel } from "../../lib/data"
test("VXLAN: все строки, числовая сортировка, экспорт выбранной строки и поиск", async ({ page }) => {
const tunnels: VxlanTunnel[] = Array.from({ length: 12 }, (_, i) => ({
id: String(i + 1), name: `vxlan-test-${i + 1}`, vni: i + 1, port: 0, dstPort: 8472,
serverId: "1", vtepIp: "192.0.2.1", remoteVteps: [`192.0.2.${i + 2}`], l2mtu: 1500, mtu: 1400,
arpProxy: false, macLearning: true, comment: "Тест", enabled: true, status: "up",
}))
const errors: string[] = []
page.on("pageerror", e => errors.push(e.message))
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/vxlan" ? { tunnels }
: path === "/api/auth/config" ? { required: false } : path === "/api/servers" ? [] : {} })
})
await page.goto("/vxlan")
const rows = page.locator("tr[data-row-id]")
await expect(rows).toHaveCount(12)
await page.getByRole("button", { name: "VNI", exact: true }).click()
await expect(rows.first()).toContainText("vxlan-test-12")
await page.getByRole("button", { name: "Действия: vxlan-test-12", exact: true }).click()
await page.getByRole("menuitem", { name: "Экспорт .rsc", exact: true }).click()
await expect(page.getByRole("dialog")).toContainText("vxlan-test-12")
await expect(page.getByRole("dialog").locator("pre")).toContainText("mtu=1400")
await page.keyboard.press("Escape")
await page.getByPlaceholder("Поиск по имени, VNI, серверу…").fill("vxlan-test-12")
await expect(rows).toHaveCount(1)
await expect(rows.first()).toContainText("vxlan-test-12")
await page.getByPlaceholder("Поиск по имени, VNI, серверу…").fill("нет-совпадений")
await expect(page.getByText("Нет VXLAN-туннелей", { exact: true })).toBeVisible()
await page.getByPlaceholder("Поиск по имени, VNI, серверу…").fill("")
await expect(rows).toHaveCount(12)
expect(errors).toEqual([])
})