Skip to content

Commit 21a374f

Browse files
authored
fix: assign new blog to e2e tests (#10717)
1 parent 0c6e65e commit 21a374f

15 files changed

+139
-173
lines changed

.github/workflows/e2e-pull-request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ env:
2323
WCP_DEV_TOOLS_BRANCH: 'trunk'
2424
TRANSACT_PLATFORM_SERVER_REPO: ${{ secrets.TRANSACT_PLATFORM_SERVER_REPO }}
2525
WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }}
26-
E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }}
27-
E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }}
28-
E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }}
26+
E2E_JP_SITE_ID: ${{ secrets.E2E_JP_SITE_ID }}
27+
E2E_JP_BLOG_TOKEN: ${{ secrets.E2E_JP_BLOG_TOKEN }}
28+
E2E_JP_USER_TOKEN: ${{ secrets.E2E_JP_USER_TOKEN }}
2929
WC_E2E_SCREENSHOTS: 1
3030
E2E_SLACK_CHANNEL_ID: ${{ secrets.E2E_SLACK_CHANNEL_ID }}
3131
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}

.github/workflows/e2e-pw-pull-request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ env:
2323
WCP_DEV_TOOLS_BRANCH: 'trunk'
2424
TRANSACT_PLATFORM_SERVER_REPO: ${{ secrets.TRANSACT_PLATFORM_SERVER_REPO }}
2525
WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }}
26-
E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }}
27-
E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }}
28-
E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }}
26+
E2E_JP_SITE_ID: ${{ secrets.E2E_JP_SITE_ID }}
27+
E2E_JP_BLOG_TOKEN: ${{ secrets.E2E_JP_BLOG_TOKEN }}
28+
E2E_JP_USER_TOKEN: ${{ secrets.E2E_JP_USER_TOKEN }}
2929
WC_E2E_SCREENSHOTS: 1
3030
E2E_SLACK_CHANNEL_ID: ${{ secrets.E2E_SLACK_CHANNEL_ID }}
3131
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}

.github/workflows/e2e-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ env:
1515
WCP_DEV_TOOLS_BRANCH: 'trunk'
1616
TRANSACT_PLATFORM_SERVER_REPO: ${{ secrets.TRANSACT_PLATFORM_SERVER_REPO }}
1717
WC_SUBSCRIPTIONS_REPO: ${{ secrets.WC_SUBSCRIPTIONS_REPO }}
18-
E2E_BLOG_ID: ${{ secrets.E2E_BLOG_ID }}
19-
E2E_BLOG_TOKEN: ${{ secrets.E2E_BLOG_TOKEN }}
20-
E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }}
18+
E2E_JP_SITE_ID: ${{ secrets.E2E_JP_SITE_ID }}
19+
E2E_JP_BLOG_TOKEN: ${{ secrets.E2E_JP_BLOG_TOKEN }}
20+
E2E_JP_USER_TOKEN: ${{ secrets.E2E_JP_USER_TOKEN }}
2121
WC_E2E_SCREENSHOTS: 1
2222
E2E_SLACK_CHANNEL_ID: ${{ secrets.E2E_SLACK_CHANNEL_ID }}
2323
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}

changelog/fix-e2e-tests-new-blog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: dev
3+
Comment: fix: assign new blog to e2e tests
4+
5+

