test(cypress): add offer engine payment coverage - #13897
Open
venkatakarthikm-maker wants to merge 12 commits into
Open
test(cypress): add offer engine payment coverage#13897venkatakarthikm-maker wants to merge 12 commits into
venkatakarthikm-maker wants to merge 12 commits into
Conversation
Changed Files
|
Renamed 57-OfferEngine.cy.js to 54-OfferEngine.cy.js and updated specSelection/config.js so it groups with the other 54-numbered Payment specs and runs ahead of 55-DynamicFields.cy.js.
Keep the 54-OfferEngine.cy.js entry in its original list position instead of reordering unrelated sibling entries.
CI's mandatory Cypress run boots a local router with no Offer Engine
microservice configured, so /payments/{id}/eligibility never returns
offer_details and the whole spec cascades into failures. Probe
POST /offer_engine/connectivity before running and skip the suite
when it isn't reachable/enabled, matching the pattern already used by
43-AuthenticationServiceEligibility.cy.js for environment-gated
features.
Extract the raw cy.request probe from 54-OfferEngine.cy.js into a checkOfferEngineConnectivity command, matching every other spec's convention of keeping HTTP calls in commands.js rather than inline.
…spec Extract the applied_offer retrieve check into a checkAppliedOfferOnRetrieve command and its expected values into Commons.js, so the spec has no inline cy.request calls left, consistent with every other Payment spec.
…convention Rename checkOfferEngineConnectivity -> offerEngineConnectivityCheck and checkAppliedOfferOnRetrieve -> appliedOfferRetrieveCheck to match the ...Check suffix used by paymentsEligibilityCheck/paymentsOfferEligibilityCheck/ healthCheck, and add the logRequestId call every other network-hitting command in this file makes.
… the spec Move offer_quote_id substitution out of 54-OfferEngine.cy.js and into confirmCallTest, following the mitUsingPMId pattern of resolving a prior step's dynamic value from globalState inside the command rather than building the request object in the spec. ConfirmWithOfferApplied now carries a static OFFER_QUOTE_ID_PLACEHOLDER in Commons.js that confirmCallTest swaps for globalState's offerQuoteId, so the spec's confirm test is a plain declarative call like every other spec.
logRequestId queues a cy.task, so returning a plain boolean from the same .then() callback trips Cypress's "mixing async and sync code" error, failing the before-all hook outright. Wrap the return value in cy.wrap(), matching the pattern every other command in this file uses after calling logRequestId.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13897 +/- ##
=======================================
Coverage ? 0
=======================================
Files ? 0
Lines ? 0
Branches ? 0
=======================================
Hits ? 0
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
Adds Cypress E2E coverage for the Offer Engine (M2) payments flow introduced in #13553:
54-OfferEngine.cy.js: eligibility -> confirm -> applied-offer flow, and a no-offer regression path.paymentsOfferEligibilityCheckcommand (commands.js) hittingPOST /payments/{payment_id}/eligibility, assertingamount_detailsand the fulloffer_details(uplifted_offer_quote_ids,eligible_offers[]) shape.offer_engineconfig block inCommons.jswith cases for intent creation, eligibility, offer-applied confirm, and no-offer confirm.confirmCallTest:offer_detailsset on the sharedconfirmBodyfixture by one test wasn't cleared for subsequent confirm calls (same class of bug already guarded forsplit_payments).specSelection/config.js, numbered54-OfferEngine.cy.jsto run alongside the other54-*Payment specs and ahead of55-DynamicFields.cy.js.Additional Changes
Motivation and Context
The Offer Engine flow (eligibility check, offer application at confirm,
applied_offeron the payment response) had no automated E2E coverage. This closes that gap.Closes #13898
How did you test it?
Ran
54-OfferEngine.cy.jsagainst a live Stripe test merchant with Offer Engine configured:amount_detailsandoffer_details.eligible_offers[]matching the configured offer.offer_details.offer_quote_idssucceeds, adjustsnet_amount/amount_receivedby the offer amount.applied_offer(offer id, amount, currency, offer engine merchant/txn ids).offer_detailsleavesapplied_offer: nullandnet_amountunchanged, confirming no state leaked from the prior offer-applying test.All 6 test cases in the spec passed.
Checklist
cargo +nightly fmt --allcargo clippy