fix(ipsec): подтвердить достоверность операций и приёмку раздела

This commit is contained in:
Denozordec committed 2026-10-09 12:46:22 +07:00
1 parent e2d81f9657
commit f80d9b7637
28 files changed
+969 -170

No files matched your search

+3 -3
View File
@@ -27,7 +27,7 @@ for (const device of ["desktop", "mobile"] as const) {
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
await page.addStyleTag({ content: "nextjs-portal { display: none !important; }" })
mkdirSync("docs/ux-ui/screens", { recursive: true })
await page.screenshot({ path: `docs/ux-ui/screens/ipsec-${device}.png`, animations: "disabled" })
await page.screenshot({ path: test.info().outputPath(`ipsec-${device}.png`), animations: "disabled" })
if (device === "mobile") {
await page.getByRole("button", { name: "Серверы", exact: true }).click()
await page.getByRole("dialog").getByRole("option").filter({ hasText: "Резервный VPN роутер" }).click()
@@ -40,7 +40,7 @@ for (const device of ["desktop", "mobile"] as const) {
const dialog = page.getByRole("dialog")
await dialog.getByRole("textbox", { name: "Имя клиента" }).fill("Проверенный клиент")
await expect.poll(() => dialog.evaluate(el => el.getBoundingClientRect().left >= 0 && el.getBoundingClientRect().right <= innerWidth)).toBe(true)
await page.screenshot({ path: `docs/ux-ui/screens/ipsec-client-${device}.png`, animations: "disabled" })
await page.screenshot({ path: test.info().outputPath(`ipsec-client-${device}.png`), animations: "disabled" })
await dialog.getByRole("button", { name: "Сохранить", exact: true }).focus()
await page.keyboard.press("Enter")
await expect(dialog).toHaveCount(0)
@@ -52,6 +52,6 @@ for (const device of ["desktop", "mobile"] as const) {
await page.clock.fastForward(6000)
await expect(page.getByText("Клиент обновлён", { exact: true })).toHaveCount(0)
if (device === "mobile") await page.getByRole("button", { name: "Переинициализировать", exact: true }).scrollIntoViewIfNeeded()
await page.screenshot({ path: `docs/ux-ui/screens/ipsec-servers-${device}.png`, animations: "disabled" })
await page.screenshot({ path: test.info().outputPath(`ipsec-servers-${device}.png`), animations: "disabled" })
})
}
+28
View File
@@ -0,0 +1,28 @@
import { test, expect } from "@playwright/test"
test.beforeEach(async ({ page }) => {
await page.route("**/health", r => r.fulfill({ json: { ok: true } }))
await page.route("**/api/**", r => {
const p = new URL(r.request().url()).pathname
return r.fulfill({ json: p === "/api/auth/config" ? { required: false } : p === "/api/servers" ? [1, 2].map(id => ({ id, name: "Роутер " + id, host: "192.0.2." + id, enabled: true, type: "home-router", country: "RU", status: "online" })) : p === "/api/ipsec" ? { servers: [1, 2].map(id => ({ serverId: String(id), serverName: "Роутер " + id, initialized: false, ike2Ready: false, natRuleManaged: false, clientsTotal: 0, clientsOnline: 0, peers: [] })), clients: [] } : {} })
})
})
test("IPsec: URL сохраняет устройство и вкладку после reload", async ({ page }) => {
await page.goto("/ipsec?server=2&tab=server")
await expect(page.getByRole("tab", { name: "Сервер", exact: true })).toHaveAttribute("aria-selected", "true")
await expect(page.getByRole("button", { name: "Инициализировать", exact: true })).toHaveCount(1)
await page.getByRole("tab", { name: "Клиенты", exact: true }).click()
await expect(page).toHaveURL(/server=2$/)
await page.reload()
await expect(page.getByRole("tab", { name: "Клиенты", exact: true })).toHaveAttribute("aria-selected", "true")
await page.getByRole("tab", { name: "Сервер", exact: true }).click()
await expect(page).toHaveURL(/server=2&tab=server$/)
})
test("IPsec: неизвестное устройство из URL не подменяется общим срезом", async ({ page }) => {
await page.goto("/ipsec?server=999&tab=server")
await expect(page.getByRole("alert").filter({ hasText: "Устройство из ссылки не найдено" })).toBeVisible()
await expect(page.getByRole("button", { name: "Инициализировать", exact: true })).toHaveCount(0)
await expect(page.getByRole("button", { name: "Новый клиент", exact: true })).toBeDisabled()
})