fix(tests): fix 7 pre-existing test failures
Some checks failed
Some checks failed
Menu tests (6): Tests expected merchant menu item id "loyalty-program" but the actual definition in loyalty/definition.py uses "program". Updated assertions to match the actual menu item IDs. Wallet test (1): test_enrollment_succeeds_without_wallet_config didn't mock the Google Wallet config, so is_configured returned True when GOOGLE_ISSUER_ID is set in .env. Added @patch to mock config as unconfigured. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -278,7 +278,7 @@ class TestMerchantMenuModuleGating:
|
||||
s for s in data["sections"] if s["id"] == platform_section_id
|
||||
)
|
||||
item_ids = {i["id"] for i in platform_section["items"]}
|
||||
assert "loyalty-program" in item_ids
|
||||
assert "program" in item_ids
|
||||
|
||||
def test_loyalty_hidden_when_module_not_enabled(
|
||||
self, client, db, menu_auth, menu_merchant, menu_subscription,
|
||||
@@ -304,7 +304,7 @@ class TestMerchantMenuModuleGating:
|
||||
s for s in data["sections"] if s["id"] == platform_section_id
|
||||
)
|
||||
overview = next(
|
||||
i for i in platform_section["items"] if i["id"] == "loyalty-program"
|
||||
i for i in platform_section["items"] if i["id"] == "program"
|
||||
)
|
||||
assert overview["url"] == "/merchants/loyalty/program"
|
||||
|
||||
@@ -498,7 +498,7 @@ class TestMerchantMenuMultiPlatform:
|
||||
s for s in data["sections"] if s["id"] == platform_a_section_id
|
||||
)
|
||||
item_ids = {i["id"] for i in pa_section["items"]}
|
||||
assert "loyalty-program" in item_ids
|
||||
assert "program" in item_ids
|
||||
# Core sections always present
|
||||
assert "main" in section_ids
|
||||
assert "billing" in section_ids
|
||||
|
||||
@@ -61,12 +61,12 @@ class TestMenuDiscoveryService:
|
||||
assert "profile" in item_ids
|
||||
|
||||
def test_merchant_loyalty_section_items(self):
|
||||
"""Loyalty section contains loyalty-program."""
|
||||
"""Loyalty section contains program."""
|
||||
menus = self.service.discover_all_menus()
|
||||
loyalty_sections = [s for s in menus[FrontendType.MERCHANT] if s.id == "loyalty"]
|
||||
assert len(loyalty_sections) == 1
|
||||
item_ids = [i.id for i in loyalty_sections[0].items]
|
||||
assert "loyalty-program" in item_ids
|
||||
assert "program" in item_ids
|
||||
|
||||
def test_get_all_menu_items_merchant(self):
|
||||
"""get_all_menu_items returns items for MERCHANT frontend type."""
|
||||
@@ -75,7 +75,7 @@ class TestMenuDiscoveryService:
|
||||
item_ids = {i.id for i in items}
|
||||
assert "dashboard" in item_ids
|
||||
assert "subscriptions" in item_ids
|
||||
assert "loyalty-program" in item_ids
|
||||
assert "program" in item_ids
|
||||
|
||||
def test_get_all_menu_item_ids_merchant(self):
|
||||
"""get_all_menu_item_ids returns IDs for MERCHANT frontend type."""
|
||||
@@ -85,7 +85,7 @@ class TestMenuDiscoveryService:
|
||||
assert "invoices" in item_ids
|
||||
assert "stores" in item_ids
|
||||
assert "profile" in item_ids
|
||||
assert "loyalty-program" in item_ids
|
||||
assert "program" in item_ids
|
||||
|
||||
def test_get_mandatory_item_ids_merchant(self):
|
||||
"""Mandatory items for MERCHANT include dashboard and subscriptions."""
|
||||
|
||||
@@ -360,10 +360,14 @@ class TestEnrollmentWalletCreation:
|
||||
google_wallet_service._http_client = None
|
||||
google_wallet_service._credentials = None
|
||||
|
||||
@patch("app.modules.loyalty.services.google_wallet_service.config")
|
||||
def test_enrollment_succeeds_without_wallet_config(
|
||||
self, db, wt_program, test_merchant, test_customer
|
||||
self, mock_config, db, wt_program, test_merchant, test_customer
|
||||
):
|
||||
"""Enrollment works even when Google Wallet is not configured."""
|
||||
mock_config.google_issuer_id = None
|
||||
mock_config.google_service_account_json = None
|
||||
|
||||
from app.modules.loyalty.services.card_service import card_service
|
||||
card = card_service.enroll_customer(db, test_customer.id, test_merchant.id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user