Skip to content

Commit 71357a5

Browse files
authored
Fix e2e tests and rename SPE to OC (#4287)
* Fix e2e tests and rename SPE to OC
1 parent be1426b commit 71357a5

File tree

10 files changed

+79
-70
lines changed

10 files changed

+79
-70
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
max-parallel: 10
1616
matrix:
17-
checkout: [ 'Default', 'Legacy', 'SPE' ]
17+
checkout: [ 'Default', 'Legacy', 'OptimizedCheckout' ]
1818

1919
name: ${{ matrix.checkout }} WP=latest, WC=latest, PHP=7.4
2020
steps:
@@ -88,8 +88,8 @@ jobs:
8888
run: |
8989
if [ "${{ matrix.checkout }}" = "Legacy" ]; then
9090
npm run test:e2e-legacy
91-
elif [ "${{ matrix.checkout }}" = "SPE" ]; then
92-
npm run test:e2e-spe
91+
elif [ "${{ matrix.checkout }}" = "OptimizedCheckout" ]; then
92+
npm run test:e2e-oc
9393
else
9494
npm run test:e2e
9595
fi

.github/workflows/run-e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121
max-parallel: 10
2222
matrix:
23-
project: [ 'default', 'legacy', 'acss', 'spe' ]
23+
project: [ 'default', 'legacy', 'acss', 'optimized-checkout' ]
2424

2525
name: E2E - ${{ matrix.project }} (WP=${{ inputs.wp-version }}, WC=${{ inputs.wc-version }}, PHP=${{ inputs.php-version }})
2626
steps:

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@
163163
"test:e2e-legacy-debug": "npm run test:e2e-legacy -- --debug",
164164
"test:e2e-lpm-acss": "./tests/e2e/bin/run-tests.sh --project=acss",
165165
"test:e2e-lpm-acss-debug": "npm run test:e2e-lpm-acss -- --debug",
166-
"test:e2e-spe": "./tests/e2e/bin/run-tests.sh --project=spe",
167-
"test:e2e-spe-debug": "npm run test:e2e-spe -- --debug",
166+
"test:e2e-oc": "./tests/e2e/bin/run-tests.sh --project=optimized-checkout",
167+
"test:e2e-oc-debug": "npm run test:e2e-oc -- --debug",
168168
"changelog": "node bin/changelog.js"
169169
},
170170
"engines": {

tests/e2e/bin/setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ redirect_output cli wp option update _wcstripe_feature_lpm_ach 'yes'
143143
echo " - Enabling the ACSS feature flag"
144144
redirect_output cli wp option update _wcstripe_feature_lpm_acss 'yes'
145145

146-
echo " - Enabling the SPE feature flag"
147-
redirect_output cli wp option update _wcstripe_feature_spe 'yes'
146+
echo " - Enabling the Optimized Checkout feature flag"
147+
redirect_output cli wp option update _wcstripe_feature_oc 'yes'
148148

149149
step "Installing Woo Subscriptions"
150150
echo " - Fetching latest version"

tests/e2e/config/playwright.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const config = {
8383
testIgnore: [
8484
'**/_legacy-experience/**',
8585
'**/acss.spec.js',
86-
'**/spe.spec.js',
86+
'**/optimized-checkout.spec.js',
8787
],
8888
dependencies: [ 'default-setup' ],
8989
use: { ...devices[ 'Desktop Chrome' ] },
@@ -111,14 +111,14 @@ const config = {
111111
use: { ...devices[ 'Desktop Chrome' ] },
112112
},
113113
{
114-
name: 'spe-setup',
115-
testMatch: '/spe.setup.js',
114+
name: 'oc-setup',
115+
testMatch: '/optimized-checkout.setup.js',
116116
use: { ...devices[ 'Desktop Chrome' ] },
117117
},
118118
{
119-
name: 'spe',
120-
testMatch: '**/spe.spec.js',
121-
dependencies: [ 'spe-setup' ],
119+
name: 'optimized-checkout',
120+
testMatch: '**/optimized-checkout.spec.js',
121+
dependencies: [ 'oc-setup' ],
122122
use: { ...devices[ 'Desktop Chrome' ] },
123123
},
124124
],

tests/e2e/tests/checkout/blocks/spe.spec.js renamed to tests/e2e/tests/checkout/blocks/optimized-checkout.spec.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { payments, api, user } from '../../../utils';
66
const {
77
emptyCart,
88
setupCart,
9+
setupOptimizedCheckout,
910
setupBlocksCheckout,
10-
setupSPECheckout,
11-
fillSPEDetails,
11+
fillOCDetails,
1212
clickPlaceOrder,
1313
} = payments;
1414

15-
test.describe( 'SPE payment tests @blocks', () => {
15+
test.describe( 'Optimized Checkout payment tests @blocks', () => {
1616
let username, userEmail;
1717

1818
test.describe.configure( { mode: 'serial' } );
@@ -36,17 +36,19 @@ test.describe( 'SPE payment tests @blocks', () => {
3636
} );
3737
} );
3838

39-
test( 'customer can pay with SPE @smoke', async ( { page } ) => {
40-
await setupSPECheckout( page, 'blocks' );
41-
await fillSPEDetails( page, config.get( 'cards.basic' ) );
39+
test( 'customer can pay with Optimized Checkout @smoke', async ( {
40+
page,
41+
} ) => {
42+
await setupOptimizedCheckout( page, 'blocks' );
43+
await fillOCDetails( page, config.get( 'cards.basic' ) );
4244
await clickPlaceOrder( page );
4345
await page.waitForURL( '**/checkout/order-received/**' );
4446
await expect( page.locator( 'h1.entry-title' ) ).toHaveText(
4547
'Order received'
4648
);
4749
} );
4850

49-
test( 'customer can save and reuse SPE payment method @smoke', async ( {
51+
test( 'customer can save and reuse Optimized Checkout payment method @smoke', async ( {
5052
page,
5153
} ) => {
5254
// First order - Save the payment method.
@@ -58,9 +60,9 @@ test.describe( 'SPE payment tests @blocks', () => {
5860
username,
5961
config.get( 'users.customer.password' )
6062
);
61-
await setupSPECheckout( page, 'blocks' );
63+
await setupOptimizedCheckout( page, 'blocks' );
6264
await page.getByLabel( 'Save payment information' ).click();
63-
await fillSPEDetails( page, config.get( 'cards.basic' ) );
65+
await fillOCDetails( page, config.get( 'cards.basic' ) );
6466
await clickPlaceOrder( page );
6567
await page.waitForURL( '**/checkout/order-received/**' );
6668
await expect( page.locator( 'h1.entry-title' ) ).toHaveText(

tests/e2e/tests/checkout/shortcode/spe.spec.js renamed to tests/e2e/tests/checkout/shortcode/optimized-checkout.spec.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ const {
77
emptyCart,
88
setupCart,
99
setupShortcodeCheckout,
10-
setupSPECheckout,
11-
fillSPEDetails,
10+
setupOptimizedCheckout,
11+
fillOCDetails,
1212
clickPlaceOrder,
1313
} = payments;
1414

15-
test.describe( 'SPE payment tests @shortcode', () => {
15+
test.describe( 'Optimized Checkout payment tests @shortcode', () => {
1616
let username, userEmail;
1717

1818
test.describe.configure( { mode: 'serial' } );
@@ -36,17 +36,19 @@ test.describe( 'SPE payment tests @shortcode', () => {
3636
} );
3737
} );
3838

39-
test( 'customer can pay with SPE @smoke', async ( { page } ) => {
40-
await setupSPECheckout( page, 'shortcode' );
41-
await fillSPEDetails( page, config.get( 'cards.basic' ), 'shortcode' );
39+
test( 'customer can pay with Optimized Checkout @smoke', async ( {
40+
page,
41+
} ) => {
42+
await setupOptimizedCheckout( page, 'shortcode' );
43+
await fillOCDetails( page, config.get( 'cards.basic' ), 'shortcode' );
4244
await clickPlaceOrder( page );
4345
await page.waitForURL( '**/checkout/order-received/**' );
4446
await expect( page.locator( 'h1.entry-title' ) ).toHaveText(
4547
'Order received'
4648
);
4749
} );
4850

49-
test( 'customer can save and reuse SPE payment method @smoke', async ( {
51+
test( 'customer can save and reuse Optimized Checkout payment method @smoke', async ( {
5052
page,
5153
} ) => {
5254
// First order - Save the payment method.
@@ -58,8 +60,8 @@ test.describe( 'SPE payment tests @shortcode', () => {
5860
username,
5961
config.get( 'users.customer.password' )
6062
);
61-
await setupSPECheckout( page, 'shortcode' );
62-
await fillSPEDetails(
63+
await setupOptimizedCheckout( page, 'shortcode' );
64+
await fillOCDetails(
6365
page,
6466
config.get( 'cards.basic' ),
6567
'shortcode'
@@ -70,7 +72,7 @@ test.describe( 'SPE payment tests @shortcode', () => {
7072
} )
7173
.check( { force: true } );
7274
await clickPlaceOrder( page );
73-
await fillSPEDetails(
75+
await fillOCDetails(
7476
page,
7577
config.get( 'cards.basic' ),
7678
'shortcode'
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { test as setup, expect } from '@playwright/test';
2+
3+
setup(
4+
'Configure store for Optimized Checkout tests',
5+
async ( { browser } ) => {
6+
const adminContext = await browser.newContext( {
7+
storageState: process.env.ADMINSTATE,
8+
} );
9+
10+
const page = await adminContext.newPage();
11+
12+
// Enable SPE in the admin.
13+
await page.goto(
14+
'/wp-admin/admin.php?page=wc-settings&tab=checkout&section=stripe&panel=settings'
15+
);
16+
17+
const checkbox = page.getByTestId( 'single-payment-element-checkbox' );
18+
const isChecked = await checkbox.isChecked();
19+
20+
if ( ! isChecked ) {
21+
await checkbox.click();
22+
await page.click( 'text=Save changes' );
23+
await expect(
24+
page.locator(
25+
'.components-snackbar__content:has-text("Settings saved.")'
26+
)
27+
).toBeVisible();
28+
await expect(
29+
page.getByTestId( 'single-payment-element-checkbox' )
30+
).toBeChecked();
31+
}
32+
33+
await adminContext.close();
34+
}
35+
);

tests/e2e/tests/spe.setup.js

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

tests/e2e/utils/payments.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ export const setupACSSCheckout = async ( page, checkoutType = 'blocks' ) => {
528528
};
529529

530530
/**
531-
* Set up the checkout page for Stripe Payment Element (SPE).
531+
* Set up the checkout page for Optimized Checkout (OC).
532532
*
533533
* @param {Page} page Playwright page fixture.
534534
* @param {string} checkoutType The type of checkout ('blocks' or 'shortcode').
@@ -538,7 +538,7 @@ export const setupACSSCheckout = async ( page, checkoutType = 'blocks' ) => {
538538
* @returns {Promise<void>} Resolves when setup is complete.
539539
* @throws {Error} If iframe cannot be found or initialization fails.
540540
*/
541-
export const setupSPECheckout = async (
541+
export const setupOptimizedCheckout = async (
542542
page,
543543
checkoutType = 'blocks',
544544
options = { timeout: 10000, skipCartSetup: false }
@@ -605,7 +605,9 @@ export const setupSPECheckout = async (
605605
// Select the card payment method
606606
await paymentFrame.getByRole( 'button', { name: 'Card' } ).click();
607607
} catch ( error ) {
608-
throw new Error( `Failed to set up SPE checkout: ${ error.message }` );
608+
throw new Error(
609+
`Failed to set up Optimized Checkout: ${ error.message }`
610+
);
609611
}
610612
};
611613

@@ -745,13 +747,13 @@ export async function handleCheckoutCashAppPay(
745747
}
746748

747749
/**
748-
* Fill in the payment details for Stripe Payment Element (SPE) checkout.
750+
* Fill in the payment details for Optimized Checkout (OC).
749751
*
750752
* @param {Page} page Playwright page fixture.
751753
* @param {Object} card The CC info in the format provided on the test-data.
752754
* @param {string} checkoutType The type of checkout ('blocks' or 'shortcode').
753755
*/
754-
export const fillSPEDetails = async ( page, card, checkoutType = 'blocks' ) => {
756+
export const fillOCDetails = async ( page, card, checkoutType = 'blocks' ) => {
755757
// Determine the appropriate iframe selector based on checkout type
756758
const iframeSelector =
757759
checkoutType === 'blocks'

0 commit comments

Comments
 (0)