fix(ui): перенести таблицы IPsec и GRE на ReUI v9
This commit is contained in:
1 parent
8b9b584513
commit
583b23ded1
5 files changed
+115
-35
No files matched your search
@@ -0,0 +1,70 @@
|
||||
import { test, expect, type Page } from "@playwright/test"
|
||||
import { ipsecListResponseSchema } from "../../packages/contracts/src/ipsec"
|
||||
import type { GreTunnel } from "../../lib/data"
|
||||
|
||||
const ids = Array.from({ length: 12 }, (_, i) => i + 1)
|
||||
const ipsec = ipsecListResponseSchema.parse({ servers: [], clients: ids.map(i => ({
|
||||
id: String(i), rosId: `*${i}`, serverId: "1", serverName: "Тестовый роутер",
|
||||
name: `Клиент ${i}`, authMethod: "certificate", online: false, disabled: false, managed: true,
|
||||
})) })
|
||||
const tunnels: GreTunnel[] = ids.map(i => ({
|
||||
id: String(i), name: `gre-test-${i}`, serverId: "1", localAddress: "192.0.2.1",
|
||||
remoteAddress: `192.0.2.${i + 1}`, localInnerIp: `10.0.${i}.1/30`, remoteInnerIp: `10.0.${i}.2/30`,
|
||||
poolId: `pool-${i}`, ipsec: null, mtu: 1400 + i, keepaliveInterval: 10, keepaliveRetries: 3,
|
||||
dscp: "inherit", clampTcpMss: true, allowFastPath: true, comment: "Тест", enabled: true, status: "up",
|
||||
}))
|
||||
|
||||
async function setup(page: Page, path: string, empty = false) {
|
||||
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/ipsec" ? (empty ? { servers: [], clients: [] } : ipsec)
|
||||
: path === "/api/gre/tunnels" ? { tunnels: empty ? [] : tunnels }
|
||||
: path === "/api/auth/config" ? { required: false } : path === "/api/servers" ? [] : {} })
|
||||
})
|
||||
await page.goto(path)
|
||||
}
|
||||
|
||||
test("IPsec: 12 клиентов, сортировка, выбор удаления и поиск", async ({ page }) => {
|
||||
await setup(page, "/ipsec")
|
||||
const rows = page.locator("tr[data-row-id]")
|
||||
await expect(rows).toHaveCount(12)
|
||||
await page.getByRole("table").getByRole("button", { name: "Клиент", exact: true }).click()
|
||||
await expect(rows.first()).toContainText("Клиент 1")
|
||||
await page.getByRole("table").getByRole("button", { name: "Клиент", exact: true }).click()
|
||||
await expect(rows.first()).toContainText("Клиент 12")
|
||||
await rows.first().getByRole("button", { name: "Удалить клиента" }).click()
|
||||
await expect(page.getByRole("alertdialog")).toContainText("Клиент 12")
|
||||
await page.getByRole("button", { name: "Отмена", exact: true }).click()
|
||||
await page.getByPlaceholder("Поиск по имени / CN / IP…").fill("Клиент 12")
|
||||
await expect(rows).toHaveCount(1)
|
||||
})
|
||||
|
||||
test("GRE: 12 туннелей и пулов, числовая сортировка и поиск", async ({ page }) => {
|
||||
const errors: string[] = []
|
||||
page.on("pageerror", e => errors.push(e.message))
|
||||
await setup(page, "/gre")
|
||||
const rows = page.locator("tr[data-row-id]")
|
||||
await expect(rows).toHaveCount(12)
|
||||
await page.getByRole("button", { name: "MTU", exact: true }).click()
|
||||
await expect(rows.first()).toContainText("gre-test-12")
|
||||
await page.getByPlaceholder("Поиск по имени, IP…").fill("gre-test-12")
|
||||
await expect(rows).toHaveCount(1)
|
||||
await page.getByPlaceholder("Поиск по имени, IP…").fill("")
|
||||
await page.getByRole("button", { name: "IP-пулы", exact: true }).click()
|
||||
await expect(rows).toHaveCount(12)
|
||||
await page.getByRole("button", { name: "Имя пула", exact: true }).click()
|
||||
await expect(rows.first()).toContainText("pool-1")
|
||||
await page.getByRole("button", { name: "Имя пула", exact: true }).click()
|
||||
await expect(rows.first()).toContainText("pool-12")
|
||||
expect(errors).toEqual([])
|
||||
})
|
||||
|
||||
test("Пустые ответы IPsec и GRE", async ({ page }) => {
|
||||
await setup(page, "/ipsec", true)
|
||||
await expect(page.getByText("Нет клиентов IKEv2", { exact: true })).toBeVisible()
|
||||
await page.goto("/gre")
|
||||
await expect(page.getByText("Нет GRE-туннелей", { exact: true })).toBeVisible()
|
||||
await page.getByRole("button", { name: "IP-пулы", exact: true }).click()
|
||||
await expect(page.getByText("Нет IP-пулов", { exact: true })).toBeVisible()
|
||||
})
|
||||
Reference in new issue
Block a user