fix(wireguard): поддержать IPv6 и исключить выключенные серверы

This commit is contained in:
Denozordec committed 2026-10-11 22:08:10 +07:00
1 parent f3cbc32720
commit 4d3cb659c1
30 files changed
+2001 -82

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
import { test, expect } from "@playwright/test"
for (const width of [1440, 320]) {
test(`WireGuard IPv6: форма сохраняет адрес после ошибки API, ширина ${width}`, async ({ page }) => {
await page.setViewportSize({ width, height: 1000 })
let attempts = 0
const errors: string[] = []
page.on("pageerror", e => errors.push(e.message))
const iface = { id: "1:*152", rosId: "*152", name: "wg-ipv6", serverId: "1", serverName: "CHR", listenPort: 13231, mtu: 1420, address: "fd00:152::1/64", comment: "", enabled: true, status: "up", peers: [] }
await page.route("**/health", route => route.fulfill({ json: { ok: true } }))
await page.route("**/api/**", route => {
const path = new URL(route.request().url()).pathname
if (path === "/api/wireguard/interfaces" && route.request().method() === "POST") {
expect(route.request().postDataJSON()).toMatchObject({ name: "wg-ipv6", address: "fd00:152::1/64", serverId: "1" })
attempts++
return attempts === 1 ? route.fulfill({ status: 403, json: { error: "Запись запрещена тест" } }) : route.fulfill({ status: 201, json: iface })
}
return route.fulfill({ json: path === "/api/auth/config" ? { required: false } : path === "/api/servers" ? [{ id: 1, name: "CHR", host: "192.0.2.1", enabled: true, type: "exit-node", country: "RU", status: "online" }] : path === "/api/wireguard" ? { interfaces: attempts > 1 ? [iface] : [] } : {} })
})
await page.goto("/wireguard")
await page.getByRole("button", { name: "Новый интерфейс", exact: true }).first().click()
const dialog = page.getByRole("dialog")
await dialog.getByLabel("Сервер", { exact: true }).selectOption("1")
await dialog.getByLabel("Имя интерфейса", { exact: true }).fill("wg-ipv6")
await dialog.getByRole("button", { name: "Дополнительно", exact: true }).click()
await dialog.getByLabel("IP на интерфейсе", { exact: true }).fill("fd00:152::1/64")
await expect(dialog.getByLabel("IP на интерфейсе", { exact: true })).toHaveAttribute("placeholder", "IPv4/IPv6 с префиксом")
await dialog.getByRole("button", { name: "Создать туннель", exact: true }).click()
await expect(dialog.getByRole("alert")).toContainText("Запись запрещена тест")
await expect(dialog.getByLabel("IP на интерфейсе", { exact: true })).toHaveValue("fd00:152::1/64")
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
await dialog.getByRole("button", { name: "Создать туннель", exact: true }).click()
await expect(dialog).toHaveCount(0)
expect(attempts).toBe(2)
expect(errors).toEqual([])
})
}