exec(open('ui_test.py').read().split("with sync_playwright() as pw:")[0])
with sync_playwright() as pw:
    b = pw.chromium.launch()
    for label, (W, H, mob) in {'desktop': (1440, 900, False), 'phone': (390, 844, True)}.items():
        ctx = b.new_context(viewport={'width': W, 'height': H}, is_mobile=mob, has_touch=mob); p, errs = login(ctx)
        p.goto(BASE + '#/team'); p.wait_for_timeout(1200)
        ok(not p.query_selector('.sb-nav a[href="#/settings"]'), label + ': Settings is not in the main navigation')
        if mob: p.click('#burger'); p.wait_for_timeout(500)
        s = p.query_selector('.sb-foot .sb-settings'); ok(s is not None, label + ': Settings is at the bottom of the menu')
        s.click(); p.wait_for_timeout(1200)
        ok('#/settings' in p.url, label + ': it opens Settings', p.url)
        if mob: p.click('#burger'); p.wait_for_timeout(500)
        ok(p.query_selector('.sb-settings.on'), label + ': highlighted while in Settings')
        p.screenshot(path=f'/tmp/sl-{label}.png'); ok(not errs, label + ': no script errors', errs[:2])
        ctx.close()
    b.close()
print(f"{sum(R)} passed, {len(R)-sum(R)} failed")
