Implement product selection landing page (Feature 002)
Adds landing page at root URL (/) that displays all active products with links to feedback submission forms. This replaces the requirement for users to know direct product URLs. Changes: - Added Product.load_active() method to filter and sort active products alphabetically - Created landing route blueprint with error handling and structured logging - Registered landing blueprint in app factory, replacing old index route - Created landing page template with product list and empty state - Added comprehensive contract tests (6 tests) covering active products, filtering, sorting, XSS prevention - Added integration test for complete user flow from landing page to submission form All 7 tests pass. User Story 1 (P1 - MVP) complete. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
"""Integration test for complete landing page flow"""
|
||||
import pytest
|
||||
import os
|
||||
import yaml
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_product_for_flow(app):
|
||||
"""Create a test product for the integration flow"""
|
||||
with app.app_context():
|
||||
products_dir = os.path.join(app.config['DATA_DIR'], 'products')
|
||||
product_dir = os.path.join(products_dir, 'flow-test-product')
|
||||
os.makedirs(product_dir, exist_ok=True)
|
||||
|
||||
with open(os.path.join(product_dir, 'config.yaml'), 'w') as f:
|
||||
yaml.dump({
|
||||
'product_id': 'flow-test-product',
|
||||
'name': 'Flow Test Product',
|
||||
'submission_url_slug': 'flow-test-product',
|
||||
'owner_language': 'en',
|
||||
'assigned_owner_ids': [],
|
||||
'status': 'active',
|
||||
'description': 'Product for integration flow testing'
|
||||
}, f)
|
||||
|
||||
yield 'flow-test-product'
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_landing_to_submission_flow(client, test_product_for_flow):
|
||||
"""T008: Complete flow - landing page → click product → submission form
|
||||
|
||||
Test the entire user journey:
|
||||
1. User visits landing page
|
||||
2. User sees products listed
|
||||
3. User clicks on a product link
|
||||
4. User is redirected to submission form for that product
|
||||
"""
|
||||
# Step 1: Visit landing page
|
||||
response = client.get('/')
|
||||
assert response.status_code == 200
|
||||
|
||||
# Step 2: Verify product is listed
|
||||
assert b'Flow Test Product' in response.data
|
||||
assert b'flow-test-product' in response.data
|
||||
|
||||
# Step 3: Extract and verify product link
|
||||
html = response.data.decode('utf-8')
|
||||
assert '/submit/flow-test-product' in html, "Product link not found in landing page"
|
||||
|
||||
# Step 4: Click product link (navigate to submission form)
|
||||
submission_response = client.get('/submit/flow-test-product')
|
||||
|
||||
# Should reach submission form (not 404)
|
||||
assert submission_response.status_code == 200
|
||||
# Should be on submission form page (has form or product name)
|
||||
assert b'Flow Test Product' in submission_response.data or b'feedback' in submission_response.data.lower()
|
||||
Reference in New Issue
Block a user