feat: multi-module improvements across merchant, store, i18n, and customer systems
All checks were successful
CI / ruff (push) Successful in 12s
CI / pytest (push) Successful in 50m57s
CI / validate (push) Successful in 24s
CI / dependency-scanning (push) Successful in 29s
CI / docs (push) Successful in 40s
CI / deploy (push) Successful in 51s

- Fix platform-grouped merchant sidebar menu with core items at root level
- Add merchant store management (detail page, create store, team page)
- Fix store settings 500 error by removing dead stripe/API tab
- Move onboarding translations to module-owned locale files
- Fix onboarding banner i18n with server-side rendering + context inheritance
- Refactor login language selectors to use languageSelector() function (LANG-002)
- Move HTTPException handling to global exception handler in merchant routes (API-003)
- Add language selector to all login pages and portal headers
- Fix customer module: drop order stats from customer model, add to orders module
- Fix admin menu config visibility for super admin platform context
- Fix storefront auth and layout issues
- Add missing i18n translations for onboarding steps (en/fr/de/lb)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-08 23:48:25 +01:00
parent f141cc4e6a
commit a77a8a3a98
113 changed files with 3741 additions and 2923 deletions

View File

@@ -0,0 +1,84 @@
# tests/unit/models/test_customer_order_stats.py
"""Unit tests for CustomerOrderStats model."""
import pytest
from sqlalchemy.exc import IntegrityError
from app.modules.orders.models.customer_order_stats import CustomerOrderStats
@pytest.mark.unit
@pytest.mark.database
class TestCustomerOrderStatsModel:
"""Test CustomerOrderStats model."""
def test_create_stats(self, db, test_store, test_customer):
"""Test creating customer order stats."""
stats = CustomerOrderStats(
store_id=test_store.id,
customer_id=test_customer.id,
total_orders=3,
total_spent_cents=15000,
)
db.add(stats)
db.commit()
db.refresh(stats)
assert stats.id is not None
assert stats.store_id == test_store.id
assert stats.customer_id == test_customer.id
assert stats.total_orders == 3
assert stats.total_spent_cents == 15000
def test_default_values(self, db, test_store, test_customer):
"""Test default values for stats."""
stats = CustomerOrderStats(
store_id=test_store.id,
customer_id=test_customer.id,
)
db.add(stats)
db.commit()
db.refresh(stats)
assert stats.total_orders == 0
assert stats.total_spent_cents == 0
assert stats.last_order_date is None
assert stats.first_order_date is None
def test_unique_constraint(self, db, test_store, test_customer):
"""Test unique constraint on store_id + customer_id."""
stats1 = CustomerOrderStats(
store_id=test_store.id,
customer_id=test_customer.id,
total_orders=1,
)
db.add(stats1)
db.commit()
stats2 = CustomerOrderStats(
store_id=test_store.id,
customer_id=test_customer.id,
total_orders=2,
)
db.add(stats2)
with pytest.raises(IntegrityError):
db.commit()
def test_update_stats(self, db, test_store, test_customer):
"""Test updating existing stats."""
stats = CustomerOrderStats(
store_id=test_store.id,
customer_id=test_customer.id,
total_orders=1,
total_spent_cents=5000,
)
db.add(stats)
db.commit()
stats.total_orders = 2
stats.total_spent_cents = 12000
db.commit()
db.refresh(stats)
assert stats.total_orders == 2
assert stats.total_spent_cents == 12000