"""Quick diagnostic: does the toggle still work after SPA navigation?""" from playwright.sync_api import expect from e2e.auth_helpers import login def test_toggle_after_spa_nav(browser, app_url, db_ready): """After SPA navigation, the hamburger toggle should still open the menu.""" page = browser.new_page(viewport={"width": 375, "height": 812}) try: login(page, app_url, next="/") # Wait for whoami to settle (admin) page.wait_for_function( "() => !document.querySelector('#nav-sources').hasAttribute('hidden')", timeout=10_000, ) # Open the menu page.click("#nav-toggle") expect(page.locator("#nav-toggle")).to_have_attribute("aria-expanded", "true") # Navigate to a different view via SPA page.click("#nav-sources") expect(page).to_have_url(app_url + "/sources.html", timeout=15_000) # Menu should be closed expect(page.locator("#nav-toggle")).to_have_attribute("aria-expanded", "false") # NOW try to open the menu again - THIS IS THE BUG CHECK page.click("#nav-toggle") try: expect(page.locator("#nav-toggle")).to_have_attribute( "aria-expanded", "true", timeout=3000 ) print("PASS: Toggle still works after SPA navigation") except Exception as e: print(f"FAIL: Toggle does NOT work after SPA navigation: {e}") finally: page.close()