fix(gre): сохранять и восстанавливать статические IPv6 адреса

This commit is contained in:
Denozordec committed 2026-10-11 21:37:12 +07:00
1 parent 655ea9727f
commit f3cbc32720
21 files changed
+1643 -60

No files matched your search

+2 -1
View File
@@ -13,7 +13,7 @@ for (const mode of ["create", "dto", "edit"]) {
if (route.request().method() === (mode === "edit" ? "PATCH" : "POST")) {
attempts++
expect(path).toBe("/api/gre/tunnels")
expect(route.request().postDataJSON()).toMatchObject({ serverId: "1", name: "gre-test", remoteAddress: "192.0.2.9", remoteInnerIp, comment: "сохранённый ввод" })
expect(route.request().postDataJSON()).toMatchObject({ serverId: "1", name: "gre-test", remoteAddress: "192.0.2.9", remoteInnerIp, localInnerIp: mode === "edit" ? "" : "fd00:151::1/64", comment: "сохранённый ввод" })
if (mode === "edit") expect(route.request().postDataJSON().rosId).toBe("*T/1")
if (attempts === 1) { await gate; return route.fulfill({ status: 403, json: { error: "Запись запрещена тест" } }) }
if (attempts === 2) return route.fulfill({ json: {} })
@@ -40,6 +40,7 @@ for (const mode of ["create", "dto", "edit"]) {
await sheet.getByLabel("Удалённый адрес").fill("192.0.2.9")
await sheet.getByLabel("Комментарий").fill("сохранённый ввод")
await sheet.getByLabel("Удалённый IP", { exact: true }).fill(remoteInnerIp)
await sheet.getByLabel("Локальный IP", { exact: true }).fill(mode === "edit" ? "" : "fd00:151::1/64")
const submit = sheet.getByRole("button", { name: mode === "edit" ? "Сохранить" : "Создать туннель", exact: true })
await submit.evaluate(button => { (button as HTMLButtonElement).click(); (button as HTMLButtonElement).click() })
await expect.poll(() => attempts).toBe(1)
+34
View File
@@ -0,0 +1,34 @@
import { test, expect } from "@playwright/test"
for (const width of [1440, 320]) {
test(`GRE IPv6: каталог и явная очистка адреса, ширина ${width}`, async ({ page }) => {
await page.setViewportSize({ width, height: 1000 })
const errors: string[] = []
page.on("pageerror", e => errors.push(e.message))
const tunnel = { id: "*151", name: "gre-ipv6", serverId: "1", localAddress: "192.0.2.1", remoteAddress: "192.0.2.2", localInnerIp: "fd00:151::1/64", remoteInnerIp: "fd00:151::2", poolId: "live", ipsec: null, mtu: 1400, keepaliveInterval: 10, keepaliveRetries: 3, dscp: "inherit", clampTcpMss: true, allowFastPath: false, comment: "", enabled: true, status: "up" }
let submitted = false
await page.route("**/health", route => route.fulfill({ json: { ok: true } }))
await page.route("**/api/**", route => {
const path = new URL(route.request().url()).pathname
if (route.request().method() === "PATCH" && path === "/api/gre/tunnels") {
expect(route.request().postDataJSON()).toMatchObject({ rosId: "*151", localInnerIp: "", remoteInnerIp: "fd00:151::2" })
submitted = true
return route.fulfill({ json: { ok: true } })
}
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/gre/tunnels" ? { tunnels: [tunnel] } : {} })
})
await page.goto("/gre")
await expect(page.getByRole("button", { name: "Действия: gre-ipv6" })).toBeVisible()
await page.getByRole("button", { name: "Действия: gre-ipv6" }).click()
await page.getByRole("menuitem", { name: "Редактировать", exact: true }).click()
const sheet = page.getByRole("dialog")
await expect(sheet.getByLabel("Локальный IP", { exact: true })).toHaveValue("fd00:151::1/64")
await expect(sheet.getByLabel("Локальный IP", { exact: true })).toHaveAttribute("placeholder", "IPv4/IPv6 с префиксом")
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
await sheet.getByLabel("Локальный IP", { exact: true }).fill("")
await sheet.getByRole("button", { name: "Сохранить", exact: true }).click()
await expect(sheet).toHaveCount(0)
expect(submitted).toBe(true)
expect(errors).toEqual([])
})
}