Skip to content

test(cypress): add offer engine payment coverage - #13897

Open
venkatakarthikm-maker wants to merge 12 commits into
mainfrom
offersauto
Open

test(cypress): add offer engine payment coverage#13897
venkatakarthikm-maker wants to merge 12 commits into
mainfrom
offersauto

Conversation

@venkatakarthikm-maker

@venkatakarthikm-maker venkatakarthikm-maker commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • CI/CD

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.
  • paymentsOfferEligibilityCheck command (commands.js) hitting POST /payments/{payment_id}/eligibility, asserting amount_details and the full offer_details (uplifted_offer_quote_ids, eligible_offers[]) shape.
  • offer_engine config block in Commons.js with cases for intent creation, eligibility, offer-applied confirm, and no-offer confirm.
  • Fixed a state-leak bug in confirmCallTest: offer_details set on the shared confirmBody fixture by one test wasn't cleared for subsequent confirm calls (same class of bug already guarded for split_payments).
  • Registered the new spec in specSelection/config.js, numbered 54-OfferEngine.cy.js to run alongside the other 54-* Payment specs and ahead of 55-DynamicFields.cy.js.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

The Offer Engine flow (eligibility check, offer application at confirm, applied_offer on the payment response) had no automated E2E coverage. This closes that gap.

Closes #13898

How did you test it?

Ran 54-OfferEngine.cy.js against a live Stripe test merchant with Offer Engine configured:

  • Eligibility check returns amount_details and offer_details.eligible_offers[] matching the configured offer.
  • Confirm with offer_details.offer_quote_ids succeeds, adjusts net_amount/amount_received by the offer amount.
  • Payment retrieve reflects applied_offer (offer id, amount, currency, offer engine merchant/txn ids).
  • Confirm without offer_details leaves applied_offer: null and net_amount unchanged, confirming no state leaked from the prior offer-applying test.

All 6 test cases in the spec passed.

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@venkatakarthikm-maker venkatakarthikm-maker self-assigned this Aug 28, 2026
@venkatakarthikm-maker
venkatakarthikm-maker requested a review from a team as a code owner August 28, 2026 08:03
@venkatakarthikm-maker venkatakarthikm-maker added the S-test-ready Status: This PR is ready for cypress-tests label Aug 28, 2026
@semanticdiff-com

semanticdiff-com Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  cypress-tests/cypress/e2e/configs/Payment/Commons.js  0% smaller
  cypress-tests/cypress/e2e/spec/Payment/54-OfferEngine.cy.js  0% smaller
  cypress-tests/cypress/support/commands.js  0% smaller
  cypress-tests/cypress/utils/specSelection/config.js  0% smaller

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.
@HS-QUALIBOT HS-QUALIBOT changed the title Adding cypress coverage for offers engine test(cypress): add offer engine payment coverage Aug 28, 2026
Keep the 54-OfferEngine.cy.js entry in its original list position
instead of reordering unrelated sibling entries.
@github-actions github-actions Bot removed the S-test-ready Status: This PR is ready for cypress-tests label Aug 28, 2026
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.
@venkatakarthikm-maker venkatakarthikm-maker added the S-test-ready Status: This PR is ready for cypress-tests label Aug 28, 2026
QA Automation Bot and others added 8 commits August 28, 2026 15:02
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.
@github-actions github-actions Bot removed the S-test-ready Status: This PR is ready for cypress-tests label Aug 28, 2026
@venkatakarthikm-maker venkatakarthikm-maker added the S-test-ready Status: This PR is ready for cypress-tests label Aug 28, 2026
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@2f48378). Learn more about missing BASE report.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-test-ready Status: This PR is ready for cypress-tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Cypress coverage for Offer Engine payments flow

1 participant