fix(ui): показывать свежесть опроса и изменений IPsec

This commit is contained in:
Denozordec committed 2026-09-30 14:58:55 +07:00
1 parent 921aba3054
commit ce43b2d762
5 files changed
+75 -1

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import { test, expect } from "@playwright/test"
test("IPsec: время успешного опроса сохраняется при частичном/полном отказе", async ({ page }) => {
await page.clock.install({ time: new Date("2026-09-30T05:00:00Z") })
const summary = (id: string) => ({ serverId: id, serverName: "Роутер " + id, initialized: false, ike2Ready: false, peers: [], natRuleManaged: false, clientsTotal: 0, clientsOnline: 0 })
let phase = 0
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/ipsec" && phase === 2) return r.fulfill({ status: 503, json: { error: "Опрос недоступен тест" } })
return r.fulfill({ json: path === "/api/ipsec" ? { servers: phase === 1 ? [summary("1")] : [summary("1"), summary("2")], clients: [], failures: phase === 1 ? [{ serverId: "2", error: "Таймаут тест" }] : [] }
: path === "/api/servers" ? [1, 2].map(id => ({ id, name: "Роутер " + id, host: "192.0.2." + id, enabled: true, country: "RU" }))
: path === "/api/auth/config" ? { required: false } : {} })
})
await page.goto("/ipsec")
const time = page.getByRole("group", { name: "Свежесть IPsec" }).locator('[data-source-time="read"] time')
await expect(time).toHaveCount(1)
await page.getByRole("option").filter({ hasText: "Роутер 2" }).click()
const first = await time.getAttribute("datetime")
phase = 1
await page.clock.fastForward(60_000)
await page.getByRole("button", { name: "Обновить", exact: true }).click()
await expect(page.getByRole("alert").filter({ hasText: "Не удалось опросить часть роутеров" })).toBeVisible()
await expect(time).toHaveAttribute("datetime", first!)
phase = 2
await page.clock.fastForward(60_000)
await page.getByRole("button", { name: "Обновить", exact: true }).click()
await expect(page.getByRole("alert").filter({ hasText: "Не удалось загрузить IPsec" })).toBeVisible()
await expect(time).toHaveAttribute("datetime", first!)
phase = 3
await page.clock.fastForward(60_000)
await page.getByRole("button", { name: "Повторить загрузку IPsec" }).click()
await expect(time).not.toHaveAttribute("datetime", first!)
await expect(page.getByRole("button", { name: "Новый клиент", exact: true })).toBeEnabled()
})
+1
View File
@@ -30,6 +30,7 @@ test("IPsec: удаление держит замок до обновления
await expect(submit).toBeDisabled()
release!()
await expect(dialog).toHaveCount(0)
await expect(page.getByRole("group", { name: "Свежесть IPsec" }).locator('[data-source-time="write"] time')).toHaveCount(1)
await expect(page.getByRole("alert").filter({ hasText: "Не удалось загрузить IPsec" })).toContainText("Опрос после удаления недоступен")
await expect(rows).toHaveCount(1)
await expect(rows.getByRole("button", { name: "Удалить клиента" })).toBeDisabled()