Skip to content

Create mocks for the entire checkout extension API#3902

Open
kumar303 wants to merge 1 commit into02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_from
02-12-create_mocks_for_the_entire_checkout_extension_api
Open

Create mocks for the entire checkout extension API#3902
kumar303 wants to merge 1 commit into02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_from
02-12-create_mocks_for_the_entire_checkout_extension_api

Conversation

@kumar303
Copy link
Contributor

@kumar303 kumar303 commented Feb 12, 2026

Follow up to #3899 that adds a complete, type-safe mock of the checkout extension API

👁️ How to review this PR

Copy link
Contributor Author

kumar303 commented Feb 12, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch from 5c62f76 to d914c44 Compare February 12, 2026 14:41
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch 3 times, most recently from 247ecdf to 844aff7 Compare February 12, 2026 17:23
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch from 844aff7 to c8b1e1c Compare February 12, 2026 19:44
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch 2 times, most recently from 15dff41 to b2a237f Compare February 13, 2026 15:11
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch from 1f8f47e to 562a606 Compare February 13, 2026 15:11
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch from b2a237f to c9897ed Compare February 13, 2026 15:33
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch from 562a606 to a54bddd Compare February 13, 2026 15:33
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch 2 times, most recently from 433f8fd to aa7b07b Compare February 13, 2026 23:00
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch from a54bddd to 07d5a50 Compare February 13, 2026 23:00
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch 3 times, most recently from aea8398 to 604bf1b Compare February 14, 2026 23:28
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch from 07d5a50 to ffbd126 Compare February 14, 2026 23:43
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch 2 times, most recently from ae65d79 to 70c9a6c Compare February 14, 2026 23:57
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch 2 times, most recently from d45cd12 to d71f194 Compare February 15, 2026 11:11
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch 3 times, most recently from 88fa431 to b22ddd7 Compare February 15, 2026 21:17
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch from d71f194 to 8fcac33 Compare February 15, 2026 21:17
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch from 315260c to dd6200e Compare February 23, 2026 15:57
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch 3 times, most recently from 625b7aa to 040affd Compare February 23, 2026 17:25
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch 2 times, most recently from 6062317 to e334238 Compare February 23, 2026 17:34
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch from 040affd to 6fdecec Compare February 23, 2026 17:34
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch from e334238 to 2ea50ce Compare February 24, 2026 10:12
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch 2 times, most recently from 58f1a20 to 8966550 Compare February 24, 2026 10:14
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch from 2ea50ce to a63e953 Compare February 24, 2026 10:49
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch 2 times, most recently from a77c904 to 17937cc Compare February 24, 2026 11:14
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch from a63e953 to 40027b7 Compare February 24, 2026 11:14
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch from 17937cc to f2af9e8 Compare February 24, 2026 11:23
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch 2 times, most recently from b51dc56 to e98803a Compare February 24, 2026 11:29
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch 2 times, most recently from 883ccce to 8751012 Compare February 24, 2026 11:53
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch from e98803a to bdf2921 Compare February 24, 2026 14:01
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_checkout_extension_api branch 2 times, most recently from fc22751 to 5830102 Compare February 24, 2026 14:11
@kumar303 kumar303 force-pushed the 02-11-create_a_testing_library_for_ui-extensions_proof_of_concept_ branch from bdf2921 to 2388be3 Compare February 24, 2026 14:11
@kumar303 kumar303 marked this pull request as ready for review February 24, 2026 14:27
Copy link
Contributor

@jamesvidler jamesvidler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great work! I'd like to see us add some type safety for the targets so we don't get into scenarios where we forget to update the mocks as targets change.

@@ -0,0 +1,29 @@
{
"name": "checkout-basic-testing-example",
"version": "1.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add

"type": "module",

Otherwise I got:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/jkv/src/github.com/Shopify/ui-extensions/examples/testing/checkout-basic-testing-example/node_modules/vite/dist/node/index.js from /Users/jkv/src/github.com/Shopify/ui-extensions/examples/testing/checkout-basic-testing-example/node_modules/vitest/dist/config.cjs not supported.
Instead change the require of index.js in /Users/jkv/src/github.com/Shopify/ui-extensions/examples/testing/checkout-basic-testing-example/node_modules/vitest/dist/config.cjs to a dynamic import() which is available in all CommonJS modules.
    at _require.extensions.<computed> [as .js] (file:///Users/jkv/src/github.com/Shopify/ui-extensions/examples/testing/checkout-basic-testing-example/node_modules/vite/dist/node/chunks/config.js:35920:9)
    at Object.<anonymous> (/Users/jkv/src/github.com/Shopify/ui-extensions/examples/testing/checkout-basic-testing-example/node_modules/vitest/dist/config.cjs:5:12)
    at _require.extensions.<computed> [as .js] (file:///Users/jkv/src/github.com/Shopify/ui-extensions/examples/testing/checkout-basic-testing-example/node_modules/vite/dist/node/chunks/config.js:35920:9) {
  code: 'ERR_REQUIRE_ESM'
}

When running the tests in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. So weird.

const checkoutMockFactories: Partial<CheckoutMockFactory> = {
// CheckoutApi & StandardApi
'purchase.checkout.actions.render-before': createCheckoutStandardMock,
'Checkout::Actions::RenderBefore': createCheckoutStandardMock,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we need to support the legacy targets here? I thought we removed these types from the library in latest versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, these snuck in. The types weren't removed from the library because it was too hard to support removal in checkout-web when I tried. Maybe we should ask River to try it again :thinking_face:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to leave them in for now since the typing is exhaustive.

Comment on lines +19 to +36
extension.shopify.lines.value = [
createCartLine({quantity: 2}),
createCartLine({
id: 'gid://shopify/CartLine/2',
merchandise: {
type: 'variant',
id: 'gid://shopify/ProductVariant/99',
title: 'Large Widget',
selectedOptions: [],
product: {
id: 'gid://shopify/Product/42',
vendor: 'Acme',
productType: 'widget',
},
requiresShipping: true,
},
}),
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this also set the .current internally that we expose for backwards compatibility? Or, do we still expose that - I haven't used remote-dom too much lately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we don't document that. We should have just removed it entirely. That was probably a mistake. We don't need to support it in the mocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants