fix(ui): улучшить мобильную сводку и детали BGP
This commit is contained in:
1 parent
aa678b9d5d
commit
72a63b4a4f
13 files changed
+76
-15
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { test, expect } from "@playwright/test"
|
||||
import { mkdirSync } from "node:fs"
|
||||
const server = (id: number) => ({ id, name: "Роутер " + id, host: "192.0.2." + id, enabled: true, country: "RU", status: null })
|
||||
const session = (serverId: number, name = "Сессия " + serverId) => ({ id: "*1", serverId, serverName: "Роутер " + serverId, serverSite: "", serverCountry: "RU", name, peerIp: "192.0.2." + serverId, remoteAs: 64513, localAs: 64512, localId: "192.0.2.100", remoteId: "192.0.2." + serverId, state: "Established", type: "eBGP", uptime: "1h", holdTime: 90, keepalive: 30, prefixesRx: 12, prefixesTx: 2, inputMessages: 20, outputMessages: 10, capabilities: ["Тест capability"], lastError: null })
|
||||
|
||||
for (const device of ["desktop", "mobile"] as const) {
|
||||
test("BGP: layout и клавиатура " + device, async ({ page }) => {
|
||||
await page.setViewportSize(device === "desktop" ? { width: 1440, height: 1000 } : { width: 390, height: 844 })
|
||||
await page.clock.install({ time: new Date("2026-09-30T05:00:00Z") })
|
||||
await page.route("**/health", r => r.fulfill({ json: { ok: true } }))
|
||||
await page.route("**/api/**", r => {
|
||||
const path = new URL(r.request().url()).pathname
|
||||
return r.fulfill({ json: path === "/api/servers" ? [server(1), server(2)] : path === "/api/bgp/catalog" ? { sessions: [session(1), session(2)], failures: [] } : path === "/api/auth/config" ? { required: false } : {} })
|
||||
})
|
||||
await page.goto("/bgp?server=2")
|
||||
await expect(page.locator("tr[data-row-id]")).toHaveCount(1)
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
|
||||
const scroll = page.getByRole("button", { name: /^Idle/ }).locator("..").first()
|
||||
expect(await scroll.evaluate(el => el.getBoundingClientRect().right <= innerWidth)).toBe(true)
|
||||
await page.addStyleTag({ content: "nextjs-portal { display: none !important; }" })
|
||||
mkdirSync("docs/ux-ui/screens", { recursive: true })
|
||||
await page.screenshot({ path: "docs/ux-ui/screens/bgp-" + device + ".png", animations: "disabled" })
|
||||
const expand = page.getByRole("button", { name: "Открыть сессию Роутер 2 · 192.0.2.2", exact: true })
|
||||
await expand.focus()
|
||||
await page.keyboard.press("Enter")
|
||||
await expect(page.getByText("Тест capability", { exact: true })).toBeVisible()
|
||||
if (device === "mobile") expect(await page.getByText("Тест capability", { exact: true }).evaluate(el => el.getBoundingClientRect().right <= innerWidth)).toBe(true)
|
||||
await expect.poll(() => new URL(page.url()).searchParams.get("session")).toBe("2-*1")
|
||||
await page.screenshot({ path: "docs/ux-ui/screens/bgp-detail-" + device + ".png", animations: "disabled" })
|
||||
await page.getByRole("button", { name: "Аналитика", exact: true }).focus()
|
||||
await page.keyboard.press("Enter")
|
||||
await expect(page.getByLabel("Сводка префиксов BGP")).toBeVisible()
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
|
||||
await page.screenshot({ path: "docs/ux-ui/screens/bgp-analytics-" + device + ".png", animations: "disabled" })
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user