includes/class-wc-payment-gateway-wcpay.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3817,14 +3817,20 @@ public function create_and_confirm_setup_intent() {
38173817
*/
38183818
public function create_setup_intent_ajax() {
38193819
try {
3820-
$wc_add_payment_method_rate_limit_id = 'add_payment_method_' . get_current_user_id();
3821-
if ( ! check_ajax_referer( 'wcpay_create_setup_intent_nonce', false, false ) || WC_Rate_Limiter::retried_too_soon( $wc_add_payment_method_rate_limit_id ) ) {
3820+
if ( ! check_ajax_referer( 'wcpay_create_setup_intent_nonce', false, false ) ) {
38223821
throw new Add_Payment_Method_Exception(
38233822
__( "We're not able to add this payment method. Please refresh the page and try again.", 'woocommerce-payments' ),
38243823
'invalid_referrer'
38253824
);
38263825
}
38273826

3827+
if ( WC_Rate_Limiter::retried_too_soon( 'add_payment_method_' . get_current_user_id() ) ) {
3828+
throw new Add_Payment_Method_Exception(
3829+
__( 'You cannot add a new payment method so soon after the previous one. Please try again later.', 'woocommerce-payments' ),
3830+
'retried_too_soon'
3831+
);
3832+
}
3833+
38283834
$setup_intent = $this->create_and_confirm_setup_intent();
38293835
$setup_intent_output = [
38303836
'id' => $setup_intent->get_id(),

tests/e2e/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ Once you have the blog id & tokens, add the following env variables to your `loc
6666
# Set local server to false for using live server. Default: true.
6767
E2E_USE_LOCAL_SERVER=false
6868
69-
E2E_BLOG_TOKEN='<jetpack_blog_token>'
70-
E2E_USER_TOKEN='<jetpack_user_token>'
71-
E2E_BLOG_ID='<blog_id>'
69+
E2E_JP_BLOG_TOKEN='<jetpack_blog_token>'
70+
E2E_JP_USER_TOKEN='<jetpack_user_token>'
71+
E2E_JP_SITE_ID='<blog_id>'
7272
```
7373

7474
</p>

tests/e2e/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22
playwright:
33
# When updating the Playwright version in the image tag below, make sure to update the npm `@playwright/test` package.json version as well.
4-
image: mcr.microsoft.com/playwright:v1.50.1-jammy
4+
image: mcr.microsoft.com/playwright:v1.51.1-jammy
55
working_dir: /woopayments
66
volumes:
77
- $PWD:/woopayments

tests/e2e/env/setup.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ handle_permissions() {
3535
}
3636

3737
# Variables
38-
BLOG_ID=${E2E_BLOG_ID-111}
38+
BLOG_ID=${E2E_JP_SITE_ID-111}
3939
WC_GUEST_EMAIL=$(<"$USERS_CONFIG_JSON_PATH" jq -r '.users.guest.email')
4040
WC_CUSTOMER_EMAIL=$(<"$USERS_CONFIG_JSON_PATH" jq -r '.users.customer.email')
4141
WC_CUSTOMER_USERNAME=$(<"$USERS_CONFIG_JSON_PATH" jq -r '.users.customer.username')
@@ -261,10 +261,15 @@ if [[ "$IS_WORKAROUND_REQUIRED" = "1" ]]; then
261261

262262
# Ensuring that a "checkout-wcb" page exists, which is the one that will contain the "WooCommerce Blocks" checkout
263263
cli wp post create --from-post="$CHECKOUT_PAGE_ID" --post_type="page" --post_title="Checkout WCB" --post_status="publish" --post_name="checkout-wcb"
264+
CHECKOUT_WCB_PAGE_ID=$(cli_debug wp post url-to-id checkout-wcb)
264265

265266
# Update cart & checkout pages to use shortcode.
266267
cli wp post update "$CART_PAGE_ID" --post_content="$CART_SHORTCODE"
267268
cli wp post update "$CHECKOUT_PAGE_ID" --post_content="$CHECKOUT_SHORTCODE"
269+
270+
# making the checkout pages full width, so that the sidebar doesn't take too much room in the UI.
271+
cli wp post meta update "$CHECKOUT_PAGE_ID" _wp_page_template "template-fullwidth.php"
272+
cli wp post meta update "$CHECKOUT_WCB_PAGE_ID" _wp_page_template "template-fullwidth.php"
268273
fi
269274
# End - Workaround for > WC 8.3 compatibility by updating cart & checkout pages to use shortcode.
270275

@@ -326,7 +331,7 @@ if [[ "$E2E_USE_LOCAL_SERVER" != false ]]; then
326331
cli wp wcpay_dev refresh_account_data
327332
else
328333
echo "Setting Jetpack blog_id"
329-
cli wp wcpay_dev set_blog_id "$BLOG_ID" --blog_token="$E2E_BLOG_TOKEN" --user_token="$E2E_USER_TOKEN"
334+
cli wp wcpay_dev set_blog_id "$BLOG_ID" --blog_token="$E2E_JP_BLOG_TOKEN" --user_token="$E2E_JP_USER_TOKEN"
330335
fi
331336

332337
if [[ ! ${SKIP_WC_SUBSCRIPTIONS_TESTS} ]]; then

tests/e2e/reporters/slack-reporter.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,40 @@ import type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';
88
*/
99
import * as Slack from '../utils/slack';
1010

11+
function slugifyForFileName( input: string ): string {
12+
return input
13+
.toLowerCase()
14+
.replace( /[^\w\d-]+/g, '-' ) // Replace non-alphanumeric chars with dashes
15+
.replace( /-+/g, '-' ) // Collapse multiple dashes
16+
.replace( /^-|-$/g, '' ); // Trim leading/trailing dashes
17+
}
18+
1119
class SlackReporter implements Reporter {
1220
onTestEnd( test: TestCase, result: TestResult ) {
1321
// If the test has already failed, we don't want to send a duplicate message.
1422
if ( result.retry !== 0 ) {
1523
return;
1624
}
1725

18-
if ( test.outcome() === 'unexpected' ) {
19-
Slack.sendFailedTestMessageToSlack( test.title );
26+
if ( test.outcome() !== 'unexpected' ) {
27+
return;
28+
}
2029

21-
const screenshots = result.attachments.filter(
22-
( { name, path } ) => name === 'screenshot' && path
23-
);
30+
Slack.sendFailedTestMessageToSlack( test.titlePath().join( ' › ' ) );
2431

25-
if ( screenshots.length > 0 ) {
26-
const [ screenshot ] = screenshots;
27-
Slack.sendFailedTestScreenshotToSlack( screenshot.path );
32+
const screenshots = result.attachments.filter(
33+
( { name, path } ) => name === 'screenshot' && path
34+
);
35+
if ( screenshots.length > 0 ) {
36+
const [ screenshot ] = screenshots;
37+
if ( ! screenshot.path ) {
38+
return;
2839
}
40+
41+
Slack.sendFailedTestScreenshotToSlack(
42+
screenshot.path,
43+
slugifyForFileName( test.title )
44+
);
2945
}
3046
}
3147
}

tests/e2e/specs/wcpay/merchant/merchant-payment-gateways-confirmation.spec.ts

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)