Skip to content

Add Stripe Connect (Payment Elements) E2E suite#3271

Closed
shohan0120 wants to merge 1 commit into
developfrom
shohan0120
Closed

Add Stripe Connect (Payment Elements) E2E suite#3271
shohan0120 wants to merge 1 commit into
developfrom
shohan0120

Conversation

@shohan0120

@shohan0120 shohan0120 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Playwright E2E coverage for the Stripe Connect gateway revamp (Payment Elements + PaymentIntents/SetupIntents, separate charges & transfers, Block checkout, refunds, 3DS).

  • tests/e2e/stripe-connect/: admin pre-setup, vendor onboarding (+ DB-seeded connection), classic & block checkout, multi-vendor split with real Stripe transfer assertions, webhook-replay idempotency, refunds (full/partial/multi-vendor) + transfer reversals, 3DS/SCA.
  • utils/stripeApi.ts: Stripe test-API client for money-truth assertions (transfers/refunds/reversals).
  • utils/dbUtils.ts: seed/remove a Stripe-connected vendor, cart cleanup.
  • mu-plugins/dokan-stripe-connect-test-helpers.php: test-only REST route for Dokan API refunds.
  • utils/shard-durations.json: fold the new spec into the CI shard baseline.

Stripe test keys are read from env (gitignored locally / GitHub Actions secrets in CI); none are committed.

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

Related Pull Request(s)

  • Full PR Link

Closes

How to test the changes in this Pull Request:

  • Steps or issue link

Changelog entry

Title

Detailed Description of the pull request. What was previous behaviour
and what will be changed in this PR.

Before Changes

Describe the issue before changes with screenshots(s).

After Changes

Describe the issue after changes with screenshot(s).

Feature Video (optional)

Link of detailed video if this PR is for a feature.

PR Self Review Checklist:

  • Code is not following code style guidelines
  • Bad naming: make sure you would understand your code if you read it a few months from now.
  • KISS: Keep it simple, Sweetie (not stupid!).
  • DRY: Don't Repeat Yourself.
  • Code that is not readable: too many nested 'if's are a bad sign.
  • Performance issues
  • Complicated constructions that need refactoring or comments: code should almost always be self-explanatory.
  • Grammar errors.

FOR PR REVIEWER ONLY:

As a reviewer, your feedback should be focused on the idea, not the person. Seek to understand, be respectful, and focus on constructive dialog.

As a contributor, your responsibility is to learn from suggestions and iterate your pull request should it be needed based on feedback. Seek to collaborate and produce the best possible contribution to the greater whole.

  • Correct — Does the change do what it’s supposed to? ie: code 100% fulfilling the requirements?
  • Secure — Would a nefarious party find some way to exploit this change? ie: everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities?
  • Readable — Will your future self be able to understand this change months down the road?
  • Elegant — Does the change fit aesthetically within the overall style and architecture?

Summary by CodeRabbit

  • Tests
    • Added comprehensive end-to-end test coverage for Stripe Connect workflows, including payment processing, refunds, vendor transfers, and 3DS authentication verification.
    • Introduced test utilities for Stripe API assertions and database state management.

Playwright E2E coverage for the Stripe Connect gateway revamp
(Payment Elements + PaymentIntents/SetupIntents, separate charges &
transfers, Block checkout, refunds, 3DS).

- tests/e2e/stripe-connect/: admin pre-setup, vendor onboarding
  (+ DB-seeded connection), classic & block checkout, multi-vendor
  split with real Stripe transfer assertions, webhook-replay
  idempotency, refunds (full/partial/multi-vendor) + transfer
  reversals, 3DS/SCA.
- utils/stripeApi.ts: Stripe test-API client for money-truth
  assertions (transfers/refunds/reversals).
- utils/dbUtils.ts: seed/remove a Stripe-connected vendor, cart cleanup.
- mu-plugins/dokan-stripe-connect-test-helpers.php: test-only REST
  route for Dokan API refunds.
- utils/shard-durations.json: fold the new spec into the CI shard
  baseline.

Stripe test keys are read from env (gitignored locally / GitHub
Actions secrets in CI); none are committed.
@shohan0120 shohan0120 closed this Jun 16, 2026
@shohan0120 shohan0120 deleted the shohan0120 branch June 16, 2026 17:03
@shohan0120

Copy link
Copy Markdown
Contributor Author

Superseded by #3272. Branch renamed shohan0120tests/stripe-connect-e2e for a conventional name; renaming the head ref closed this PR. Same commit (a87a28ac6), same content.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0aeb2561-049c-4d02-aedc-1c4cf6ca7934

📥 Commits

Reviewing files that changed from the base of the PR and between 782cd09 and a87a28a.

📒 Files selected for processing (6)
  • tests/pw/mu-plugins/dokan-stripe-connect-test-helpers.php
  • tests/pw/tests/e2e/stripe-connect/stripeConnect.spec.ts
  • tests/pw/tests/e2e/stripe-connect/stripeConnectPage.ts
  • tests/pw/utils/dbUtils.ts
  • tests/pw/utils/shard-durations.json
  • tests/pw/utils/stripeApi.ts

📝 Walkthrough

Walkthrough

