Add description field to Product model

Issue: The landing page template supported displaying product descriptions,
but the Product model didn't load the description field from config.yaml files.

Changes:
- Added optional 'description' parameter to Product.__init__()
- Updated Product.to_dict() to include description (if present)
- Updated Product.from_dict() to load description from config
- Added test to verify descriptions are displayed on landing page

All 9 landing page tests passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-17 15:32:20 +02:00
co-authored by Claude
parent bbeacb0748
commit 13051200a6
2 changed files with 40 additions and 3 deletions
+31
View File
@@ -180,3 +180,34 @@ def test_landing_page_with_authenticated_user_renders_correctly(client, test_pro
# Should contain products (proving the page rendered successfully)
assert b'Apple Product' in response.data
assert b'Zebra Product' in response.data
@pytest.mark.contract
def test_landing_page_displays_product_descriptions(client, test_products):
"""Test that product descriptions from config.yaml are displayed on landing page
This test verifies that when a product has a description field in its config.yaml,
that description is properly loaded by the Product model and displayed on the landing page.
"""
response = client.get('/')
assert response.status_code == 200
# Zebra Product has a description in the fixture
assert b'Zebra Product' in response.data
assert b'A product for testing' in response.data
# Apple Product has no description - should not show any placeholder
assert b'Apple Product' in response.data
# No description text should appear for Apple Product
html = response.data.decode('utf-8')
# Verify Zebra description is present
assert 'A product for testing' in html
# Verify the description appears between the product name and the submit button
zebra_section_start = html.find('Zebra Product')
zebra_section_end = html.find('Submit Feedback', zebra_section_start)
zebra_section = html[zebra_section_start:zebra_section_end]
assert 'A product for testing' in zebra_section