Files
Reklamator/tests/integration/test_landing_flow.py
T

58 lines
2.1 KiB
Python
Raw Normal View History

"""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()