Skip to content

Create mocks for the entire Customer Account extension API#3905

Open
kumar303 wants to merge 1 commit into02-12-create_mocks_for_the_entire_point-of-sale_extension_apifrom
02-12-create_mocks_for_the_entire_customer_account_extension_api
Open

Create mocks for the entire Customer Account extension API#3905
kumar303 wants to merge 1 commit into02-12-create_mocks_for_the_entire_point-of-sale_extension_apifrom
02-12-create_mocks_for_the_entire_customer_account_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 Customer Account 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_customer_account_extension_api branch from 8c15ddb to 4a0e80d Compare February 12, 2026 17:57
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 3e06b36 to 072992f Compare February 12, 2026 19:44
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from 4a0e80d to 27fe3a8 Compare February 12, 2026 19:44
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 072992f to 34763c2 Compare February 13, 2026 11:46
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from 27fe3a8 to 8fccf50 Compare February 13, 2026 11:46
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 34763c2 to c11b76b Compare February 13, 2026 11:58
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from 8fccf50 to b6b83e9 Compare February 13, 2026 11:58
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from c11b76b to bb5b1ed Compare February 13, 2026 12:20
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch 3 times, most recently from bab7729 to a303042 Compare February 13, 2026 14:57
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch 2 times, most recently from 344b671 to af00386 Compare February 13, 2026 15:11
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from a303042 to 2db9df6 Compare February 13, 2026 15:11
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from af00386 to 7049f9e Compare February 13, 2026 15:33
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch 2 times, most recently from 6e15cd7 to 83b81e0 Compare February 13, 2026 15:34
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 7049f9e to 1a6144c Compare February 13, 2026 15:34
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from 83b81e0 to 69f7238 Compare February 13, 2026 16:14
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 1a6144c to 62487cd Compare February 13, 2026 16:14
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from 69f7238 to bb90420 Compare February 13, 2026 16:24
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 62487cd to 4fd668d Compare February 13, 2026 16:24
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from bb90420 to 9707ec1 Compare February 13, 2026 22:04
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 4fd668d to d8892b1 Compare February 13, 2026 22:58
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from 9707ec1 to 2b029e3 Compare February 13, 2026 22:58
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from cc4dd82 to d058148 Compare February 24, 2026 11:23
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from e04bdfe to 4c9b881 Compare February 24, 2026 11:23
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from d058148 to e592271 Compare February 24, 2026 11:29
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 4c9b881 to 1ab00cd Compare February 24, 2026 11:29
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from e592271 to 776e604 Compare February 24, 2026 11:53
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 1ab00cd to 724d295 Compare February 24, 2026 11:53
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from 776e604 to d619193 Compare February 24, 2026 14:01
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 724d295 to 2364cea Compare February 24, 2026 14:01
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from d619193 to ec9fbb4 Compare February 24, 2026 14:11
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 2364cea to 6ec4c50 Compare February 24, 2026 14:11
@kumar303 kumar303 marked this pull request as ready for review February 24, 2026 14:27

