Commit 72e6daea04 for woocommerce

commit 72e6daea049c424de64f78cefc4bbbe4cd748dc1
Author: theAverageDev (Luca Tumedei) <luca@theaveragedev.com>
Date:   Tue Feb 10 10:37:52 2026 +0100

    Convert e2e-pw test specs to TypeScript (batch 2) (#63198)

diff --git a/plugins/woocommerce/changelog/e2e-pw-ts-conversion-03 b/plugins/woocommerce/changelog/e2e-pw-ts-conversion-03
new file mode 100644
index 0000000000..072e5e6b86
--- /dev/null
+++ b/plugins/woocommerce/changelog/e2e-pw-ts-conversion-03
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Convert second set of e2e-pw test files to TypeScript.
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/cart/add-to-cart.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/cart/add-to-cart.spec.ts
similarity index 97%
rename from plugins/woocommerce/tests/e2e-pw/tests/cart/add-to-cart.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/cart/add-to-cart.spec.ts
index d82bc33b0b..68e72014fa 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/cart/add-to-cart.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/cart/add-to-cart.spec.ts
@@ -19,7 +19,7 @@ test.describe(
 	'Add to Cart behavior',
 	{ tag: [ tags.PAYMENTS, tags.SERVICES ] },
 	() => {
-		let productId;
+		let productId: number;

 		test.beforeAll( async ( { restApi } ) => {
 			await restApi
@@ -28,7 +28,7 @@ test.describe(
 					type: 'simple',
 					regular_price: productPrice,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					productId = response.data.id;
 				} );
 		} );
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/cart/cart.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/cart/cart.spec.ts
similarity index 98%
rename from plugins/woocommerce/tests/e2e-pw/tests/cart/cart.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/cart/cart.spec.ts
index 18682ef6c6..51301e696b 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/cart/cart.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/cart/cart.spec.ts
@@ -1,6 +1,7 @@
 /**
  * External dependencies
  */
+import { Page } from '@playwright/test';
 import {
 	addAProductToCart,
 	WC_API_PATH,
@@ -17,7 +18,7 @@ import { updateIfNeeded, resetValue } from '../../utils/settings';

 const cartPages = [ { name: 'blocks cart', slug: 'cart' }, CLASSIC_CART_PAGE ];

-function isClassicCart( page ) {
+function isClassicCart( page: Page ) {
 	return page.url().includes( CLASSIC_CART_PAGE.slug );
 }

diff --git a/plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout-link.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout-link.spec.ts
similarity index 100%
rename from plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout-link.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout-link.spec.ts
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout-shortcode-custom-place-order-button.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout-shortcode-custom-place-order-button.spec.ts
similarity index 100%
rename from plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout-shortcode-custom-place-order-button.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout-shortcode-custom-place-order-button.spec.ts
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout.spec.ts
similarity index 96%
rename from plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout.spec.ts
index 9ccdfadefe..8222bcf6d6 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/checkout/checkout.spec.ts
@@ -1,6 +1,7 @@
 /**
  * External dependencies
  */
+import { Page } from '@playwright/test';
 import {
 	addAProductToCart,
 	fillBillingCheckoutBlocks,
@@ -29,11 +30,11 @@ const checkoutPages = [
 ];

 /* region helpers */
-function isClassicCheckout( page ) {
+function isClassicCheckout( page: Page ) {
 	return page.url().includes( CLASSIC_CHECKOUT_PAGE.slug );
 }

-async function checkOrderDetails( page, product, qty, tax ) {
+async function checkOrderDetails( page: Page, product, qty: number, tax ) {
 	const expectedTotalPrice = (
 		parseFloat( product.price ) *
 		qty *
@@ -68,10 +69,10 @@ async function checkOrderDetails( page, product, qty, tax ) {
 }

 async function addProductToCartAndProceedToCheckout(
-	pageSlug,
-	page,
+	pageSlug: string,
+	page: Page,
 	product,
-	qty,
+	qty: number,
 	tax
 ) {
 	await addAProductToCart( page, product.id, qty );
@@ -79,7 +80,7 @@ async function addProductToCartAndProceedToCheckout(
 	await checkOrderDetails( page, product, qty, tax );
 }

-async function placeOrder( page ) {
+async function placeOrder( page: Page ) {
 	if ( ! isClassicCheckout( page ) ) {
 		await page.getByLabel( 'Add a note to your order' ).check();
 		// this helps with flakiness on clicking the Place order button
@@ -95,7 +96,7 @@ async function placeOrder( page ) {
 	).toBeVisible();
 }

-async function fillBillingDetails( page, data, createAccount ) {
+async function fillBillingDetails( page: Page, data, createAccount: boolean ) {
 	if ( isClassicCheckout( page ) ) {
 		await page
 			.getByRole( 'textbox', { name: 'First name' } )
@@ -268,12 +269,12 @@ const test = baseTest.extend( {
 			} );

 		// add a shipping zone and method for the customer
-		let shippingZoneId;
+		let shippingZoneId: number;
 		await restApi
 			.post( `${ WC_API_PATH }/shipping/zones`, {
 				name: `Free Shipping ${ customerData.shipping.city }`,
 			} )
-			.then( ( response ) => {
+			.then( ( response: { data: { id: number } } ) => {
 				shippingZoneId = response.data.id;
 			} );
 		await restApi.put(
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-block-coupons.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-block-coupons.spec.ts
similarity index 95%
rename from plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-block-coupons.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-block-coupons.spec.ts
index 8e02a07154..81893ec829 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-block-coupons.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-block-coupons.spec.ts
@@ -36,7 +36,7 @@ const customerBilling = {
 	email: 'john.doe.merchant.test@example.com',
 };

-let productId, orderId, limitedCouponId;
+let productId: number, orderId: number, limitedCouponId: number;

 const test = baseTest.extend( {
 	page: async ( { page }, use ) => {
@@ -50,7 +50,7 @@ test.describe(
 	'Cart Block Applying Coupons',
 	{ tag: [ tags.PAYMENTS, tags.SERVICES ] },
 	() => {
-		const couponBatchId = [];
+		const couponBatchId: number[] = [];

 		test.beforeAll( async ( { restApi } ) => {
 			// make sure the currency is USD
@@ -68,7 +68,7 @@ test.describe(
 					regular_price: singleProductFullPrice,
 					sale_price: singleProductSalePrice,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					productId = response.data.id;
 				} );
 			// add coupons
@@ -76,7 +76,7 @@ test.describe(
 				.post( `${ WC_API_PATH }/coupons/batch`, {
 					create: coupons,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { create: { id: number }[] } } ) => {
 					for ( let i = 0; i < response.data.create.length; i++ ) {
 						couponBatchId.push( response.data.create[ i ].id );
 					}
@@ -90,7 +90,7 @@ test.describe(
 					usage_limit: 1,
 					usage_count: 1,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					limitedCouponId = response.data.id;
 				} );
 			// add order with applied limited coupon
@@ -104,7 +104,7 @@ test.describe(
 						},
 					],
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					orderId = response.data.id;
 				} );
 		} );
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-coupons.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-coupons.spec.ts
similarity index 98%
rename from plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-coupons.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-coupons.spec.ts
index 3faa2fb073..8b52ade7b9 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-coupons.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-coupons.spec.ts
@@ -44,8 +44,8 @@ test.describe(
 	'Cart & Checkout applying coupons',
 	{ tag: [ tags.PAYMENTS, tags.SERVICES, tags.HPOS ] },
 	() => {
-		let firstProductId;
-		const couponBatchId = [];
+		let firstProductId: number;
+		const couponBatchId: number[] = [];

 		test.beforeAll( async ( { restApi } ) => {
 			// Make sure the classic cart and checkout pages exist
@@ -72,7 +72,7 @@ test.describe(
 					type: 'simple',
 					regular_price: '20.00',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					firstProductId = response.data.id;
 				} );
 			// add coupons
@@ -80,7 +80,7 @@ test.describe(
 				.post( `${ WC_API_PATH }/coupons/batch`, {
 					create: coupons,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { create: { id: number }[] } } ) => {
 					for ( let i = 0; i < response.data.create.length; i++ ) {
 						couponBatchId.push( response.data.create[ i ].id );
 					}
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-restricted-coupons.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-restricted-coupons.spec.ts
similarity index 96%
rename from plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-restricted-coupons.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-restricted-coupons.spec.ts
index 6d6ac07135..1f37190da3 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-restricted-coupons.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/coupons/cart-checkout-restricted-coupons.spec.ts
@@ -1,6 +1,7 @@
 /**
  * External dependencies
  */
+import { Page } from '@playwright/test';
 import {
 	addAProductToCart,
 	getOrderIdFromUrl,
@@ -23,7 +24,7 @@ const includedCategoryName = 'Included Category';
 const excludedCategoryName = 'Excluded Category';

 // This applies a coupon and waits for the result to prevent flakiness.
-const applyCoupon = async ( page, couponCode ) => {
+const applyCoupon = async ( page: Page, couponCode: string ) => {
 	const responsePromise = page.waitForResponse(
 		( response ) =>
 			response.url().includes( '?wc-ajax=apply_coupon' ) &&
@@ -34,7 +35,7 @@ const applyCoupon = async ( page, couponCode ) => {
 	await responsePromise;
 };

-const expandCouponForm = async ( page ) => {
+const expandCouponForm = async ( page: Page ) => {
 	await page
 		.getByRole( 'button', {
 			name: 'Enter your coupon code',
@@ -57,12 +58,12 @@ test.describe(
 		],
 	},
 	() => {
-		let firstProductId,
-			secondProductId,
-			firstCategoryId,
-			secondCategoryId,
-			shippingZoneId;
-		const couponBatchId = [];
+		let firstProductId: number,
+			secondProductId: number,
+			firstCategoryId: number,
+			secondCategoryId: number,
+			shippingZoneId: number;
+		const couponBatchId: number[] = [];

 		test.beforeAll( async ( { restApi } ) => {
 			// Make sure the classic cart and checkout pages exist
@@ -106,7 +107,7 @@ test.describe(
 				.post( `${ WC_API_PATH }/shipping/zones`, {
 					name: 'Free Shipping',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					shippingZoneId = response.data.id;
 				} );
 			await restApi.post(
@@ -120,14 +121,14 @@ test.describe(
 				.post( `${ WC_API_PATH }/products/categories`, {
 					name: includedCategoryName,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					firstCategoryId = response.data.id;
 				} );
 			await restApi
 				.post( `${ WC_API_PATH }/products/categories`, {
 					name: excludedCategoryName,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					secondCategoryId = response.data.id;
 				} );
 			// add product
@@ -138,7 +139,7 @@ test.describe(
 					regular_price: '20.00',
 					categories: [ { id: firstCategoryId } ],
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					firstProductId = response.data.id;
 				} );
 			await restApi
@@ -149,7 +150,7 @@ test.describe(
 					sale_price: '15.00',
 					categories: [ { id: secondCategoryId } ],
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					secondProductId = response.data.id;
 				} );

@@ -215,7 +216,7 @@ test.describe(
 				.post( `${ WC_API_PATH }/coupons/batch`, {
 					create: restrictedCoupons,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { create: { id: number }[] } } ) => {
 					for ( let i = 0; i < response.data.create.length; i++ ) {
 						couponBatchId.push( response.data.create[ i ].id );
 					}
@@ -403,7 +404,7 @@ test.describe(
 			context,
 			restApi,
 		} ) => {
-			const orderIds = [];
+			const orderIds: number[] = [];

 			// create 2 orders using the limited coupon
 			for ( let i = 0; i < 2; i++ ) {
@@ -427,8 +428,8 @@ test.describe(
 							},
 						],
 					} )
-					.then( ( response ) => {
-						orderIds.push = response.data.id;
+					.then( ( response: { data: { id: number } } ) => {
+						orderIds.push( response.data.id );
 					} );
 			}

diff --git a/plugins/woocommerce/tests/e2e-pw/tests/coupons/create-coupon.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/coupons/create-coupon.spec.ts
similarity index 100%
rename from plugins/woocommerce/tests/e2e-pw/tests/coupons/create-coupon.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/coupons/create-coupon.spec.ts
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/coupons/create-restricted-coupons.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/coupons/create-restricted-coupons.spec.ts
similarity index 100%
rename from plugins/woocommerce/tests/e2e-pw/tests/coupons/create-restricted-coupons.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/coupons/create-restricted-coupons.spec.ts
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/order/create-order.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/order/create-order.spec.ts
similarity index 95%
rename from plugins/woocommerce/tests/e2e-pw/tests/order/create-order.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/order/create-order.spec.ts
index a80c7df1ca..b2ddfec7df 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/order/create-order.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/order/create-order.spec.ts
@@ -1,6 +1,7 @@
 /**
  * External dependencies
  */
+import { Page } from '@playwright/test';
 import { WC_API_PATH } from '@woocommerce/e2e-utils-playwright';

 /**
@@ -43,7 +44,7 @@ const taxRates = [
 ];
 const taxTotals = [ '10.00', '20.00', '240.00' ];

-async function getOrderIdFromPage( page ) {
+async function getOrderIdFromPage( page: Page ) {
 	// get order ID from the page
 	const orderText = await page
 		.locator( 'h2.woocommerce-order-data__heading' )
@@ -52,7 +53,7 @@ async function getOrderIdFromPage( page ) {
 	return parts[ 0 ];
 }

-async function addProductToOrder( page, product, quantity ) {
+async function addProductToOrder( page: Page, product, quantity: number ) {
 	await page.getByRole( 'button', { name: 'Add item(s)' } ).click();
 	await page.getByRole( 'button', { name: 'Add product(s)' } ).click();
 	await page.getByText( 'Search for a product…' ).click();
@@ -234,15 +235,15 @@ const test = baseTest.extend( {

 	groupedProduct: async ( { restApi }, use ) => {
 		let product = {};
-		let subProductAId;
-		let subProductBId;
+		let subProductAId: number;
+		let subProductBId: number;

 		await restApi
 			.post( `${ WC_API_PATH }/products`, {
 				name: 'Add-on A',
 				regular_price: '11.95',
 			} )
-			.then( ( response ) => {
+			.then( ( response: { data: { id: number } } ) => {
 				subProductAId = response.data.id;
 			} );
 		await restApi
@@ -250,7 +251,7 @@ const test = baseTest.extend( {
 				name: 'Add-on B',
 				regular_price: '18.97',
 			} )
-			.then( ( response ) => {
+			.then( ( response: { data: { id: number } } ) => {
 				subProductBId = response.data.id;
 			} );
 		await restApi
@@ -305,17 +306,19 @@ test.describe(
 					.delete( `${ WC_API_PATH }/taxes/classes/${ slug }`, {
 						force: true,
 					} )
-					.catch( ( error ) => {
-						if (
-							error.response.data.code ===
-							'woocommerce_rest_invalid_tax_class'
-						) {
-							// do nothing, probably the tax class was not created due to a failing test
-						} else {
-							// Something else went wrong.
-							throw new Error( error.response.data );
+					.catch(
+						( error: { response: { data: { code: string } } } ) => {
+							if (
+								error.response.data.code ===
+								'woocommerce_rest_invalid_tax_class'
+							) {
+								// do nothing, probably the tax class was not created due to a failing test
+							} else {
+								// Something else went wrong.
+								throw new Error( error.response.data.code );
+							}
 						}
-					} );
+					);
 			}
 			// turn off taxes
 			await restApi.put(
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/order/customer-payment-page.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/order/customer-payment-page.spec.ts
similarity index 96%
rename from plugins/woocommerce/tests/e2e-pw/tests/order/customer-payment-page.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/order/customer-payment-page.spec.ts
index b4246758a6..cb4324ca37 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/order/customer-payment-page.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/order/customer-payment-page.spec.ts
@@ -9,7 +9,7 @@ import { WC_API_PATH } from '@woocommerce/e2e-utils-playwright';
 import { tags, expect, test } from '../../fixtures/fixtures';
 import { ADMIN_STATE_PATH } from '../../playwright.config';

-let productId, orderId;
+let productId: number, orderId: number;
 const productName = 'Simple Product Name';
 const productPrice = '15.99';

@@ -27,7 +27,7 @@ test.describe(
 					type: 'simple',
 					regular_price: productPrice,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					productId = response.data.id;
 				} );
 			// create an order
@@ -40,7 +40,7 @@ test.describe(
 						},
 					],
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					orderId = response.data.id;
 				} );
 			// enable bank transfer as a payment option
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/order/order-bulk-edit.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/order/order-bulk-edit.spec.ts
similarity index 90%
rename from plugins/woocommerce/tests/e2e-pw/tests/order/order-bulk-edit.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/order/order-bulk-edit.spec.ts
index abfdcd7c1c..86ad29e4d5 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/order/order-bulk-edit.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/order/order-bulk-edit.spec.ts
@@ -15,42 +15,46 @@ test.describe(
 	() => {
 		test.use( { storageState: ADMIN_STATE_PATH } );

-		let orderId1, orderId2, orderId3, orderId4, orderId5;
+		let orderId1: number,
+			orderId2: number,
+			orderId3: number,
+			orderId4: number,
+			orderId5: number;

 		test.beforeAll( async ( { restApi } ) => {
 			await restApi
 				.post( `${ WC_API_PATH }/orders`, {
 					status: 'processing',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					orderId1 = response.data.id;
 				} );
 			await restApi
 				.post( `${ WC_API_PATH }/orders`, {
 					status: 'processing',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					orderId2 = response.data.id;
 				} );
 			await restApi
 				.post( `${ WC_API_PATH }/orders`, {
 					status: 'processing',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					orderId3 = response.data.id;
 				} );
 			await restApi
 				.post( `${ WC_API_PATH }/orders`, {
 					status: 'processing',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					orderId4 = response.data.id;
 				} );
 			await restApi
 				.post( `${ WC_API_PATH }/orders`, {
 					status: 'processing',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					orderId5 = response.data.id;
 				} );
 		} );
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.ts
similarity index 94%
rename from plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.ts
index 3599a5e935..7dff6532d2 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.ts
@@ -9,7 +9,7 @@ import { WC_API_PATH } from '@woocommerce/e2e-utils-playwright';
 import { tags, expect, test } from '../../fixtures/fixtures';
 import { ADMIN_STATE_PATH } from '../../playwright.config';

-let productId, couponId, orderId;
+let productId: number, couponId: number, orderId: number;

 const productPrice = '9.99';
 const productName = 'Apply Coupon Product';
@@ -31,7 +31,7 @@ test.describe(
 					type: 'simple',
 					regular_price: productPrice,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					productId = response.data.id;
 				} );
 			// create a $5 off coupon
@@ -41,7 +41,7 @@ test.describe(
 					discount_type: 'fixed_product',
 					amount: couponAmount,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					couponId = response.data.id;
 				} );
 			// create order
@@ -59,7 +59,7 @@ test.describe(
 						},
 					],
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					orderId = response.data.id;
 				} );
 		} );
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/order/order-edit.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/order/order-edit.spec.ts
similarity index 95%
rename from plugins/woocommerce/tests/e2e-pw/tests/order/order-edit.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/order/order-edit.spec.ts
index 1d66ee14d1..f475559655 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/order/order-edit.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/order/order-edit.spec.ts
@@ -1,7 +1,7 @@
 /**
  * External dependencies
  */
-import { WC_API_PATH } from '@woocommerce/e2e-utils-playwright';
+import { ApiClient, WC_API_PATH } from '@woocommerce/e2e-utils-playwright';

 /**
  * Internal dependencies
@@ -13,7 +13,10 @@ import { random } from '../../utils/helpers';
 test.use( { storageState: ADMIN_STATE_PATH } );

 test.describe( 'Edit order', { tag: [ tags.SERVICES, tags.HPOS ] }, () => {
-	let orderId, secondOrderId, orderToCancel, customerId;
+	let orderId: number,
+		secondOrderId: number,
+		orderToCancel: number,
+		customerId: number;
 	const username = `big.archie.${ Date.now() }`;

 	test.beforeAll( async ( { restApi } ) => {
@@ -21,21 +24,21 @@ test.describe( 'Edit order', { tag: [ tags.SERVICES, tags.HPOS ] }, () => {
 			.post( `${ WC_API_PATH }/orders`, {
 				status: 'processing',
 			} )
-			.then( ( response ) => {
+			.then( ( response: { data: { id: number } } ) => {
 				orderId = response.data.id;
 			} );
 		await restApi
 			.post( `${ WC_API_PATH }/orders`, {
 				status: 'processing',
 			} )
-			.then( ( response ) => {
+			.then( ( response: { data: { id: number } } ) => {
 				secondOrderId = response.data.id;
 			} );
 		await restApi
 			.post( `${ WC_API_PATH }/orders`, {
 				status: 'processing',
 			} )
-			.then( ( response ) => {
+			.then( ( response: { data: { id: number } } ) => {
 				orderToCancel = response.data.id;
 			} );

@@ -70,7 +73,7 @@ test.describe( 'Edit order', { tag: [ tags.SERVICES, tags.HPOS ] }, () => {
 					postcode: '94107',
 				},
 			} )
-			.then( ( response ) => {
+			.then( ( response: { data: { id: number } } ) => {
 				customerId = response.data.id;
 			} );
 	} );
@@ -383,16 +386,18 @@ test.describe(
 			email: 'john.doe@example.com',
 		};

-		let orderId,
-			productId,
-			product2Id,
-			noProductOrderId,
-			initialGrantAccessAfterPaymentSetting;
+		let orderId: number,
+			productId: number,
+			product2Id: number,
+			noProductOrderId: number,
+			initialGrantAccessAfterPaymentSetting: string;

 		/**
 		 * Enable the "Grant access to downloadable products after payment" setting in WooCommerce > Settings > Products > Downloadable products.
 		 */
-		const enableGrantAccessAfterPaymentSetting = async ( restApi ) => {
+		const enableGrantAccessAfterPaymentSetting = async (
+			restApi: ApiClient
+		) => {
 			const endpoint = `${ WC_API_PATH }/settings/products/woocommerce_downloads_grant_access_after_payment`;

 			// Get current value
@@ -407,7 +412,9 @@ test.describe(
 			}
 		};

-		const revertGrantAccessAfterPaymentSetting = async ( restApi ) => {
+		const revertGrantAccessAfterPaymentSetting = async (
+			restApi: ApiClient
+		) => {
 			const endpoint = `${ WC_API_PATH }/settings/products/woocommerce_downloads_grant_access_after_payment`;

 			await restApi.put( endpoint, {
@@ -429,7 +436,7 @@ test.describe(
 						},
 					],
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					productId = response.data.id;
 				} );

@@ -448,7 +455,7 @@ test.describe(
 						},
 					],
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					product2Id = response.data.id;
 				} );
 			await restApi
@@ -462,7 +469,7 @@ test.describe(
 					],
 					billing: customerBilling,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					orderId = response.data.id;
 				} );
 			await restApi
@@ -470,7 +477,7 @@ test.describe(
 					status: 'processing',
 					billing: customerBilling,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					noProductOrderId = response.data.id;
 				} );
 		} );
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/order/order-grace-period.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/order/order-grace-period.spec.ts
similarity index 100%
rename from plugins/woocommerce/tests/e2e-pw/tests/order/order-grace-period.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/order/order-grace-period.spec.ts
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/order/order-refund.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/order/order-refund.spec.ts
similarity index 93%
rename from plugins/woocommerce/tests/e2e-pw/tests/order/order-refund.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/order/order-refund.spec.ts
index 4c08e29898..e9bbabca02 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/order/order-refund.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/order/order-refund.spec.ts
@@ -15,7 +15,7 @@ test.describe.serial(
 	'WooCommerce Orders > Refund an order',
 	{ tag: [ tags.PAYMENTS, tags.HPOS ] },
 	() => {
-		let productId, orderId, currencySymbol;
+		let productId: number, orderId: number, currencySymbol: string | null;

 		test.beforeAll( async ( { restApi } ) => {
 			// create a simple product
@@ -25,7 +25,7 @@ test.describe.serial(
 					type: 'simple',
 					regular_price: '9.99',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					productId = response.data.id;
 				} );
 			// create order
@@ -39,7 +39,7 @@ test.describe.serial(
 					],
 					status: 'completed',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					orderId = response.data.id;
 				} );
 		} );
@@ -145,7 +145,9 @@ test.describe(
 	'WooCommerce Orders > Refund and restock an order item',
 	{ tag: [ tags.PAYMENTS, tags.SERVICES, tags.HPOS ] },
 	() => {
-		let productWithStockId, productWithNoStockId, orderId;
+		let productWithStockId: number,
+			productWithNoStockId: number,
+			orderId: number;

 		test.beforeAll( async ( { restApi } ) => {
 			// create a simple product with managed stock
@@ -157,7 +159,7 @@ test.describe(
 					manage_stock: true,
 					stock_quantity: 10,
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					productWithStockId = response.data.id;
 				} );
 			// create a simple product with NO managed stock
@@ -167,7 +169,7 @@ test.describe(
 					type: 'simple',
 					regular_price: '5.99',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					productWithNoStockId = response.data.id;
 				} );
 			// create order
@@ -185,7 +187,7 @@ test.describe(
 					],
 					status: 'completed',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					orderId = response.data.id;
 				} );
 		} );
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/order/order-status-filter.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/order/order-status-filter.spec.ts
similarity index 94%
rename from plugins/woocommerce/tests/e2e-pw/tests/order/order-status-filter.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/order/order-status-filter.spec.ts
index 63b94670f2..f5c2787e64 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/order/order-status-filter.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/order/order-status-filter.spec.ts
@@ -9,7 +9,7 @@ import { WC_API_PATH } from '@woocommerce/e2e-utils-playwright';
 import { tags, expect, test } from '../../fixtures/fixtures';
 import { ADMIN_STATE_PATH } from '../../playwright.config';

-const orderBatchId = [];
+const orderBatchId: number[] = [];
 const statusColumnTextSelector = 'mark.order-status > span';

 // Define order statuses to filter against
@@ -41,7 +41,7 @@ test.describe(
 			} );
 			await restApi
 				.post( `${ WC_API_PATH }/orders/batch`, { create: orders } )
-				.then( ( response ) => {
+				.then( ( response: { data: { create: { id: number }[] } } ) => {
 					for ( let i = 0; i < response.data.create.length; i++ ) {
 						orderBatchId.push( response.data.create[ i ].id );
 					}
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shipping/shipping-classes.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shipping/shipping-classes.spec.ts
similarity index 100%
rename from plugins/woocommerce/tests/e2e-pw/tests/shipping/shipping-classes.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/shipping/shipping-classes.spec.ts
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shipping/shipping-zones.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shipping/shipping-zones.spec.ts
similarity index 100%
rename from plugins/woocommerce/tests/e2e-pw/tests/shipping/shipping-zones.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/shipping/shipping-zones.spec.ts
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shop/cart-redirection.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shop/cart-redirection.spec.ts
similarity index 96%
rename from plugins/woocommerce/tests/e2e-pw/tests/shop/cart-redirection.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/shop/cart-redirection.spec.ts
index 9256496032..aab42945bd 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/shop/cart-redirection.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/shop/cart-redirection.spec.ts
@@ -15,7 +15,7 @@ test.describe(
 		tag: [ tags.PAYMENTS, tags.NOT_E2E, tags.COULD_BE_LOWER_LEVEL_TEST ],
 	},
 	() => {
-		let productId;
+		let productId: number;
 		const productName = 'A redirect product test';

 		test.beforeAll( async ( { restApi } ) => {
@@ -26,7 +26,7 @@ test.describe(
 					type: 'simple',
 					regular_price: '17.99',
 				} )
-				.then( ( response ) => {
+				.then( ( response: { data: { id: number } } ) => {
 					productId = response.data.id;
 				} );
 			await restApi.put(
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shop/shop-search-browse-sort.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shop/shop-search-browse-sort.spec.ts
similarity index 98%
rename from plugins/woocommerce/tests/e2e-pw/tests/shop/shop-search-browse-sort.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/shop/shop-search-browse-sort.spec.ts
index 00e2cca3a1..aaa53b8ca7 100644
--- a/plugins/woocommerce/tests/e2e-pw/tests/shop/shop-search-browse-sort.spec.js
+++ b/plugins/woocommerce/tests/e2e-pw/tests/shop/shop-search-browse-sort.spec.ts
@@ -32,7 +32,7 @@ test.describe(
 						console.log( JSON.stringify( response.data ) );
 					}
 				} )
-				.catch( ( error ) => {
+				.catch( ( error: { response: unknown } ) => {
 					console.error( error.response );
 				} );

@@ -56,7 +56,7 @@ test.describe(
 				.then( ( response ) => {
 					products = response.data.create;
 				} )
-				.catch( ( error ) => {
+				.catch( ( error: { response: unknown } ) => {
 					console.error( error.response );
 				} );
 		} );
diff --git a/plugins/woocommerce/tests/e2e-pw/tests/shop/shop-title-after-deletion.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/shop/shop-title-after-deletion.spec.ts
similarity index 100%
rename from plugins/woocommerce/tests/e2e-pw/tests/shop/shop-title-after-deletion.spec.js
rename to plugins/woocommerce/tests/e2e-pw/tests/shop/shop-title-after-deletion.spec.ts