Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ACH E2E tests #3931

Merged
merged 37 commits into from
Feb 27, 2025
Merged

Add ACH E2E tests #3931

merged 37 commits into from
Feb 27, 2025

Conversation

rafaelzaleski
Copy link
Contributor

@rafaelzaleski rafaelzaleski commented Feb 22, 2025

Closes #3749

Changes proposed in this Pull Request:

This PR introduces E2E tests for ACH payments, covering the following scenarios:

  • Verifying the enabling and disabling of the ACH payment method in settings.
  • Testing payment processing using a non-saved payment method.
  • Testing payment processing using a saved payment method.

The tests are organized into two suites: one for Shortcode and another for Blocks checkout.

This PR also includes improvements to the E2E testing environment:

  • Fixes to the Docker Compose commands.
  • Skips webhook secret validation during E2E tests.
  • Adds the Stripe listener container to handle incoming webhooks in E2E environments that do not use a publicly accessible URL (e.g., CI and local environments).

Testing instructions

  1. Reset your E2E environment locally if it was previously set up.
  2. npm run test:e2e
  3. Verify that all tests pass successfully.

  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Changelog entry

  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Comment

Comment

Post merge

@rafaelzaleski rafaelzaleski self-assigned this Feb 22, 2025
@rafaelzaleski rafaelzaleski marked this pull request as ready for review February 25, 2025 14:45
@rafaelzaleski rafaelzaleski requested review from a team and ricardo and removed request for a team February 25, 2025 21:45
Comment on lines +37 to +41
if [ "$CI" = "true" ]; then
CWD="$CWD" E2E_ROOT="$E2E_ROOT" redirect_output docker compose -p wcstripe-e2e -f "$E2E_ROOT"/env/docker-compose.yml up --build --force-recreate -d
else
CWD="$CWD" E2E_ROOT="$E2E_ROOT" redirect_output docker compose -p wcstripe-e2e --env-file "$E2E_ROOT"/config/local.env -f "$E2E_ROOT"/env/docker-compose.yml up --build --force-recreate -d
fi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally, the environment variables are defined in "$E2E_ROOT"/config/local.env, but in CI they’re set in the workflow configuration. We need these variables to start the Stripe listener container.

