Skip to content

Create mocks for the entire Admin extension API#3914

Merged
kumar303 merged 1 commit into2026-04-rcfrom
02-12-create_mocks_for_the_entire_admin_extension_api
Mar 12, 2026
Merged

Create mocks for the entire Admin extension API#3914
kumar303 merged 1 commit into2026-04-rcfrom
02-12-create_mocks_for_the_entire_admin_extension_api

Conversation

@kumar303
Copy link
Copy Markdown
Contributor

@kumar303 kumar303 commented Feb 12, 2026

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

👁️ How to review this PR

Copy link
Copy Markdown
Contributor Author

kumar303 commented Feb 12, 2026

@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_admin_extension_api branch from 4c628d8 to b85e478 Compare February 13, 2026 11:46
@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_admin_extension_api branch from b85e478 to 1d61583 Compare February 13, 2026 11:58
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from b6b83e9 to 574013a Compare February 13, 2026 12:20
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_admin_extension_api branch from 1d61583 to 13b040e Compare February 13, 2026 12:20
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from 574013a to bab7729 Compare February 13, 2026 12:24
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_admin_extension_api branch 2 times, most recently from 381b4b0 to 7d9c01d Compare February 13, 2026 12:38
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from bab7729 to a303042 Compare February 13, 2026 14:57
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_admin_extension_api branch 2 times, most recently from 2b2e29f to 51d4649 Compare February 13, 2026 15:11
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch 2 times, most recently from 2db9df6 to 6e15cd7 Compare February 13, 2026 15:33
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_admin_extension_api branch from 51d4649 to 05ae0aa Compare February 13, 2026 15:33
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from 6e15cd7 to 83b81e0 Compare February 13, 2026 15:34
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_admin_extension_api branch 2 times, most recently from 824bdde to 7fe1043 Compare February 13, 2026 16:14
@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_admin_extension_api branch from 7fe1043 to ebd1e09 Compare February 13, 2026 16:24
@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_admin_extension_api branch from ebd1e09 to da03983 Compare February 13, 2026 22:04
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch 2 times, most recently from 9707ec1 to 2b029e3 Compare February 13, 2026 22:58
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_admin_extension_api branch from da03983 to a2036e0 Compare February 13, 2026 22:58
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_admin_extension_api branch 2 times, most recently from f818e9e to 2c24129 Compare February 15, 2026 11:11
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch from 4fb5962 to 2a4b2ee Compare February 15, 2026 11:11
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_admin_extension_api branch 3 times, most recently from 30baf2f to da9aa46 Compare February 15, 2026 21:12
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch 2 times, most recently from 525403d to 6e71146 Compare February 15, 2026 21:15
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_admin_extension_api branch 2 times, most recently from 0dbd881 to a73d9a3 Compare February 15, 2026 21:16
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch 2 times, most recently from 72c73f2 to f40aec8 Compare February 15, 2026 21:17
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_admin_extension_api branch 2 times, most recently from c1fd817 to 472f137 Compare February 15, 2026 22:24
@kumar303 kumar303 force-pushed the 02-12-create_mocks_for_the_entire_customer_account_extension_api branch 2 times, most recently from c54d277 to ce20b48 Compare February 15, 2026 22:26
@kumar303
Copy link
Copy Markdown
Contributor Author

/snapit

7 similar comments
@kumar303
Copy link
Copy Markdown
Contributor Author

/snapit

@kumar303
Copy link
Copy Markdown
Contributor Author

/snapit

@kumar303
Copy link
Copy Markdown
Contributor Author

/snapit

@kumar303
Copy link
Copy Markdown
Contributor Author

/snapit

@kumar303
Copy link
Copy Markdown
Contributor Author

/snapit

@kumar303
Copy link
Copy Markdown
Contributor Author

/snapit

@kumar303
Copy link
Copy Markdown
Contributor Author

/snapit

extensions/*/build
extensions/*/dist

# lock files
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

wouldn't we want to keep them in case someone runs an example with shopify app dev to try it out? I was doing that during development.

Copy link
Copy Markdown
Member

@vividviolet vividviolet left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! I have a few questions

Copy link
Copy Markdown
Member

@vividviolet vividviolet left a comment

Choose a reason for hiding this comment

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

Looks great - just a small fix for the test extension 🙏

Copy link
Copy Markdown
Member

@vividviolet vividviolet left a comment

Choose a reason for hiding this comment

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

Sorry, just one small thing to fix please. Good to go otherwise

function createShouldRenderMock<T extends ExtensionTarget>(target: T) {
return {
...createMockStandardApi(target),
data: createData(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, i just noticed that this always return an empty array. The contract for block and action extensions is that we always return 1 object with id set to a gid. For example, block extensions returngid://shopify/Product/1 . Can you update this to create a mock gid based on the target instead?

Copy link
Copy Markdown
Contributor Author

@kumar303 kumar303 Mar 12, 2026

Choose a reason for hiding this comment

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

I made that change for block and render targets only (per your comment).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If there are other targets that always have one selected GID, I can fix that in a follow-up

});

test('shows the single_product key when one product is selected', async () => {
extension.shopify.data.selected = [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we update the default mock we can delete this override from the test set up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In these examples, the number of selected products are all part of what feature is under test. For that reason, I think it's better to make the test setup explicit per test.

Copy link
Copy Markdown
Contributor Author

kumar303 commented Mar 12, 2026

Merge activity

  • Mar 12, 2:49 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 12, 3:00 PM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 12, 3:02 PM UTC: @kumar303 merged this pull request with Graphite.

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