Test Framework: Missing fixture dependency for popup_page in some tests

Resolved 💬 3 comments Opened Oct 15, 2025 by vishnujayvel Closed Jan 11, 2026

Issue Description

Some tests in the test suite use popup_page fixture without actually needing it, which could cause unnecessary overhead and potential failures.

Problem

Tests like test_progress_modal_appears_on_button_click accept popup_page as a parameter but only use it for initial API key configuration, then create their own amazon_page. This means:

  1. Extra overhead: popup_page fixture opens extension popup unnecessarily
  2. Potential race conditions: Two pages open simultaneously (popup + Amazon)
  3. Unclear dependencies: Not obvious why popup_page is needed

Affected Tests

In test_progress_modal_ui.py:

  • test_progress_modal_appears_on_button_click (line 130)
  • test_progress_modal_step_transitions (line 189)
  • test_progress_modal_shows_error_state (line 352)
  • test_progress_modal_persistence_during_workflow (line 493)

In test_latency_optimizations.py:

  • test_llm_cache_hit_on_duplicate_order
  • test_async_comment_does_not_block_success_message
  • test_end_to_end_latency_improvement

Current Pattern (Problematic)

def test_progress_modal_appears_on_button_click(browser_context: BrowserContext, popup_page: Page):
    # Configure API keys on popup
    configure_api_keys(popup_page, ...)
    
    # Then create a NEW page for Amazon
    amazon_page = browser_context.new_page()
    amazon_page.goto("https://www.amazon.com/...")
    
    # popup_page is now orphaned but still open

Proposed Solution

Option 1: Use Fixture Properly (Recommended)

Create a dedicated fixture that configures API keys and cleans up:

# In conftest.py
@pytest.fixture
def configured_extension(popup_page: Page):
    """Configure extension with API keys from environment"""
    api_keys = load_api_keys_from_env()
    configure_api_keys(popup_page, **api_keys)
    popup_page.close()  # Clean up after configuration
    yield

# In test file
def test_progress_modal_appears_on_button_click(browser_context: BrowserContext, configured_extension):
    # Extension is already configured, just use it
    amazon_page = browser_context.new_page()
    amazon_page.goto("https://www.amazon.com/...")

Option 2: Remove popup_page Dependency

Configure API keys via chrome.storage API directly:

def configure_extension_storage(browser_context: BrowserContext, **keys):
    """Configure extension via storage API without opening popup"""
    # Use browser_context.evaluate or service worker message
    pass

def test_progress_modal_appears_on_button_click(browser_context: BrowserContext):
    configure_extension_storage(browser_context, ...)
    amazon_page = browser_context.new_page()
    # ...

Option 3: Close popup_page After Use

def test_progress_modal_appears_on_button_click(browser_context: BrowserContext, popup_page: Page):
    configure_api_keys(popup_page, ...)
    popup_page.close()  # Explicitly close after configuration
    
    amazon_page = browser_context.new_page()
    # ...

Impact

Low-Medium Priority:

  • Tests currently work but inefficiently
  • Potential for intermittent failures
  • Cleanup overhead in test runs

Recommendation

Option 1 (dedicated fixture) is cleanest because:

  • ✅ Clear separation of concerns
  • ✅ Automatic cleanup
  • ✅ Reusable across tests
  • ✅ Works with environment variables (from #9554)

Related Issues

  • #9554 - Test Framework: E2E tests require hardcoded API keys
  • #9555 - Create dedicated test Splitwise group

Files to Modify

  • tests/v2/conftest.py (add configured_extension fixture)
  • tests/v2/test_progress_modal_ui.py (update 4 tests)
  • tests/v2/test_latency_optimizations.py (update 3 tests)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