Skip to content

Conversation

mgascam
Copy link
Contributor

@mgascam mgascam commented Sep 16, 2025

Fixes #WOOPMNT-5336

Changes proposed in this Pull Request

This is a stacked PR that builds on top of the basic QIT E2E testing functionality to address the key challenge of establishing a Jetpack connection for WooPayments in test environments.

The previous foundation established basic E2E testing infrastructure, but lacked the ability to connect WooPayments to a real test account via Jetpack. This PR solves that by providing automated Jetpack connection setup for already onboarded test accounts.

Key features:

  1. WP-CLI QIT Development Commands: New WP_CLI_QIT_Dev_Command class providing:

    • wp woopayments qit_setup - Configures Jetpack connection for pre-onboarded test sites
    • wp woopayments qit_status - Shows connection status for debugging
    • Automatic test mode configuration and account data refresh from server
  2. Enhanced E2E Test Runner: Updated e2e-runner.sh with:

    • Plugin build caching based on source file signatures (avoids unnecessary rebuilds)
    • Jetpack credential passing via environment variables
  3. Connection Validation Tests:

    • Tests to verify WooPayments shows configuration options (not Connect screen)
    • Validation that account data is properly fetched from the server
  4. Configuration Management:

    • Added E2E Jetpack credential support in default.env template
    • Environment variable handling for site ID, blog token, and user token

Why This Approach:
The added WP-CLI commands are doing pretty much the same as the WCPay Dev Tools that we use for the current E2E tests. Initially I tried to use this dev plugin, but it turned out to be tricky to download and install it in the QIT environment. I came with this workaround inspired by the work @dmvrtx did in his draft #10811. But initializating a test drive account turned out to be tricky, so I went with the approach of using an already onboarded account. So, essentially, I'm following the same approach that we have in the current E2E tests, but adapted to the QIT needs. I'd love to hear any ideas for improving this part, but I guess the current approach could work for the time being. It's worth noting that the WP-CLI commands are only registered in development/local environments for security.

Testing instructions

Prerequisites:

  • QIT CLI installed and configured (ie. run composer install)
  • Access to a pre-onboarded WooPayments test account with Jetpack credentials. The following steps worked well for me:
    1. Spin a fresh JN site with WooCommerce, WooPayments and Jetpack Debug Tools
    2. Follow the minimum steps to onboard with a test account
    3. Go to Jetpack Debug > Broken Token to find the current tokens and blog ID
    4. Copy tests/qit/config/default.env to tests/qit/config/local.env
    5. Fill in E2E credentials from your onboarded test account:
E2E_JP_SITE_ID=your_site_id_here
E2E_JP_BLOG_TOKEN=your_blog_token_here
E2E_JP_USER_TOKEN=your_user_token_here

Running the tests:

  1. Run E2E tests: npm run test:qit-e2e
  2. Connection validation tests should pass

  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@mgascam mgascam changed the title [E2E] Connect account [E2E] Connect WooPayments account Sep 16, 2025
@mgascam mgascam changed the title [E2E] Connect WooPayments account [E2E] [QIT] Connect WooPayments account Sep 16, 2025
@mgascam mgascam force-pushed the dev/qit-e2e-foundation branch from 0b2290d to ebb5a08 Compare September 16, 2025 16:22
@mgascam mgascam force-pushed the dev/qit-e2e-basic-checkout branch 2 times, most recently from 0c4df2c to f187c98 Compare September 16, 2025 16:58
@mgascam mgascam force-pushed the dev/qit-e2e-foundation branch from 18924a5 to bd1afc7 Compare September 17, 2025 09:15
…nce setup functions, and add connection validation tests
@mgascam mgascam force-pushed the dev/qit-e2e-basic-checkout branch 2 times, most recently from 1475a9f to 307ef0f Compare September 17, 2025 10:13
@mgascam mgascam force-pushed the dev/qit-e2e-basic-checkout branch from 307ef0f to e3064e3 Compare September 17, 2025 10:15
@mgascam mgascam changed the title [E2E] [QIT] Connect WooPayments account [E2E] [QIT] Connect test site to WooPayments account Sep 17, 2025
@mgascam mgascam changed the title [E2E] [QIT] Connect test site to WooPayments account [E2E] [QIT] Add Jetpack connection support for QIT E2E tests Sep 18, 2025
@mgascam mgascam marked this pull request as ready for review September 18, 2025 08:51
@mgascam mgascam requested a review from a team September 18, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant