fix(ui): вписывать топологию в область карты

This commit is contained in:
Denozordec committed 2026-10-01 03:18:02 +07:00
1 parent 89e48c2424
commit bc83b8dbbf
13 files changed
+91 -88

No files matched your search

+18
View File
@@ -44,3 +44,21 @@ test("Карта: reduced motion и самостоятельный SVG эксп
const parsed=await page.evaluate(source=>{const doc=new DOMParser().parseFromString(source,"image/svg+xml");return {errors:doc.querySelectorAll("parsererror").length,width:doc.documentElement.getAttribute("width")}},source)
expect(parsed.errors).toBe(0);expect(parsed.width).toBe("1240")
})
test("Карта: пропорции камеры, ручной масштаб и обновление без сброса",async({page})=>{
await page.setViewportSize({width:390,height:900});await page.goto("/network-map")
const map=page.getByRole("group",{name:"Интерактивная карта сети"})
await expect(page.getByRole("button",{name:/^Устройство Домашний/})).toBeVisible()
await expect.poll(async()=>Number((await map.getAttribute("viewBox"))!.split(" ")[2])).toBeLessThan(1240)
const camera=await map.evaluate((element:SVGSVGElement)=>{const rect=element.getBoundingClientRect(),box=element.viewBox.baseVal;return {ratio:box.width/box.height,screenRatio:rect.width/rect.height}})
expect(camera.ratio).toBeCloseTo(camera.screenRatio,3)
await page.getByRole("button",{name:"Увеличить карту",exact:true}).click()
const manual=await map.getAttribute("viewBox")
await page.getByRole("button",{name:"Обновить",exact:true}).click()
await expect(page.getByRole("button",{name:"Обновить",exact:true})).toBeEnabled();await expect(map).toHaveAttribute("viewBox",manual!)
await page.getByRole("button",{name:"Вписать карту",exact:true}).click()
expect(await map.getAttribute("viewBox")).not.toBe(manual)
await page.getByRole("combobox",{name:"Устройство на карте"}).selectOption("1")
const wan=page.getByRole("button",{name:"WAN WAN",exact:true});await wan.focus();await wan.press("Enter")
await expect(page).toHaveURL(/wan=0/);await expect(wan).toHaveAttribute("aria-pressed","true")
})