← back to Nationalrealestate
livetest.cjs
34 lines
const { chromium, devices } = require('playwright');
(async () => {
const b = await chromium.launch();
const ctx = await b.newContext({ ...devices['iPhone 13'] });
const page = await ctx.newPage();
const errs=[]; page.on('pageerror',e=>errs.push(e.message.slice(0,90)));
page.on('console',m=>{if(m.type()==='error'&&!/502|404|Failed to load resource/.test(m.text()))errs.push('C:'+m.text().slice(0,80));});
const P=[];
const status = (await page.goto('https://corkwallcovering.com/',{waitUntil:'networkidle',timeout:30000})).status();
P.push(['page loads 200', status===200]);
await page.waitForTimeout(1200);
// 1 hero
const heroImg = await page.evaluate(()=>{const b=document.getElementById('heroBg');return b?getComputedStyle(b).backgroundImage:''});
P.push(['hero = room setting (hero-bg.jpg)', /hero-bg\.jpg/.test(heroImg)]);
P.push(['"Living Texture" heading gone', (await page.locator('text=Living Texture').count())===0]);
// 2 search scrolls results into view
await page.$eval('#searchInput', el=>el.scrollIntoView({block:'center'}));
await page.click('#searchInput'); await page.type('#searchInput','cork',{delay:110});
await page.waitForTimeout(1600);
const vp = await page.evaluate(()=>{const vh=innerHeight;const g=document.getElementById('grid').getBoundingClientRect();const c=document.querySelector('#grid .card, #grid a.card');return{gridTop:Math.round(g.top),vh,inView:c?c.getBoundingClientRect().top<vh&&c.getBoundingClientRect().top> -50:false, stat:(document.getElementById('statLine')||{}).textContent}});
P.push(['search results scroll INTO view', vp.inView]);
P.push(['search filtered (stat updated)', /matching "cork"/.test(vp.stat||'')]);
// 3 tap a result opens detail
let opened=false;
try{ await page.click('#grid .card, #grid a.card',{timeout:4000}); await page.waitForTimeout(500); await page.click('#grid .card.revealed, #grid a.card.revealed',{timeout:2000}).catch(()=>{}); await page.waitForTimeout(600); opened = await page.isVisible('#dwmDetails,.ns-modal.show,[id*=Detail]').catch(()=>false);}catch(e){}
P.push(['tap result opens detail (best-effort)', opened]);
console.log('STAT:', vp.stat, '| gridTop', vp.gridTop, '/ vh', vp.vh);
console.log('----- RESULTS -----');
P.forEach(([n,ok])=>console.log((ok?'✅':'❌'), n));
console.log('console/page errors:', errs.length?errs:'NONE');
await page.screenshot({path:'/tmp/live-search-test.png'});
await b.close();
})().catch(e=>{console.error('ERR',e.message);process.exit(1)});