fix(tests): fix all 10 e2e test failures
- test_planner_calculate_htmx: click capex tab to reveal #tab-content (it starts display:none and only shows after tab switch) - test_planner_quote_sidebar_visible_wide: use browser.new_page() instead of page.context.new_page() (default contexts don't support new_page) - test_login/signup/quote_step1_loads: add .first to avoid strict mode violation from the feedback popover form - test_language_switcher_en_to_de: verify footer link href + navigate directly instead of click (avoids off-screen element timing issues) - test_landing_nav_no_overlap: filter display:none elements (zero-width bounding rect) so mobile-only nav div doesn't skew overlap check - test_quote_wizard_*: replace schema.sql (doesn't exist) with migrate() approach matching test_visual.py and test_e2e_flows.py; fix URL from /leads/quote to /en/leads/quote; use label click for display:none pill radios; add missing required fields for steps 6 (financing_status + decision_process) and 8 (services_needed); add contact_phone to step 9 All 1018 unit tests + 61 e2e tests now pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,8 @@ Run explicitly with:
|
||||
"""
|
||||
import asyncio
|
||||
import multiprocessing
|
||||
import sqlite3
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, patch
|
||||
@@ -16,6 +18,7 @@ from unittest.mock import AsyncMock, patch
|
||||
import pytest
|
||||
from padelnomics import core
|
||||
from padelnomics.app import create_app
|
||||
from padelnomics.migrations.migrate import migrate
|
||||
from playwright.sync_api import expect, sync_playwright
|
||||
|
||||
pytestmark = pytest.mark.visual
|
||||
@@ -29,17 +32,25 @@ def _run_server(ready_event):
|
||||
import aiosqlite
|
||||
|
||||
async def _serve():
|
||||
schema_path = (
|
||||
Path(__file__).parent.parent
|
||||
/ "src"
|
||||
/ "padelnomics"
|
||||
/ "migrations"
|
||||
/ "schema.sql"
|
||||
)
|
||||
# Build schema DDL by replaying migrations against a temp DB
|
||||
tmp_db = str(Path(tempfile.mkdtemp()) / "schema.db")
|
||||
migrate(tmp_db)
|
||||
tmp_conn = sqlite3.connect(tmp_db)
|
||||
rows = tmp_conn.execute(
|
||||
"SELECT sql FROM sqlite_master"
|
||||
" WHERE sql IS NOT NULL"
|
||||
" AND name NOT LIKE 'sqlite_%'"
|
||||
" AND name NOT LIKE '%_fts_%'"
|
||||
" AND name != '_migrations'"
|
||||
" ORDER BY rowid"
|
||||
).fetchall()
|
||||
tmp_conn.close()
|
||||
schema_ddl = ";\n".join(r[0] for r in rows) + ";"
|
||||
|
||||
conn = await aiosqlite.connect(":memory:")
|
||||
conn.row_factory = aiosqlite.Row
|
||||
await conn.execute("PRAGMA foreign_keys=ON")
|
||||
await conn.executescript(schema_path.read_text())
|
||||
await conn.executescript(schema_ddl)
|
||||
await conn.commit()
|
||||
core._db = conn
|
||||
|
||||
@@ -84,9 +95,14 @@ def page(browser):
|
||||
pg.close()
|
||||
|
||||
|
||||
def _check_radio(page, name, value):
|
||||
"""Click the label for a CSS-hidden radio/checkbox pill button."""
|
||||
page.locator(f"label:has(input[name='{name}'][value='{value}'])").click()
|
||||
|
||||
|
||||
def _fill_step_1(page):
|
||||
"""Fill step 1: facility type = indoor."""
|
||||
page.locator("input[name='facility_type'][value='indoor']").check()
|
||||
_check_radio(page, "facility_type", "indoor")
|
||||
|
||||
|
||||
def _fill_step_2(page):
|
||||
@@ -96,18 +112,30 @@ def _fill_step_2(page):
|
||||
|
||||
def _fill_step_5(page):
|
||||
"""Fill step 5: timeline = 3-6mo."""
|
||||
page.locator("input[name='timeline'][value='3-6mo']").check()
|
||||
_check_radio(page, "timeline", "3-6mo")
|
||||
|
||||
|
||||
def _fill_step_6(page):
|
||||
"""Fill step 6: financing status + decision process (both required)."""
|
||||
_check_radio(page, "financing_status", "self_funded")
|
||||
_check_radio(page, "decision_process", "solo")
|
||||
|
||||
|
||||
def _fill_step_7(page):
|
||||
"""Fill step 7: stakeholder type = entrepreneur."""
|
||||
page.locator("input[name='stakeholder_type'][value='entrepreneur']").check()
|
||||
_check_radio(page, "stakeholder_type", "entrepreneur")
|
||||
|
||||
|
||||
def _fill_step_8(page):
|
||||
"""Fill step 8: select at least one service (required, checkbox pill)."""
|
||||
_check_radio(page, "services_needed", "installation")
|
||||
|
||||
|
||||
def _fill_step_9(page):
|
||||
"""Fill step 9: contact details."""
|
||||
"""Fill step 9: contact details (name, email, phone, consent)."""
|
||||
page.fill("input[name='contact_name']", "Test User")
|
||||
page.fill("input[name='contact_email']", "test@example.com")
|
||||
page.fill("input[name='contact_phone']", "+49 123 456789")
|
||||
page.locator("input[name='consent']").check()
|
||||
|
||||
|
||||
@@ -125,7 +153,7 @@ def _click_back(page):
|
||||
|
||||
def test_quote_wizard_full_flow(live_server, page):
|
||||
"""Complete all 9 steps and submit — verify success page shown."""
|
||||
page.goto(f"{live_server}/leads/quote")
|
||||
page.goto(f"{live_server}/en/leads/quote")
|
||||
page.wait_for_load_state("networkidle")
|
||||
|
||||
# Step 1: Your Project
|
||||
@@ -151,8 +179,9 @@ def test_quote_wizard_full_flow(live_server, page):
|
||||
_fill_step_5(page)
|
||||
_click_next(page)
|
||||
|
||||
# Step 6: Financing (optional)
|
||||
# Step 6: Financing (has required fields)
|
||||
expect(page.locator("h2.q-step-title")).to_contain_text("Financing")
|
||||
_fill_step_6(page)
|
||||
_click_next(page)
|
||||
|
||||
# Step 7: About You
|
||||
@@ -160,8 +189,9 @@ def test_quote_wizard_full_flow(live_server, page):
|
||||
_fill_step_7(page)
|
||||
_click_next(page)
|
||||
|
||||
# Step 8: Services Needed (optional)
|
||||
# Step 8: Services Needed (at least one required)
|
||||
expect(page.locator("h2.q-step-title")).to_contain_text("Services Needed")
|
||||
_fill_step_8(page)
|
||||
_click_next(page)
|
||||
|
||||
# Step 9: Contact Details
|
||||
@@ -182,7 +212,7 @@ def test_quote_wizard_full_flow(live_server, page):
|
||||
|
||||
def test_quote_wizard_back_navigation(live_server, page):
|
||||
"""Go forward 3 steps, go back, verify data preserved in form fields."""
|
||||
page.goto(f"{live_server}/leads/quote")
|
||||
page.goto(f"{live_server}/en/leads/quote")
|
||||
page.wait_for_load_state("networkidle")
|
||||
|
||||
# Step 1: select Indoor
|
||||
@@ -194,8 +224,8 @@ def test_quote_wizard_back_navigation(live_server, page):
|
||||
page.fill("input[name='city']", "Berlin")
|
||||
_click_next(page)
|
||||
|
||||
# Step 3: select a build context
|
||||
page.locator("input[name='build_context'][value='new_standalone']").check()
|
||||
# Step 3: select a build context (radio is display:none, click label instead)
|
||||
_check_radio(page, "build_context", "new_standalone")
|
||||
_click_next(page)
|
||||
|
||||
# Step 4: now go back to step 3
|
||||
@@ -220,7 +250,7 @@ def test_quote_wizard_back_navigation(live_server, page):
|
||||
|
||||
def test_quote_wizard_validation_errors(live_server, page):
|
||||
"""Skip a required field on step 1 — verify error shown on same step."""
|
||||
page.goto(f"{live_server}/leads/quote")
|
||||
page.goto(f"{live_server}/en/leads/quote")
|
||||
page.wait_for_load_state("networkidle")
|
||||
|
||||
# Step 1: DON'T select facility_type, just click Next
|
||||
|
||||
Reference in New Issue
Block a user