Create mocks for the entire Admin extension API#3914
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
27fe3a8 to
8fccf50
Compare
4c628d8 to
b85e478
Compare
8fccf50 to
b6b83e9
Compare
b85e478 to
1d61583
Compare
b6b83e9 to
574013a
Compare
1d61583 to
13b040e
Compare
574013a to
bab7729
Compare
381b4b0 to
7d9c01d
Compare
bab7729 to
a303042
Compare
2b2e29f to
51d4649
Compare
2db9df6 to
6e15cd7
Compare
51d4649 to
05ae0aa
Compare
6e15cd7 to
83b81e0
Compare
824bdde to
7fe1043
Compare
83b81e0 to
69f7238
Compare
7fe1043 to
ebd1e09
Compare
69f7238 to
bb90420
Compare
ebd1e09 to
da03983
Compare
9707ec1 to
2b029e3
Compare
da03983 to
a2036e0
Compare
f818e9e to
2c24129
Compare
4fb5962 to
2a4b2ee
Compare
30baf2f to
da9aa46
Compare
525403d to
6e71146
Compare
0dbd881 to
a73d9a3
Compare
72c73f2 to
f40aec8
Compare
c1fd817 to
472f137
Compare
c54d277 to
ce20b48
Compare
|
/snapit |
7 similar comments
|
/snapit |
|
/snapit |
|
/snapit |
|
/snapit |
|
/snapit |
|
/snapit |
|
/snapit |
| extensions/*/build | ||
| extensions/*/dist | ||
|
|
||
| # lock files |
There was a problem hiding this comment.
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.
vividviolet
left a comment
There was a problem hiding this comment.
Thanks for doing this! I have a few questions
examples/testing/admin-testing-example/extensions/admin-testing-example/package.json
Outdated
Show resolved
Hide resolved
examples/testing/admin-testing-example/extensions/admin-testing-example/shopify.extension.toml
Outdated
Show resolved
Hide resolved
examples/testing/admin-testing-example/extensions/admin-testing-example/src/SelectionAction.jsx
Outdated
Show resolved
Hide resolved
...testing/admin-testing-example/extensions/admin-testing-example/tests/SelectionAction.test.ts
Outdated
Show resolved
Hide resolved
examples/testing/admin-testing-example/extensions/admin-testing-example/src/BlockExtension.jsx
Outdated
Show resolved
Hide resolved
vividviolet
left a comment
There was a problem hiding this comment.
Looks great - just a small fix for the test extension 🙏
examples/testing/admin-testing-example/extensions/admin-testing-example/src/SelectionAction.jsx
Outdated
Show resolved
Hide resolved
vividviolet
left a comment
There was a problem hiding this comment.
Sorry, just one small thing to fix please. Good to go otherwise
| function createShouldRenderMock<T extends ExtensionTarget>(target: T) { | ||
| return { | ||
| ...createMockStandardApi(target), | ||
| data: createData(), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I made that change for block and render targets only (per your comment).
There was a problem hiding this comment.
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 = [ |
There was a problem hiding this comment.
If we update the default mock we can delete this override from the test set up
There was a problem hiding this comment.
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.

Follow up to #3899 that adds a complete, type-safe mock of the Admin extension API
👁️ How to review this PR