Adds a full Playwright E2E test suite for Dokan Stripe Connect. Introduces a PHP mu-plugin REST endpoint for test-triggered refunds, a Stripe REST API client utility, DB seed/teardown helpers, a StripeConnectPage page object, and a spec covering admin configuration, vendor onboarding, classic/block checkout, multi-vendor transfer correctness, webhook replay idempotency, refund/transfer-reversal flows, and 3DS/SCA settlement.

Changes

Stripe Connect E2E suite

Layer / File(s) Summary
Test support utilities: PHP refund endpoint, Stripe API client, DB helpers
tests/pw/mu-plugins/dokan-stripe-connect-test-helpers.php, tests/pw/utils/stripeApi.ts, tests/pw/utils/dbUtils.ts
Adds a manage_woocommerce-gated WordPress REST endpoint for creating full/partial Dokan refunds; a thin Stripe REST client (stripeApi) for fetching PaymentIntents, charges, transfers, and events; and three dbUtils methods to seed/clear Stripe-connected vendor user meta, cart data, and transients.
StripeConnectPage: constants, interface, selectors
tests/pw/tests/e2e/stripe-connect/stripeConnectPage.ts
Exports Stripe test card constants, Connect credential/account env-var bindings, the GatewayConfig interface, the StripeConnectPage class constructor, and all page-object selector maps and static billing data.
StripeConnectPage: admin module/gateway config and withdraw method
tests/pw/tests/e2e/stripe-connect/stripeConnectPage.ts
Implements idempotent module toggle, gateway credential fill/save/assert-persisted, 3DS field disabled assertion, gateway readiness notice check, and Withdraw Options toggle with persistence verification.
StripeConnectPage: vendor connect, payment element, classic/block checkout, 3DS
tests/pw/tests/e2e/stripe-connect/stripeConnectPage.ts
Adds vendor OAuth connect/disconnect UI assertions, cross-origin iframe polling and retry for Stripe Payment Element card entry, classic and block checkout order placement with success/error assertions, and a 3DS/SCA frame-polling completion routine.
Spec: helpers, admin pre-setup, vendor onboarding, DB-seeded connect state
tests/pw/tests/e2e/stripe-connect/stripeConnect.spec.ts
Defines spec-local helpers for refund triggering, Stripe order settlement polling, PaymentIntent/charge id resolution, and unsigned webhook posting; adds serial admin setup and vendor onboarding describe blocks.
Spec: classic and block checkout purchase/decline coverage
tests/pw/tests/e2e/stripe-connect/stripeConnect.spec.ts
Serial test suites for classic and block checkout asserting successful order placement and declined-card inline/block error with no-order confirmation.
Spec: real transfer correctness and webhook replay idempotency
tests/pw/tests/e2e/stripe-connect/stripeConnect.spec.ts
Places multi-vendor orders, polls Stripe API to assert exactly one transfer per vendor and validates transfer amounts; posts and replays unsigned payment_intent.succeeded events and asserts no duplicate transfers.
Spec: refund/transfer-reversal coverage, 3DS/SCA settlement, and shard config
tests/pw/tests/e2e/stripe-connect/stripeConnect.spec.ts, tests/pw/utils/shard-durations.json
Full/partial refund tests asserting charge refund and transfer reversal amounts, a missing-intent-meta edge case, a known-failure multi-vendor refund; 3DS/SCA tests asserting orders reach processing/completed state; shard-durations entry for the new spec.

Sequence Diagram(s)

sequenceDiagram
  rect rgba(100, 149, 237, 0.5)
    Note over Spec,Stripe: Checkout + Transfer Verification
  end
  participant Spec as stripeConnect.spec.ts
  participant StripeConnectPage as StripeConnectPage
  participant WooCommerce as WooCommerce / Dokan
  participant StripeAPI as stripeApi (api.stripe.com)

  Spec->>StripeConnectPage: placeOrderClassic(card, product)
  StripeConnectPage->>WooCommerce: POST /checkout, complete order
  WooCommerce-->>StripeConnectPage: order received URL
  StripeConnectPage-->>Spec: orderId

  Spec->>WooCommerce: GET order meta (_stripe_intent_id, _stripe_charge_id)
  WooCommerce-->>Spec: intentId, chargeId

  Spec->>StripeAPI: transfersForChargeToVendor(chargeId, vendorAccount)
  StripeAPI-->>Spec: transfers[] (assert count == 1)

  rect rgba(144, 238, 144, 0.5)
    Note over Spec,MuPlugin: Refund + Transfer Reversal
  end
  participant MuPlugin as PHP mu-plugin REST

  Spec->>MuPlugin: POST /dokan-test/v1/refund (order_id, amount?)
  MuPlugin-->>Spec: {ok, refund_amount}

  Spec->>StripeAPI: getCharge(chargeId)
  StripeAPI-->>Spec: charge.amount_refunded (assert match)
  Spec->>StripeAPI: getTransfer(transferId)
  StripeAPI-->>Spec: transfer.reversals.total_amount (assert match)
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • getdokan/dokan#3233: Modifies the same tests/pw/utils/shard-durations.json file to update Playwright CI sharding configuration, which this PR also extends with the new stripe-connect/stripeConnect.spec.ts shard entry.

Suggested labels

QA Automation

Suggested reviewers

  • MdAsifHossainNadim

Poem

🐇 Hops through iframes, one by one,
Finds the card field — tests begun!
Transfers verified, webhooks replayed,
Refunds reversed, no doubts displayed.
3DS challenged, orders complete —
This rabbit's E2E suite is neat! 🎉

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shohan0120

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant