import { chromium } from 'playwright';
const b = await chromium.launch({ executablePath:'/usr/bin/chromium-browser', args:['--no-sandbox'] });
const ctx = await b.newContext({ viewport:{ width:390, height:1000 }, deviceScaleFactor:2, serviceWorkers:'block' });
await ctx.addInitScript(()=>{localStorage.setItem('sz_theme','dark');localStorage.setItem('sz_accent','green');});
const p = await ctx.newPage();
await p.goto('https://poly-dev.szhub.space/', { waitUntil:'domcontentloaded', timeout:35000 });
await p.waitForTimeout(5500);
// switch to FADE
await p.click('.pk-ltoggle .pk-f', { timeout:6000 }).catch(()=>{});
await p.waitForTimeout(1000);
const av = await p.evaluate(()=>document.querySelector('.pk-cav')?.innerText);
const fadeTop = await p.evaluate(()=>{const c=document.querySelector('.pk-card');return c?.querySelector('.pk-cname')?.innerText+' WR '+c?.querySelector('.pk-wrv')?.innerText+' '+c?.querySelector('.pk-cstat b')?.innerText});
// click WIN-RATE sort tab — should re-rank instantly (worst WR first in fade)
const tabs = await p.$$('.pk-sort');
let clicked='';
for (const t of tabs){ const tx=await t.innerText(); if(/win/i.test(tx)){ await t.click(); clicked=tx; break; } }
await p.waitForTimeout(900);
const afterWr = await p.evaluate(()=>{const c=document.querySelector('.pk-card');return c?.querySelector('.pk-wrv')?.innerText});
await p.screenshot({ path:'_v3.png' });
console.log('avatar:', av, '| fade top:', fadeTop);
console.log('clicked tab:', clicked, '| top WR after win-rate sort:', afterWr, '(должен быть самый низкий)');
await b.close();