fix(ui): улучшить доступность и мобильный вывод диагностики
This commit is contained in:
1 parent
440e10c646
commit
d28d7a2cdb
11 files changed
+149
-145
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import {test,expect} from "@playwright/test"
|
||||
for(const [name,width] of [["desktop",1440],["mobile",390],["narrow",320]] as const)test("Диагностика: адаптивность и длинный вывод "+name,async({page})=>{
|
||||
await page.setViewportSize({width,height:900});const device={id:1,name:"Очень длинное имя устройства диагностики для проверки мобильной кнопки",host:"192.0.2.1",country:"RU",enabled:true,status:null,type:"exit-node"}
|
||||
await page.route("**/health",r=>r.fulfill({json:{ok:true}}));await page.route("**/api/**",r=>{const p=new URL(r.request().url()).pathname;return r.fulfill({json:p==="/api/servers"?[device]:p==="/api/auth/config"?{required:false}:p.endsWith("/ros-src-address")?{host:"192.0.2.1",ipv4:"192.0.2.1"}:{tunnels:[]}})})
|
||||
const output=Array.from({length:1200},(_,i)=>"строка-"+i+" "+"x".repeat(160)).join("\n")
|
||||
await page.route("**/api/servers/1/probes/run",r=>r.fulfill({json:{output}}));await page.goto("/probes?server=1");await expect(page.getByRole("button",{name:"Запустить",exact:true})).toBeEnabled();await expect(page.getByRole("status").filter({hasText:"IPv4 для preview:"})).toBeVisible()
|
||||
await page.getByRole("button",{name:"DNS",exact:true}).click();await expect(page.getByRole("button",{name:"DNS",exact:true})).toHaveAttribute("aria-pressed","true");await page.getByRole("button",{name:"CNAME",exact:true}).click();await expect(page.getByRole("button",{name:"CNAME",exact:true})).toHaveAttribute("aria-pressed","true");await page.getByRole("button",{name:"Ping",exact:true}).click()
|
||||
expect(await page.evaluate(()=>document.documentElement.scrollWidth<=window.innerWidth)).toBe(true)
|
||||
if(width<768){const button=page.getByRole("button",{name:"Серверы",exact:true});const box=await button.boundingBox();expect(box&&box.x+box.width<=width).toBe(true);await button.click();await page.keyboard.press("Escape");await expect(button).toBeFocused()}
|
||||
await page.screenshot({path:"docs/ux-ui/screens/probes-ready-"+name+".png",fullPage:true})
|
||||
await page.getByRole("button",{name:"Запустить",exact:true}).click();const region=page.getByRole("region",{name:/^Вывод Ping/});await expect(region).toContainText("строка-1199");await expect(region).toContainText("Показаны последние 1000 строк");await expect(region).not.toContainText("строка-199 ");await region.scrollIntoViewIfNeeded();await region.focus()
|
||||
expect(await region.evaluate(el=>el.clientHeight>100&&el.scrollHeight>el.clientHeight&&el.scrollWidth<=el.clientWidth+1)).toBe(true);expect(await page.evaluate(()=>document.documentElement.scrollWidth<=window.innerWidth)).toBe(true)
|
||||
await page.screenshot({path:"docs/ux-ui/screens/probes-output-"+name+".png",fullPage:true})
|
||||
await page.getByRole("button",{name:/^Удалить результат/}).click();await expect(region).toHaveCount(0);await expect(page.getByRole("button",{name:"Запустить",exact:true})).toBeFocused()
|
||||
})
|
||||
test("Диагностика: недоступный clipboard сохраняет вывод и сообщает ошибку",async({page})=>{
|
||||
await page.route("**/health",r=>r.fulfill({json:{ok:true}}));await page.route("**/api/**",r=>r.fulfill({json:new URL(r.request().url()).pathname==="/api/servers"?[{id:1,name:"Тест",host:"192.0.2.1",enabled:true,status:null,type:"exit-node"}]:new URL(r.request().url()).pathname==="/api/auth/config"?{required:false}:{tunnels:[]}}))
|
||||
await page.addInitScript(()=>Object.defineProperty(navigator,"clipboard",{value:{writeText:()=>Promise.reject(new Error("permission denied"))},configurable:true}))
|
||||
await page.goto("/probes?server=1");await page.getByRole("button",{name:"Скопировать параметры диагностики"}).click();await expect(page.getByText(/Не удалось скопировать/)).toBeVisible();await expect(page.getByRole("textbox",{name:"Цель диагностики"})).toHaveValue("8.8.8.8")
|
||||
})
|
||||
Reference in new issue
Block a user