const { chromium } = require('playwright'); (async () => { const browser = await chromium.launch({ executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', args: ['--no-sandbox'], }); const results = []; const check = (name, ok, detail) => { results.push({ name, ok, detail }); console.log(`${ok ? 'PASS' : 'FAIL'} ${name}${detail ? ' — ' + detail : ''}`); }; // ---- web-ui: region gate ---- { const page = await browser.newPage(); await page.goto('http://localhost:4174/', { waitUntil: 'networkidle', timeout: 60000 }).catch(() => {}); await page.waitForTimeout(4000); const body = await page.content(); const hasGate = /select.*region|choose.*region|delivery region/i.test(body); const hasMbnr = /Mahabubnagar/i.test(body); check('web-ui region gate renders', hasGate, `gate=${hasGate}`); check('web-ui lists Mahabubnagar', hasMbnr, `listed=${hasMbnr}`); await page.screenshot({ path: '/tmp/verify-webui-gate.png' }); // Try selecting the region if a matching button/option exists const clicked = await page.evaluate(() => { const els = Array.from(document.querySelectorAll('button, [role="option"], li, div')); const t = els.find((e) => /Mahabubnagar/i.test(e.textContent || '') && (e.textContent || '').length < 120); if (t) { t.click(); return true; } return false; }); if (clicked) { await page.waitForTimeout(5000); const after = await page.content(); check('web-ui region selectable, home loads after', !/select.*region/i.test(after) || /store|product|slot/i.test(after), `clicked=${clicked}`); await page.screenshot({ path: '/tmp/verify-webui-home.png' }); } else { check('web-ui region selectable, home loads after', false, 'no clickable region row found'); } await page.close(); } // ---- admin-web: login + customize bound tabs ---- { const page = await browser.newPage(); await page.goto('http://localhost:4175/login', { waitUntil: 'networkidle', timeout: 60000 }).catch(() => {}); await page.waitForTimeout(3000); await page.screenshot({ path: '/tmp/verify-admin-login.png' }); // Fill first text input + password input const inputs = await page.$$('input'); if (inputs.length >= 2) { await inputs[0].fill('uitest'); await inputs[inputs.length - 1].fill('test1234'); const btn = await page.$('button[type="submit"], button:has-text("Login"), button:has-text("Sign in")'); if (btn) await btn.click(); await page.waitForTimeout(4000); const authed = page.url(); check('admin-web staff login works', !/login/i.test(authed), `url=${authed}`); } else { check('admin-web staff login works', false, `found ${inputs.length} inputs`); } await page.goto('http://localhost:4175/dashboard/customize-app', { waitUntil: 'networkidle', timeout: 60000 }).catch(() => {}); await page.waitForTimeout(5000); const body = await page.content(); check('customize shows bound tabs', /Mbnr-1/i.test(body) && /Mbnr-2/i.test(body), 'Mbnr-1 & Mbnr-2'); check('customize marks effective bound', /effective/i.test(body), 'EFFECTIVE badge/copy'); check('customize loads bound settings', /delivery charge/i.test(body), 'settings rendered'); await page.screenshot({ path: '/tmp/verify-admin-customize.png', fullPage: true }); await page.close(); } await browser.close(); const failed = results.filter((r) => !r.ok); console.log(`\n${results.length - failed.length}/${results.length} checks passed`); process.exit(failed.length ? 1 : 0); })().catch((e) => { console.error('SCRIPT ERROR:', e.message); process.exit(2); });