fix(ipsec): показывать неопределённый статус при общих Remote ID

This commit is contained in:
Denozordec committed 2026-10-10 10:33:54 +07:00
1 parent 7815e00a1c
commit cb6ec09312
20 files changed
+1077 -15

No files matched your search

+38
View File
@@ -5,6 +5,44 @@ const client = (id: string, name = "Клиент " + id) => ({ id: id + "-*1", r
const servers = [1, 2].map(id => ({ id, name: "Роутер " + id, host: "192.0.2." + id, enabled: true, country: "RU", type: "exit-node", status: "online" }))
const full = { servers: [summary("1"), summary("2")], clients: [client("1"), client("2")] }
for (const width of [1280, 320]) {
test(`IPsec: неоднозначная сессия и восстановление статуса ${width}px`, async ({ page }) => {
await page.setViewportSize({ width, height: 1000 })
let phase = 0
const rows = [client("1", "Сертификат"), { ...client("1", "PSK"), id: "1-*2", rosId: "*2", kind: "psk", authMethod: "pre-shared-key" }]
await page.route("**/health", r => r.fulfill({ json: { ok: true } }))
await page.route("**/api/**", r => {
const path = new URL(r.request().url()).pathname
const values = phase === 0 ? rows.map(c => ({ ...c, sessionAmbiguous: true })) : [
{ ...rows[0], online: true, activeAddress: "198.18.112.250", ...(phase === 2 ? { sessionAmbiguous: true } : {}) }, rows[1],
]
return r.fulfill({ json: path === "/api/ipsec" ? { servers: [{ ...summary("1"), clientsTotal: 2, clientsOnline: phase === 0 ? 0 : 1, ...(phase === 0 ? { clientsSessionAmbiguous: 2 } : {}) }], clients: values }
: path === "/api/servers" ? servers : path === "/api/auth/config" ? { required: false } : {} })
})
await page.goto("/ipsec?server=1")
const gridRows = page.locator("tr[data-row-id]")
const ambiguity = page.getByRole("alert").filter({ hasText: "Статус части клиентов не определён" })
await expect(ambiguity).toContainText("У 2 клиентов")
await expect(gridRows).toHaveCount(2)
await expect(gridRows.getByText("Не определено", { exact: true })).toHaveCount(2)
await expect(gridRows.getByText("офлайн", { exact: true })).toHaveCount(0)
await expect(page.getByLabel("Сводка IPsec")).toContainText("—")
await page.getByRole("tab", { name: "Сервер", exact: true }).click()
await expect(page.getByText("0 подтверждено онлайн / 2; статус 2 не определён", { exact: true })).toBeVisible()
await page.getByRole("tab", { name: "Клиенты", exact: true }).click()
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
phase = 1
await page.getByRole("button", { name: "Обновить", exact: true }).click()
await expect(ambiguity).toHaveCount(0)
await expect(gridRows.getByText("офлайн", { exact: true })).toHaveCount(1)
await expect(gridRows.getByText("198.18.112.250", { exact: true })).toHaveCount(1)
phase = 2
await page.getByRole("button", { name: "Обновить", exact: true }).click()
await expect(page.getByRole("alert").filter({ hasText: "Не удалось загрузить IPsec" })).toBeVisible()
await expect(gridRows.getByText("198.18.112.250", { exact: true })).toHaveCount(1)
})
}
for (const broken of ["http", "payload", "duplicate", "conflict", "peer-context", "pool-context", "blank-failure"]) {
test(`IPsec: неизвестное начало и сохранение данных при ${broken}`, async ({ page }) => {
let phase = 0