fix(ui): сохранять ошибку загрузки истории IPsec

This commit is contained in:
Denozordec committed 2026-09-29 18:55:46 +07:00
1 parent 3dd4ad34ee
commit 46d62c98b8
5 files changed
+75 -9

No files matched your search

+45
View File
@@ -67,3 +67,48 @@ for (const section of ["wireguard", "ipsec", "gre", "firewall", "filters", "recu
expect(errors.filter(error => !error.includes("403 (Forbidden)"))).toEqual([])
})
}
test("История IPsec: ошибка, повтор и поздний ответ закрытой панели", async ({ page }) => {
let attempts = 0
let release: (() => void) | undefined
const gate = new Promise<void>(resolve => { release = resolve })
await page.route("**/health", route => route.fulfill({ json: { ok: true } }))
await page.route("**/api/**", async route => {
const path = new URL(route.request().url()).pathname
if (path === "/api/ipsec/revisions") {
attempts++
if (attempts === 1) return route.fulfill({ status: 403, json: { error: "История недоступна тест" } })
if (attempts === 2) {
await gate
return route.fulfill({ status: 500, json: { error: "Устаревшая ошибка тест" } })
}
if (attempts === 3) return route.fulfill({ json: {} })
return route.fulfill({ json: { revisions: [] } })
}
return route.fulfill({ json: path === "/api/auth/config" ? { required: false }
: path === "/api/ipsec" ? { servers: [], clients: [] }
: path === "/api/servers" ? [{ id: 1, name: "История роутер", host: "192.0.2.1", enabled: true, type: "exit-node", country: "RU", status: "online" }] : {} })
})
await page.goto("/ipsec")
await page.getByRole("option").filter({ hasText: "История роутер" }).click()
const open = page.getByRole("button", { name: "История", exact: true })
const sheet = page.getByRole("dialog", { name: "История конфигураций IPsec" })
await open.click()
await expect(sheet.getByRole("alert")).toContainText("История недоступна тест")
await expect(sheet.getByText("Истории пока нет", { exact: true })).toHaveCount(0)
await sheet.getByRole("button", { name: "Повторить загрузку" }).click()
await expect.poll(() => attempts).toBe(2)
await expect(sheet.getByRole("status")).toContainText("Загрузка истории")
await page.keyboard.press("Escape")
await expect(sheet).toHaveCount(0)
await open.click()
await expect(sheet.getByRole("alert")).toContainText("Некорректный ответ истории IPsec")
await sheet.getByRole("button", { name: "Повторить загрузку" }).click()
await expect(sheet.getByText("Истории пока нет", { exact: true })).toBeVisible()
const response = page.waitForResponse(r => r.url().includes("/api/ipsec/revisions?"))
release!()
await (await response).finished()
await page.waitForTimeout(150)
await expect(sheet.getByRole("alert")).toHaveCount(0)
await expect(sheet.getByText("Истории пока нет", { exact: true })).toBeVisible()
})