38 lines
2.6 KiB
TypeScript
38 lines
2.6 KiB
TypeScript
import { test, expect, type Page } from "@playwright/test"
|
|
import { geoip } from "./fixtures/geoip"
|
|
import { keyedNetflowSettings } from "./fixtures/netflow-settings"
|
|
const common = { enabled: true, intervalSec: 300, retentionDays: 14, lastCollectedAt: null, lastDurationMs: 0, lastError: null }
|
|
const values: Record<string, object> = {
|
|
"/api/traffic/settings": { ...common, intervalSec: 45 },
|
|
"/api/servers-api-ping/settings": { ...common, enabled: false, intervalSec: 120 },
|
|
"/api/uptime/settings": { ...common, resourcesEnabled: true, pingEnabled: false, speedEnabled: false, probeIntervalSec: 15, speedIntervalSec: 60 },
|
|
"/api/internet-path/settings": common,
|
|
"/api/certificates/renew-settings": { enabled: false, intervalSec: 21600, renewBeforeDays: 30 },
|
|
}
|
|
async function setup(page: Page) {
|
|
await page.route("**/health", r => r.fulfill({ json: { ok: true } }))
|
|
await page.route("**/api/**", r => {
|
|
const path = new URL(r.request().url()).pathname
|
|
if (path === "/api/auth/config") return r.fulfill({ json: { required: false } })
|
|
if (path === "/api/geoip") return r.fulfill({ json: geoip })
|
|
if (path === "/api/scheduler/status") return r.fulfill({ json: { jobs: [] } })
|
|
if (path === "/api/scheduler/runs") return r.fulfill({ json: { runs: [] } })
|
|
if (path === "/api/traffic/flow/settings") return r.fulfill({ json: {...keyedNetflowSettings,publicEndpoint:"collector.example.test"} })
|
|
if (values[path]) return r.fulfill({ json: values[path] })
|
|
return r.fulfill({ status: 503, json: { error: "outside settings fixture" } })
|
|
})
|
|
}
|
|
|
|
|
|
for (const width of [1440, 390, 320]) test("NetFlow: адаптивность/" + width, async ({ page }) => {
|
|
await page.setViewportSize({ width, height: 1000 }); await setup(page); await page.goto("/data-collection")
|
|
const section = page.getByText("Traffic Flow / NetFlow (IPFIX)", { exact: true }).locator("xpath=ancestor::*[@data-slot='frame'][1]")
|
|
await expect(page.getByRole("textbox", { name: "UDP IPFIX", exact: true })).toHaveValue("4739")
|
|
await page.getByText("Traffic Flow / NetFlow (IPFIX)", {exact:true}).scrollIntoViewIfNeeded()
|
|
expect(await section.evaluate(element => element.scrollWidth <= element.clientWidth + 2)).toBe(true)
|
|
expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true)
|
|
await page.screenshot({ path: "docs/ux-ui/screens/netflow-" + width + ".png", fullPage: true })
|
|
await page.getByRole("button",{name:"Сохранить NetFlow",exact:true}).scrollIntoViewIfNeeded()
|
|
await page.screenshot({path:"docs/ux-ui/screens/netflow-actions-"+width+".png",fullPage:true})
|
|
})
|