fix(ui): повысить контраст заполненных таблиц BGP и OSPF

This commit is contained in:
Denozordec committed 2026-10-14 01:05:45 +07:00
1 parent d91cc77cda
commit 8b60ab040a
16 files changed
+1291 -101

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import {test,expect} from '@playwright/test'
import axe from 'axe-core'
import {writeFileSync} from 'node:fs'
const states=['Established','Active','Idle','Connect','OpenSent','OpenConfirm','Unknown']
const server={id:1,name:'Own218 router',host:'192.0.2.1',enabled:true,country:'RU',status:null}
const host={serverId:1,serverName:server.name,serverSite:'',serverCountry:'RU'}
for(const theme of ['light','dark'])for(const width of [1440,320])for(const section of ['bgp','ospf'])test(`Routing contrast ${section} ${theme} ${width}`,async({page})=>{
test.setTimeout(90000);await page.setViewportSize({width,height:1000});await page.addInitScript(t=>localStorage.setItem('rl-theme',t),theme)
let writes=0;const sessions=states.map((state,index)=>({...host,id:'*'+(index+1),name:'own218-'+state,peerIp:'192.0.2.2',remoteAs:64513,localAs:64512,localId:'192.0.2.1',remoteId:'192.0.2.2',state,type:index===1?'iBGP':index===6?'Unknown':'eBGP',uptime:'1h',holdTime:90,keepalive:30,prefixesRx:12,prefixesTx:2,inputMessages:20,outputMessages:10,capabilities:[],lastError:null}))
const catalog={neighbors:[],interfaces:[],instances:[],bfdSessions:[],routes:['O','O IA','O E1','O E2','Unknown'].map((type,index)=>({...host,id:'r'+index,destination:'192.0.'+(index+2)+'.0/24',type,cost:10,nextHop:'192.0.2.2',via:'ether1',area:'backbone'})),failures:[]}
await page.route('**/health',r=>r.fulfill({json:{ok:true}}));await page.route('**/api/**',r=>{if(r.request().method()!=='GET')writes++;const p=new URL(r.request().url()).pathname;return r.fulfill({json:p==='/api/auth/config'?{required:false}:p==='/api/servers'?[server]:p==='/api/bgp/catalog'?{sessions,failures:[]}:p==='/api/ospf/catalog'?catalog:{}})})
await page.goto('/'+section);if(section==='ospf')await page.getByRole('button',{name:'Маршруты',exact:true}).click()
const rows=page.locator('tr[data-row-id]');await expect(rows).toHaveCount(section==='bgp'?7:5);await page.evaluate(()=>document.fonts.ready);await page.waitForTimeout(900);await page.addScriptTag({content:axe.source});const findings=[]
for(let index=0;index<await rows.count();index++)for(const cellIndex of section==='bgp'?[4,5,7]:[1]){const cell=rows.nth(index).locator('td').nth(cellIndex);await cell.scrollIntoViewIfNeeded();await cell.evaluate(el=>el.id='own218-audit');const result=await page.evaluate(async()=>(window as unknown as {axe:typeof axe}).axe.run({include:['#own218-audit']},{runOnly:{type:'rule',values:['color-contrast']}}));findings.push({row:index,cell:cellIndex,text:(await cell.innerText()).trim(),violations:result.violations.map(v=>({id:v.id,nodes:v.nodes.map(n=>({target:n.target,summary:n.failureSummary}))}))});await cell.evaluate(el=>el.removeAttribute('id'))}
writeFileSync(`tmp/routing218-${section}-${theme}-${width}.json`,JSON.stringify({date:'2026-10-14',section,theme,width,scope:'Explicitly scrolled BGP type/state/prefix RX and OSPF route type cells',findings},null,2))
if(process.env.MMAPP_A11Y_BASELINE!=='true')expect(findings.filter(f=>f.violations.length)).toEqual([]);expect(writes).toBe(0);expect(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1)).toBe(true)
})