fix(ui): раскрывать предупреждения ресурсов порциями

This commit is contained in:
Denozordec committed 2026-10-04 03:00:32 +07:00
1 parent 2762f073a0
commit ab334764cf
6 files changed
+77 -28

No files matched your search

+28
View File
@@ -1,4 +1,5 @@
import { test, expect } from "@playwright/test"
import axe from "axe-core"
test("1000 ресурсов: страницы, поиск, обновление и уменьшение списка", async ({ page }, info) => {
test.setTimeout(90000)
@@ -44,8 +45,35 @@ test("1000 ресурсов: страницы, поиск, обновление
for (let i = 0; i < 3; i++) await page.getByRole("button", { name: "…", exact: true }).last().click()
await page.getByRole("button", { name: "Перейти на страницу 20", exact: true }).click()
await expect(page.getByText("951–1000 из 1000", { exact: true })).toBeVisible()
resources = resources.map(resource => ({ ...resource, cpu: 90 }))
await page.getByRole("button", { name: "Обновить данные", exact: true }).click()
const warnings = page.getByRole("alert").filter({ hasText: "Серверов с предупреждениями: 1000" })
await expect(warnings).toBeVisible()
await expect(warnings.locator("[data-resource-warning]")).toHaveCount(5)
console.log(JSON.stringify({ warningRows: 1000, warningNodes: await warnings.locator("*").count(), domNodes: await page.locator("*").count() }))
expect(await page.locator("*").count()).toBeLessThan(3500)
const summary = warnings.locator("summary")
await summary.focus()
await page.keyboard.press("Enter")
await expect(warnings.locator("[data-resource-warning]")).toHaveCount(55)
await warnings.getByRole("button", { name: "Показать ещё 50", exact: true }).click()
await expect(warnings.locator("[data-resource-warning]")).toHaveCount(105)
await summary.click()
await expect(warnings.locator("[data-resource-warning]")).toHaveCount(5)
await summary.click()
await expect(warnings.locator("[data-resource-warning]")).toHaveCount(55)
await summary.click()
await page.setViewportSize({ width: 320, height: 900 })
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true)
await page.addScriptTag({ content: axe.source })
const audit = await page.evaluate(async () => {
const engine = (window as unknown as { axe: typeof axe }).axe
const root = document.querySelector("[data-resource-warning]")!.closest("[role=alert]")!
return engine.run(root, { runOnly: { type: "tag", values: ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"] } })
})
await info.attach("resource-warning-axe", { body: JSON.stringify(audit), contentType: "application/json" })
expect(audit.violations.map(violation => ({ id: violation.id, nodes: violation.nodes.map(node => node.target) }))).toEqual([])
resources = resources.slice(0, 1)
await page.getByRole("button", { name: "Обновить данные", exact: true }).click()
await expect(rows).toHaveCount(1)