const customerAccountMockFactories: CustomerAccountMockFactory = {
// StandardApi only
'customer-account.page.render': createStandardApiProperties,
Copy link
Member

Choose a reason for hiding this comment

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

Should we also add the navigation api? https://shopify.dev/docs/api/customer-account-ui-extensions/latest/apis/navigation

navigate is available in all targets, full page extensions have more properties available

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yeah. Is this available for Admin, too? I can't tell.

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 added a mock for all surfaces (on the base branch). Good call, thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Why all surfaces? 😅 Checkout doesn't have it, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if at least two surfaces include it then I think it's good to include it everywhere. We could make navigate() throw an error if the extension under test is in an unsupported target.

@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 6ec4c50 to 32fb2a4 Compare February 24, 2026 15:35
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch 2 times, most recently from 44a456a to f7c9ffa Compare February 24, 2026 16:41
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from 32fb2a4 to a026d49 Compare February 24, 2026 16:41
Copy link
Member

Tried to run tests, but it failed to resolve the package.
Any other commands I gotta run despite yarn in the main package and npm i in the test example app?

 extensions/customer-account-testing-example/tests/OrderStatusBlock.test.ts [ extensions/customer-account-testing-example/tests/OrderStatusBlock.test.ts ]
Error: Failed to resolve entry for package "@shopify/ui-extensions-tester". The package may have incorrect main/module/exports specified in its package.json.
  Plugin: vite:import-analysis
  File: /Users/robindrexler/src/github.com/Shopify/ui-extensions/examples/testing/customer-account-testing-example/extensions/customer-account-testing-example/tests/OrderStatusBlock.test.ts:5:27
  1  |  import { expect, test, beforeEach, afterEach } from "vitest";
  2  |  import { getExtension } from "@shopify/ui-extensions-tester";
     |                                ^
  3  |  const extension = getExtension(
  4  |    "customer-account.order-status.block.render"
 ❯ packageEntryFailure node_modules/vite/dist/node/chunks/config.js:32816:32
 ❯ resolvePackageEntry node_modules/vite/dist/node/chunks/config.js:32813:2
 ❯ tryNodeResolve node_modules/vite/dist/node/chunks/config.js:32716:70
 ❯ ResolveIdContext.handler node_modules/vite/dist/node/chunks/config.js:32555:16
 ❯ EnvironmentPluginContainer.resolveId node_modules/vite/dist/node/chunks/config.js:28717:56
 ❯ TransformPluginContext.resolve node_modules/vite/dist/node/chunks/config.js:28929:13
 ❯ normalizeUrl node_modules/vite/dist/node/chunks/config.js:27111:22
 ❯ node_modules/vite/dist/node/chunks/config.js:27177:32

Copy link
Contributor Author

Hmm, this is working for me. Is this what you did?

yarn build
pushd examples/testing/customer-account-testing-example
npm install
npm test

@robin-drexler
Copy link
Member

Hmm, this is working for me. Is this what you did?

yarn build
pushd examples/testing/customer-account-testing-example
npm install
npm test

ah nope, didn't run the yarn build step. 🤦‍♂️ Thanks

@robin-drexler
Copy link
Member

Not sure if expected, after running yarn, I have diff in the yarn.lock

diff --git a/yarn.lock b/yarn.lock
index ecd4402ac..9094c8db4 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2024,6 +2024,13 @@
   resolved "https://registry.npmjs.org/@shopify/typescript-configs/-/typescript-configs-5.1.0.tgz"
   integrity sha512-RywGBTR+nQyJLxcrUcihPkHPIG3pIQI6i0YwMrM5rs9nWJ0+9A5HKEcboyGPLH+8V08EXGfFQ6H820O9ajyk4A==

+"@shopify/ui-extensions@*":
+  version "2026.1.2"
+  resolved "https://npm.shopify.io/node/@shopify/ui-extensions/-/ui-extensions-2026.1.2.tgz#2599a6bf6063640f467a3c3ff2ab80afbd2de9d0"
+  integrity sha512-lngck7uPBcpMrL36cw/7NJCBsagIleB6dw/hrxEtW600PdPoOUoUyhOnsjM4J5NCheNGD4Ar2h/a0zh2ki9QXw==
+  dependencies:
+    ts-morph "^25.0.1"
+
 "@sinclair/typebox@^0.24.1":
   version "0.24.51"
   resolved "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.51.tgz"

@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from f7c9ffa to b8004e1 Compare February 25, 2026 15:10
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_point-of-sale_extension_api branch from a026d49 to 68598b8 Compare February 25, 2026 15:10
@robin-drexler
Copy link
Member

@kumar303 why did you choose to have all those examples be packages that use npm and handle their own locks etc?

Why not make them part of the workspaces for easier dependency management?

Copy link
Contributor Author

I updated all the example readmes to specify the build step. As for yarn.lock, that's probably because you're not at the top of the stack. I might have to fix yarn.local after it all merges anyway.

Copy link
Contributor Author

Why not make them part of the workspaces

probably no good reason. I didn't think I could make nested example directories part of the workspace.

Copy link
Contributor Author

and yarn is weird

Copy link
Member

@robin-drexler robin-drexler 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 amazing. I haven't (yet) looked into how the sausage is made exactly, but the test experience looks good at a glance!

);

beforeEach(() => {
extension.setUp();
Copy link
Member

Choose a reason for hiding this comment

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

nit: why not setup?

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.

2 participants