fix(ui): адаптировать строки Ping-проб для телефона

This commit is contained in:
Denozordec committed 2026-09-21 09:58:43 +07:00
1 parent dfb993e1a3
commit e9e5030047
5 files changed
+133 -38

No files matched your search

+45 -2
View File
@@ -1,13 +1,18 @@
import { test, expect, type Page } from "@playwright/test"
async function setup(page: Page, url: string, failed = 0) {
const control = { failed, posts: [] as { path: string; body: unknown }[] }
async function setup(page: Page, url: string, failed = 0, longNames = false) {
const control = { writes: [] as { method: string; path: string; body: unknown }[], failed, posts: [] as { path: string; body: unknown }[] }
const servers = [{ id: 1, name: "Источник", host: "192.0.2.1", type: "exit-node", enabled: true, country: "RU", site: "TEST", asn: "64512", status: "online", latency: 1, os: "7", model: "CHR", wanUplinks: [] }]
const probes = ["p1", "p/2"].map(id => ({ id, srcServerId: "1", name: "Проверка сети", target: "192.0.2.10", filter: "main", rtt: null, loss: 100, status: "down", series: [0], enabled: true, showOnDashboard: false }))
if (longNames) {
servers[0].name = "Источник-с-длинным-названием-площадки-для-проверки-переноса"
probes.forEach(p => { p.name = "Проверка-доступности-длинного-имени-сетевого-узла"; p.target = "router-with-a-long-hostname.example.test"; p.filter = "Фильтр-с-длинным-названием" })
}
await page.route("**/health", route => route.fulfill({ json: { ok: true } }))
await page.route("**/api/**", route => {
const request = route.request()
const path = new URL(request.url()).pathname
if (!["GET", "HEAD"].includes(request.method())) control.writes.push({ method: request.method(), path, body: request.postDataJSON() })
if (request.method() === "POST") control.posts.push({ path, body: request.postDataJSON() })
if (path === "/api/uptime/overview" && control.failed) return route.fulfill({ status: control.failed, json: { error: "Мониторинг недоступен" } })
const json = path === "/api/auth/config" ? { required: false }
@@ -83,3 +88,41 @@ for (const failed of [0, 403, 500]) {
expect(control.posts).toEqual([])
})
}
for (const width of [320, 390, 1440]) {
test(`Ping-пробы ${width}px: длинные подписи, доступные действия и раскрытие`, async ({ page }) => {
await page.setViewportSize({ width, height: 1000 })
const control = await setup(page, "/uptime?probe=p%2F2", 0, true)
const row = page.locator('[data-probe-id="p/2"]')
await expect(row).toBeVisible()
await expect(row.getByText("График RTT", { exact: true })).toBeVisible({ visible: width < 1440 })
if (width < 1440) expect(await row.getByText("Фильтр-с-длинным-названием", { exact: true }).evaluate(el => el.getBoundingClientRect().right)).toBeLessThanOrEqual(width)
for (const name of ["Редактировать пробу", "Удалить пробу", "Показать на дашборде"]) {
const button = row.getByRole("button", { name, exact: true })
await button.scrollIntoViewIfNeeded()
const bounds = await button.boundingBox()
expect(bounds!.x).toBeGreaterThanOrEqual(0)
expect(bounds!.x + bounds!.width).toBeLessThanOrEqual(width)
}
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(width)
const toggle = row.getByRole("switch", { name: /Включить пробу/ })
await expect(toggle).toBeChecked()
const chart = row.getByRole("button", { name: /Подробный график RTT/ })
await chart.focus()
await page.keyboard.press("Enter")
await expect(chart).toHaveAttribute("aria-expanded", "true")
await page.keyboard.press("Enter")
await expect(chart).toHaveAttribute("aria-expanded", "false")
await row.scrollIntoViewIfNeeded()
await page.screenshot({ path: `test-results/ping-row-${width}.png`, animations: "disabled" })
expect(control.writes).toEqual([])
await row.getByRole("button", { name: "Редактировать пробу", exact: true }).click()
await expect(page.getByRole("dialog")).toBeVisible()
await page.keyboard.press("Escape")
await expect(page.getByRole("dialog")).toBeHidden()
await row.getByRole("button", { name: "Показать на дашборде", exact: true }).click()
await expect.poll(() => control.writes.some(w => w.method === "PATCH" && w.path === "/api/uptime/probes/p%2F2" && (w.body as { showOnDashboard: boolean }).showOnDashboard === true)).toBe(true)
await toggle.click()
await expect.poll(() => control.writes.some(w => w.method === "PUT" && w.path === "/api/uptime/probes")).toBe(true)
})
}