Conversation
AI Generated. Add a certificate reference to the commerce order factory so that order creation in e2e tests no longer fails with a 400 when the upstream API requires a certificate during agreement setup. Promote the certificate_id fixture from tests/e2e/program/certificate/conftest.py to the shared tests/e2e/conftest.py so the order factory can consume it outside the program.certificate scope.
📝 WalkthroughWalkthroughThe pull request relocates the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment |
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/e2e/conftest.py (1)
184-186: Align fixture scope with other config-backed IDs.
certificate_id(Line 184) is derived from session-levele2e_config, like the other*_idfixtures in this file. Consider making it session-scoped for consistent lifecycle and slightly less fixture churn.Suggested diff
-@pytest.fixture +@pytest.fixture(scope="session") def certificate_id(e2e_config): return e2e_config["program.certificate.id"]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/e2e/conftest.py` around lines 184 - 186, The certificate_id fixture is created from the session-level e2e_config but currently has default (function) scope; change the pytest fixture declaration for certificate_id to use session scope so its lifecycle matches other config-backed *_id fixtures—update the decorator on certificate_id (the pytest.fixture for certificate_id that returns e2e_config["program.certificate.id"]) to include scope="session".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/e2e/conftest.py`:
- Around line 184-186: The certificate_id fixture is created from the
session-level e2e_config but currently has default (function) scope; change the
pytest fixture declaration for certificate_id to use session scope so its
lifecycle matches other config-backed *_id fixtures—update the decorator on
certificate_id (the pytest.fixture for certificate_id that returns
e2e_config["program.certificate.id"]) to include scope="session".
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: e4466201-8f0e-439a-9025-b6be718783f8
📒 Files selected for processing (3)
tests/e2e/commerce/order/conftest.pytests/e2e/conftest.pytests/e2e/program/certificate/conftest.py
💤 Files with no reviewable changes (1)
- tests/e2e/program/certificate/conftest.py



🤖 AI-generated PR — Please review carefully.
Summary
Fixes the flaky commerce order e2e tests that were failing during setup with
400 Cannot update agreement on setup. The upstream API now requires acertificatesreference on the agreement when an order is created, so the order factory was producing an invalid payload.Changes
tests/e2e/commerce/order/conftest.py— addcertificate_idto theorder_factorysignature and include"certificates": [{"id": certificate_id}]in the order payload.tests/e2e/conftest.py— promote thecertificate_idfixture to the shared e2e conftest so it is available to fixtures outside theprogram.certificatescope.tests/e2e/program/certificate/conftest.py— remove the now-redundant localcertificate_idfixture.Testing
Jira
MPT-20694
Closes MPT-20694
Changes
order_factoryfixture to accept acertificate_idparameter and include acertificatesfield in the constructed order payloadcertificate_idfixture fromtests/e2e/program/certificate/conftest.pytotests/e2e/conftest.pyto make it available across all e2e test scopescertificate_idfixture fromtests/e2e/program/certificate/conftest.pyafter moving it to the shared e2e configurationImpact
Resolves flaky commerce order e2e test setup failures by ensuring orders include the required certificate reference in the payload as mandated by the upstream API.