Skip to content

Commit 4d5c30e

Browse files
authored
e2e: support using WC rc, timing issue fixes (#4550)
* Support using WooCommerce RC in e2e tests * Timing issue fixes for ACH, Klarna and Affirm * Add changelog and readme entries * Remove unnecessary clicks, wait to be visible only * Fix visibility check
1 parent 678c3ad commit 4d5c30e

File tree

4 files changed

+52
-15
lines changed

4 files changed

+52
-15
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* Dev - Minor CSS change to comply with a SASS rule deprecation
3434
* Dev - Update SCSS to replace @import with @use and @forward
3535
* Fix - Handle missing customer when calling payment_methods API
36+
* Dev - Fix some e2e issues: timing, optional flows, and WooCommerce RC support
3637

3738
= 9.7.1 - 2025-07-28 =
3839
* Add - Add state mapping for Lithuania in express checkout

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
142142
* Dev - Minor CSS change to comply with a SASS rule deprecation
143143
* Dev - Update SCSS to replace @import with @use and @forward
144144
* Fix - Handle missing customer when calling payment_methods API
145+
* Dev - Fix some e2e issues: timing, optional flows, and WooCommerce RC support
145146

146147
[See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

tests/e2e/bin/setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ if [[ -n "$WC_VERSION" && $WC_VERSION != 'latest' ]]; then
9090
if [[ $WC_VERSION == 'beta' ]]; then
9191
WC_VERSION=$(curl https://api.wordpress.org/plugins/info/1.0/woocommerce.json | jq -r '.versions | with_entries(select(.key|match("beta";"i"))) | keys[-1]' --sort-keys)
9292
fi
93+
94+
if [[ $WC_VERSION == 'rc' ]]; then
95+
WC_VERSION=$(curl https://api.wordpress.org/plugins/info/1.0/woocommerce.json | jq -r '.versions | with_entries(select(.key|match("rc";"i"))) | keys[0]' --sort-keys)
96+
fi
97+
9398
step "Installing WooCommerce ${WC_VERSION}"
9499
redirect_output cli wp plugin install woocommerce --version="$WC_VERSION" --activate
95100
else

tests/e2e/utils/payments.js

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,24 @@ export const fillACHBankDetails = async ( page ) => {
476476
// Click "Connect Account" button.
477477
await frame.getByTestId( 'select-button' ).click();
478478

479-
// Skip link registration
480-
await frame.getByTestId( 'link-not-now-button' ).click();
479+
// Link registration button may or may not appear.
480+
await Promise.race( [
481+
frame
482+
.getByTestId( 'link-not-now-button' )
483+
.waitFor( {
484+
state: 'visible',
485+
timeout: 5000,
486+
} )
487+
.then( async () => {
488+
await frame.getByTestId( 'link-not-now-button' ).click();
489+
} ),
490+
491+
frame.getByTestId( 'done-button' ).waitFor( {
492+
state: 'visible',
493+
timeout: 5000,
494+
} ),
495+
] );
481496

482-
// Click "Done" button.
483497
await frame.getByTestId( 'done-button' ).click();
484498
};
485499

@@ -905,16 +919,24 @@ export const setupAffirmCheckout = async ( page, checkoutType = 'blocks' ) => {
905919
const affirmLabel = page.locator( 'label', { hasText: 'Affirm' } );
906920
await affirmLabel.waitFor( { state: 'visible' } );
907921
await affirmLabel.click();
908-
await page.waitForSelector(
909-
'#radio-control-wc-payment-method-options-stripe_affirm__content'
910-
);
922+
await expect(
923+
page
924+
.frameLocator(
925+
'#radio-control-wc-payment-method-options-stripe_affirm__content iframe[name^="__privateStripeFrame"]'
926+
)
927+
.getByTestId( 'next-action-text' )
928+
).toBeVisible();
911929
} else {
912930
const affirmLabel = page.getByText( 'Affirm' );
913931
await affirmLabel.waitFor( { state: 'visible' } );
914932
await affirmLabel.click();
915-
await page.waitForSelector(
916-
'.payment_method_stripe_affirm iframe[src*="elements-inner-payment"]'
917-
);
933+
await expect(
934+
page
935+
.frameLocator(
936+
'.payment_method_stripe_affirm iframe[src*="elements-inner-payment"]'
937+
)
938+
.getByTestId( 'next-action-text' )
939+
).toBeVisible();
918940
}
919941
};
920942

@@ -943,15 +965,23 @@ export const setupKlarnaCheckout = async ( page, checkoutType = 'blocks' ) => {
943965
const klarnaLabel = page.locator( 'label', { hasText: 'Klarna' } );
944966
await klarnaLabel.waitFor( { state: 'visible' } );
945967
await klarnaLabel.click();
946-
await page.waitForSelector(
947-
'#radio-control-wc-payment-method-options-stripe_klarna__content'
948-
);
968+
await expect(
969+
page
970+
.frameLocator(
971+
'#radio-control-wc-payment-method-options-stripe_klarna__content iframe[name^="__privateStripeFrame"]'
972+
)
973+
.getByTestId( 'next-action-text' )
974+
).toBeVisible();
949975
} else {
950976
const klarnaLabel = page.getByText( 'Klarna' );
951977
await klarnaLabel.waitFor( { state: 'visible' } );
952978
await klarnaLabel.click();
953-
await page.waitForSelector(
954-
'.payment_method_stripe_klarna iframe[src*="elements-inner-payment"]'
955-
);
979+
await expect(
980+
page
981+
.frameLocator(
982+
'.payment_method_stripe_klarna iframe[src*="elements-inner-payment"]'
983+
)
984+
.getByTestId( 'next-action-text' )
985+
).toBeVisible();
956986
}
957987
};

0 commit comments

Comments
 (0)