Files
MikrotikManager/tests/e2e/uptime-speed-interface.spec.ts

31 lines
2.3 KiB
TypeScript

import { test, expect } from "@playwright/test"
import { server } from "./fixtures/users"
test("Speed: форма использует адрес каталога и разделяет маршрут теста и Ping-интерфейс", async ({ page }) => {
const probe = { id: "iface-probe", srcServerId: "1", dstServerId: "2", srcInterface: "ether1", dstInterface: "ether1", protocol: "tcp", direction: "transmit", durationSec: "3", enabled: true, lastRunAt: null, lastStatus: null, lastError: null, lastTxAvgMbps: null, lastRxAvgMbps: null }
await page.route("**/health", route => route.fulfill({ json: { ok: true } }))
await page.route("**/api/**", route => {
const path = new URL(route.request().url()).pathname
return route.fulfill({ json:
path === "/api/auth/config" ? { required: false } :
path === "/api/servers" ? [server, { ...server, id: 2, name: "Назначение", host: "198.51.100.2" }] :
path === "/api/uptime/overview" ? { probes: [], resources: [] } :
path === "/api/uptime/speed-probes" ? { probes: [probe] } :
path === "/api/uptime/speed-test/runs" ? { runs: [] } :
path.includes("/speed-test/endpoints/") ? { interfaces: [{ name: "ether1", running: true, disabled: false, addresses: path.includes("/2/") ? ["195.195.195.195", "198.51.100.2"] : ["192.0.2.1"] }] } : {},
})
})
await page.goto("/uptime?tab=speed")
await page.getByRole("button", { name: "Редактировать speed-пробу", exact: true }).click()
const dialog = page.getByRole("dialog")
const commands = dialog.locator("pre")
await expect(commands).toContainText('/ip address print where interface="ether1"')
await expect(commands).not.toContainText("where name=")
await expect(commands).toContainText('/ping address=195.195.195.195 count=4 interface="ether1"')
await expect(commands).toContainText("/tool bandwidth-test address=195.195.195.195")
await expect(dialog).toContainText("Интерфейс источника используется для Ping после теста")
await expect(dialog).toContainText("Маршрут bandwidth-test определяет RouterOS")
await page.setViewportSize({ width: 320, height: 900 })
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
})