Comment on lines +34 to +38
await admin.togglePaymentMethod(
browser,
'ACH Direct Debit',
true
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided not to disable ACH after the tests because another file (the shortcode tests) uses it. If one test disables the payment method in the middle of another test execution, it could cause issues. Since test environments aren’t intended to be reusable, this is acceptable.

@@ -20,6 +20,8 @@ setup( 'Disable legacy checkout experience', async ( { browser } ) => {
await expect(
page.getByTestId( 'legacy-checkout-experience-checkbox' )
).not.toBeChecked();

await adminContext.close();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you run the tests in headed mode, these pages never closed. This fixes that issue.

Copy link
Member

@ricardo ricardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. New tests passed. ✅

@rafaelzaleski All tests passed for me, except for customer can renew a subscription @smoke @subscriptions. Did you experience the same?

Apparently something changed in the Link flow and it now requires a "First and last name" input.

I know this isn't part of the scope of this PR, but I just wanted to check given the opportunity.

rafaelzaleski and others added 2 commits February 27, 2025 09:16
Co-authored-by: Ricardo Metring <ricardometring@gmail.com>
@rafaelzaleski
Copy link
Contributor Author

@ricardo, I noticed this test failing a few times while working on the ACH tests, but it's working for me now:

Screenshot 2025-02-27 at 09 34 01

Copy link
Member

@ricardo ricardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and tested well. All tests passed in my last run:

  ✓  1 [default-setup] › default.setup.js:7:6 › Disable legacy checkout experience (4.5s)
  ✓  2 [default-setup] › default.setup.js:27:6 › enable Link (4.5s)
  ✓  3 …rd-failures.spec.js:55:6 › customer cannot checkout with invalid cards @blocks › a card with insufficient funds shows the correct error message (15.2s)
  ✓  4 …locks/card-failures.spec.js:51:6 › customer cannot checkout with invalid cards @blocks › a declined card shows the correct error message @smoke (16.6s)
  ✓  5 …-failures.spec.js:67:6 › customer cannot checkout with invalid cards @blocks › a card with incorrect CVC shows the correct error message @smoke (17.4s)
  ✓  6 …ks/card-failures.spec.js:59:6 › customer cannot checkout with invalid cards @blocks › a card with invalid number shows the correct error message (5.2s)
  ✓  7 …ckout/blocks/card-failures.spec.js:63:6 › customer cannot checkout with invalid cards @blocks › an expired card shows the correct error message (16.1s)
  ✓  8 …card-failures.spec.js:71:6 › customer cannot checkout with invalid cards @blocks › an error processing the card shows the correct error message (13.2s)
  ✓  9 [default] › checkout/blocks/lpms/ach.spec.js:44:6 › ACH payment tests @blocks › customer can pay with ACH using valid bank details @smoke (25.3s)
  ✓  10 [default] › checkout/blocks/lpms/ach.spec.js:56:6 › ACH payment tests @blocks › customer can save and reuse ACH payment method @smoke (36.8s)
  ✓  11 [default] › checkout/blocks/normal-card.spec.js:12:5 › customer can checkout with a normal credit card @smoke @blocks (13.4s)
  ✓  12 [default] › checkout/blocks/saved-card.spec.js:30:5 › customer can checkout with a saved card @smoke @blocks (30.6s)
  ✓  13 [default] › checkout/blocks/sca-card.spec.js:12:5 › customer can checkout with a SCA card @smoke @blocks (21.6s)
  ✓  14 [default] › checkout/blocks/subscription-product.spec.js:32:5 › customer can purchase a subscription product @smoke @blocks @subscriptions (17.6s)
  ✓  15 …ut/shortcode/card-failures.spec.js:34:6 › customer cannot checkout with invalid cards › a declined card shows the correct error message @smoke (10.5s)
  ✓  16 …code/card-failures.spec.js:38:6 › customer cannot checkout with invalid cards › a card with insufficient funds shows the correct error message (10.4s)
  ✓  17 …shortcode/card-failures.spec.js:42:6 › customer cannot checkout with invalid cards › a card with invalid number shows the correct error message (4.9s)
  ✓  18 … checkout/shortcode/card-failures.spec.js:46:6 › customer cannot checkout with invalid cards › an expired card shows the correct error message (10.6s)
  ✓  19 …de/card-failures.spec.js:50:6 › customer cannot checkout with invalid cards › a card with incorrect CVC shows the correct error message @smoke (10.8s)
  ✓  20 …rtcode/card-failures.spec.js:54:6 › customer cannot checkout with invalid cards › an error processing the card shows the correct error message (10.7s)
  ✓  21 [default] › checkout/shortcode/lpms/ach.spec.js:44:6 › ACH payment tests @shortcode › customer can pay with ACH using valid bank details @smoke (23.7s)
  ✓  22 [default] › checkout/shortcode/lpms/ach.spec.js:56:6 › ACH payment tests @shortcode › customer can save and reuse ACH payment method @smoke (37.9s)
  ✓  23 [default] › checkout/shortcode/normal-card.spec.js:12:5 › customer can checkout with a normal credit card @smoke (12.2s)
  ✓  24 [default] › checkout/shortcode/saved-card.spec.js:30:5 › customer can checkout with a saved card @smoke (28.2s)
  ✓  25 [default] › checkout/shortcode/sca-card.spec.js:12:5 › customer can checkout with a SCA card @smoke (20.1s)
  ✓  26 [default] › checkout/shortcode/subscription-product.spec.js:32:5 › customer can purchase a subscription product @smoke @subscriptions (16.9s)
  ✓  27 [default] › express-checkout/express-checkout.spec.js:54:2 › customer can use Link express checkout › inside the product page (3.4s)
  ✓  28 [default] › orders/full-refund.spec.js:13:5 › merchant can issue a full refund @smoke (31.9s)
  ✓  29 [default] › express-checkout/express-checkout.spec.js:57:2 › customer can use Link express checkout › inside the cart page (classic) (4.1s)
  ✓  30 [default] › subscriptions/subscription-renewal.spec.js:47:5 › customer can renew a subscription @smoke @subscriptions (29.7s)
  ✓  31 [default] › express-checkout/express-checkout.spec.js:62:2 › customer can use Link express checkout › inside the checkout page (classic) (7.2s)
  ✓  32 [default] › express-checkout/express-checkout.spec.js:67:2 › customer can use Link express checkout › inside the cart page (block) (4.3s)
  ✓  33 [default] › express-checkout/express-checkout.spec.js:72:2 › customer can use Link express checkout › inside the checkout page (block) (5.9s)

======

- Trying to clear consumer token... Try:1
✔ Cleared up consumer token successfully.

======


  Slow test file: [default] › orders/full-refund.spec.js (31.9s)
  Slow test file: [default] › checkout/blocks/saved-card.spec.js (30.6s)
  Slow test file: [default] › subscriptions/subscription-renewal.spec.js (29.7s)
  Slow test file: [default] › checkout/shortcode/saved-card.spec.js (28.2s)
  Slow test file: [default] › express-checkout/express-checkout.spec.js (24.8s)
  Consider splitting slow test files to speed up parallel execution
  33 passed (2.7m)

@rafaelzaleski rafaelzaleski enabled auto-merge (squash) February 27, 2025 13:38
@rafaelzaleski rafaelzaleski merged commit ca52817 into develop Feb 27, 2025
40 checks passed
@rafaelzaleski rafaelzaleski deleted the e2e/3749-add-ach-tests branch February 27, 2025 14:00
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.

ACH: Add E2E Tests
2 participants