Commit 229328419ee for woocommerce
commit 229328419ee9119af2f3d94f40d5f20fcf444482
Author: Chris Lilitsas <1105590+xristos3490@users.noreply.github.com>
Date: Wed Oct 21 17:55:48 2026 +0300
Accept curly quotes in Back in Stock and checkout link E2E notice matchers (#70059)
* test: accept curly quotes in Back in Stock e2e notice matchers
WordPress 7.2 kses decodes " in text, so wptexturize curls the
quotes around product names when a block template renders the notice.
* test: accept curly quotes in checkout link e2e notice matchers
Same WordPress 7.2 kses and wptexturize change as the Back in Stock
specs. The coupon matcher keeps the case-insensitive match the string
form had, since the Store API lowercases the coupon code.
* test: require matching quote pairs in e2e notice matchers
* test: move quotedPattern to shared e2e helpers
---------
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
diff --git a/plugins/woocommerce/changelog/fix-bis-e2e-curly-quotes b/plugins/woocommerce/changelog/fix-bis-e2e-curly-quotes
new file mode 100644
index 00000000000..4a3392107d1
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-bis-e2e-curly-quotes
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Match curly or straight quotes in Back in Stock Notifications and checkout link E2E notice assertions so they pass on WordPress 7.2; no production change.
diff --git a/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/my-account.spec.ts b/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/my-account.spec.ts
index ac0a570004e..2201be065fd 100644
--- a/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/my-account.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/my-account.spec.ts
@@ -10,11 +10,13 @@ import { expect, request, tags, locks } from '../../fixtures/fixtures';
import {
BIS_FEATURE_OPTION,
createOutOfStockProduct,
+ escapeRegExp,
resetBISOptions,
setBISOptions,
signUpOnProductPage,
test,
} from '../../utils/back-in-stock-notifications';
+import { quotedPattern } from '../../utils/helpers';
import { logInFromMyAccount } from '../../utils/login';
import { setOption } from '../../utils/options';
@@ -233,7 +235,7 @@ test.describe(
);
await expect(
page.getByText(
- "You haven't signed up for any back-in-stock notifications yet."
+ /You haven['’]t signed up for any back-in-stock notifications yet\./
)
).toHaveCount( 0 );
@@ -329,7 +331,11 @@ test.describe(
// And a notice confirms the cancellation.
await expect(
page.getByText(
- `Back in stock notification for "${ product.name }" cancelled.`
+ new RegExp(
+ `Back in stock notification for ${ quotedPattern(
+ escapeRegExp( product.name )
+ ) } cancelled\\.`
+ )
)
).toBeVisible();
} finally {
@@ -368,7 +374,7 @@ test.describe(
await expect(
page.getByText(
- "You haven't signed up for any back-in-stock notifications yet."
+ /You haven['’]t signed up for any back-in-stock notifications yet\./
)
).toBeVisible();
diff --git a/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/variations.spec.ts b/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/variations.spec.ts
index be03f0debc8..8a27fd3e719 100644
--- a/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/variations.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/back-in-stock-notifications/variations.spec.ts
@@ -25,6 +25,7 @@ import {
triggerStockNotificationsBatch,
uniqueGuestEmail,
} from '../../utils/back-in-stock-notifications';
+import { quotedPattern } from '../../utils/helpers';
import { setOption } from '../../utils/options';
test.describe(
@@ -130,11 +131,13 @@ test.describe(
await expect(
guestPage.getByText(
new RegExp(
- `You have successfully signed up! You will be notified when "${ escapeRegExp(
- variableProduct.name
- ) } [-–] ${ escapeRegExp(
- outOfStockVariation.option
- ) }" is back in stock\\.`
+ `You have successfully signed up! You will be notified when ${ quotedPattern(
+ `${ escapeRegExp(
+ variableProduct.name
+ ) } [-–] ${ escapeRegExp(
+ outOfStockVariation.option
+ ) }`
+ ) } is back in stock\\.`
)
)
).toBeVisible();
diff --git a/plugins/woocommerce/tests/e2e/tests/checkout/checkout-link.spec.ts b/plugins/woocommerce/tests/e2e/tests/checkout/checkout-link.spec.ts
index 9e3fa3281d6..4ad481c6a47 100644
--- a/plugins/woocommerce/tests/e2e/tests/checkout/checkout-link.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/checkout/checkout-link.spec.ts
@@ -14,6 +14,7 @@ import {
guestFile,
} from '../../fixtures/fixtures';
import { getFakeProduct } from '../../utils/data';
+import { quotedPattern } from '../../utils/helpers';
const test = baseTest.extend( {
products: async ( { restApi }, use ) => {
@@ -116,7 +117,12 @@ test.describe( 'Checkout Link Endpoint', () => {
// Assert error notice is shown for invalid coupon
await expect(
page.getByText(
- 'Coupon "INVALID_COUPON" cannot be applied because it does not exist.'
+ new RegExp(
+ `Coupon ${ quotedPattern(
+ 'INVALID_COUPON'
+ ) } cannot be applied because it does not exist\\.`,
+ 'i'
+ )
)
).toBeVisible();
}
@@ -136,7 +142,11 @@ test.describe( 'Checkout Link Endpoint', () => {
// Assert error notice is shown for invalid product
await expect(
page.getByText(
- 'Product with ID "999999" was not found and cannot be added to the cart.'
+ new RegExp(
+ `Product with ID ${ quotedPattern(
+ '999999'
+ ) } was not found and cannot be added to the cart\\.`
+ )
)
).toBeVisible();
}
@@ -156,7 +166,11 @@ test.describe( 'Checkout Link Endpoint', () => {
// Assert error notice is shown for invalid product
await expect(
page.getByText(
- 'Product with ID "999999" was not found and cannot be added to the cart.'
+ new RegExp(
+ `Product with ID ${ quotedPattern(
+ '999999'
+ ) } was not found and cannot be added to the cart\\.`
+ )
)
).toBeVisible();
diff --git a/plugins/woocommerce/tests/e2e/utils/back-in-stock-notifications.ts b/plugins/woocommerce/tests/e2e/utils/back-in-stock-notifications.ts
index 4b076b6cbdf..8e8559c8b72 100644
--- a/plugins/woocommerce/tests/e2e/utils/back-in-stock-notifications.ts
+++ b/plugins/woocommerce/tests/e2e/utils/back-in-stock-notifications.ts
@@ -14,6 +14,7 @@ import {
import { deleteOption, setOption } from './options';
import { expectEmail } from './email';
import { setFilterValue } from './filters';
+import { quotedPattern } from './helpers';
import { wpCLI } from './cli';
import { expect, test as baseTest } from '../fixtures/fixtures';
import { admin } from '../test-data/data';
@@ -849,9 +850,9 @@ export const bisNotice = {
*/
success: ( productName: string ): RegExp =>
new RegExp(
- `You have successfully signed up! You will be notified when "${ escapeRegExp(
- productName
- ) }" is back in stock\\.`
+ `You have successfully signed up! You will be notified when ${ quotedPattern(
+ escapeRegExp( productName )
+ ) } is back in stock\\.`
),
doubleOptIn:
/Thanks for signing up! Please complete the sign-up process by following the verification link sent to your e-mail\./,
@@ -864,9 +865,9 @@ export const bisNotice = {
*/
verified: ( productName: string ): RegExp =>
new RegExp(
- `Successfully verified stock notifications for "${ escapeRegExp(
- productName
- ) }"\\.`
+ `Successfully verified stock notifications for ${ quotedPattern(
+ escapeRegExp( productName )
+ ) }\\.`
),
/**
* Printed on the shop page after an unsubscribe link is followed.
@@ -878,9 +879,9 @@ export const bisNotice = {
new RegExp(
`Successfully unsubscribed ${ escapeRegExp(
email
- ) }\\. You will not receive a notification when "${ escapeRegExp(
- productName
- ) }" becomes available\\.`
+ ) }\\. You will not receive a notification when ${ quotedPattern(
+ escapeRegExp( productName )
+ ) } becomes available\\.`
),
/**
* Printed on the shop page after an unsubscribe link is followed for a
diff --git a/plugins/woocommerce/tests/e2e/utils/helpers.ts b/plugins/woocommerce/tests/e2e/utils/helpers.ts
index 4aed00d9253..cf8c68c78ba 100644
--- a/plugins/woocommerce/tests/e2e/utils/helpers.ts
+++ b/plugins/woocommerce/tests/e2e/utils/helpers.ts
@@ -7,4 +7,17 @@ const random = ( size = 4 ) => {
return crypto.randomBytes( size ).toString( 'hex' );
};
-export { random };
+/**
+ * Wrap a regular expression pattern in a matching pair of straight or curly
+ * double quotes.
+ *
+ * Since WordPress 7.2, kses decodes `"` in notice text, so `wptexturize`
+ * curls the quotes when a block template renders the notice.
+ *
+ * @param {string} pattern The regular expression pattern to wrap.
+ */
+const quotedPattern = ( pattern: string ) => {
+ return `(?:"(?:${ pattern })"|“(?:${ pattern })”)`;
+};
+
+export { random, quotedPattern };