Files
MikrotikManager/tests/e2e/gre-ipv6.spec.ts
T

35 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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([])
})
}