fix(ui): разделить время опроса и подтверждения OSPF
This commit is contained in:
1 parent
baa43b7ad4
commit
c18c148a23
5 files changed
+65
-4
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { test, expect } from "@playwright/test"
|
||||
const servers = [1, 2].map(id => ({ id, name: "Роутер " + id, host: "192.0.2." + id, country: "RU", enabled: true, status: null }))
|
||||
const host = (serverId: number) => ({ serverId, serverName: "Роутер " + serverId, serverSite: "", serverCountry: "RU" })
|
||||
const neighbor = (serverId: number, address = "192.0.2." + serverId) => ({ ...host(serverId), id: "*1", address, routerId: address, instance: "default", area: "backbone", areaId: "0.0.0.0", interface: "ether1", state: "Full", uptime: "1h", stateChanges: 0, priority: 1 })
|
||||
const all = { neighbors: [neighbor(1), neighbor(2)], interfaces: [], instances: [], bfdSessions: [], routes: [], failures: [] }
|
||||
|
||||
test("OSPF: время успешного опроса устройства сохраняется при отказе", async ({ page }) => {
|
||||
await page.clock.install({ time: new Date("2026-09-30T05:00:00Z") })
|
||||
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/ospf/catalog" && phase === 2) return r.fulfill({ status: 503, json: { error: "Общий отказ OSPF" } })
|
||||
return r.fulfill({ json: path === "/api/servers" ? [...servers] : path === "/api/ospf/catalog" ? { ...all, neighbors: phase === 1 ? [neighbor(1)] : [neighbor(1), neighbor(2)], failures: phase === 1 ? [{ serverId: 2, serverName: "Роутер 2", error: "Таймаут тест" }] : [] } : path === "/api/auth/config" ? { required: false } : {} })
|
||||
})
|
||||
await page.goto("/ospf")
|
||||
const group = page.getByRole("group", { name: "Свежесть OSPF" })
|
||||
const first = await group.locator('[data-ospf-server="2"]').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(group.locator('[data-ospf-server="2"]')).toHaveAttribute("datetime", first!)
|
||||
await expect(group.locator('[data-ospf-server="1"]')).not.toHaveAttribute("datetime", first!)
|
||||
const after = await group.locator('[data-ospf-server="1"]').getAttribute("datetime")
|
||||
phase = 2
|
||||
await page.clock.fastForward(60_000)
|
||||
await page.getByRole("button", { name: "Повторить загрузку OSPF" }).click()
|
||||
await expect(page.getByRole("alert").filter({ hasText: "Общий отказ OSPF" })).toBeVisible()
|
||||
await expect(group.locator('[data-ospf-server="1"]')).toHaveAttribute("datetime", after!)
|
||||
await expect(group.locator('[data-ospf-server="2"]')).toHaveAttribute("datetime", first!)
|
||||
phase = 3
|
||||
await page.getByRole("button", { name: "Повторить загрузку OSPF" }).click()
|
||||
await expect(page.getByRole("alert").filter({ hasText: "Не удалось" })).toHaveCount(0)
|
||||
await expect(group.locator('[data-ospf-server="2"]')).not.toHaveAttribute("datetime", first!)
|
||||
})
|
||||
@@ -43,7 +43,10 @@ for (const outcome of ["success", "http", "foreign", "malformed", "poll-failure"
|
||||
if (["http", "foreign", "malformed"].includes(outcome)) {
|
||||
await expect(page.getByRole("alert").filter({ hasText: "Оптимизация OSPF не подтверждена" })).toBeVisible()
|
||||
await expect(page.getByText("API подтвердил оптимизацию OSPF", { exact: false })).toHaveCount(0)
|
||||
} else await expect(page.getByText("API подтвердил оптимизацию OSPF: 1 интерфейсов", { exact: true })).toBeVisible()
|
||||
} else {
|
||||
await expect(page.getByText("API подтвердил оптимизацию OSPF: 1 интерфейсов", { exact: true })).toBeVisible()
|
||||
await expect(page.getByRole("group", { name: "Свежесть OSPF" }).locator('[data-ospf-time="write"]')).toContainText("API подтвердил оптимизацию устройства 1")
|
||||
}
|
||||
if (outcome === "poll-failure") {
|
||||
await expect(page.getByRole("alert").filter({ hasText: "Опрос после записи недоступен" })).toBeVisible()
|
||||
await expect(optimize).toBeDisabled()
|
||||
|
||||
Reference in new issue
Block a user