feat(ui-extensions-tester): add shopify.intercept mock and POS event data factories - #4643
Draft
vctrchu wants to merge 1 commit into
Draft
feat(ui-extensions-tester): add shopify.intercept mock and POS event data factories#4643vctrchu wants to merge 1 commit into
vctrchu wants to merge 1 commit into
Conversation
…data factories Assisted-By: devx/c380b28c-ab53-4c64-a5d7-b1e4b72559e9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Stacked on #4641, which adds the POS intercept resolution target types. Extensions registering interceptors via
shopify.intercept()had no way to unit-test their blocking logic: the tester exposed nointercepton the mockshopifyglobal and no way to invoke a registered interceptor.Solution
Mirrors the existing
addEventListener/dispatchpair:shopify.intercept(name, interceptor)on the mock global — same semantics as the sandbox implementation: interceptor must be a function, event name must be a supported intercept event, one interceptor per event, returns an unregister function.extension.fireIntercept(name, data)— invokes the registered interceptor with{type, ...data}(the host payload shape) and returns itsInterceptResult. Returnsundefinedwhen nothing is registered; throws if the interceptor returns a Promise, matching the host's synchronous-only rule.createCartValidationsEventData()andcreatePaymentValidationsEventData()build the payloads forfireIntercept()and double asshopify.resolution.eventvalues on the resolution targets from feat(point-of-sale): add resolution target types for cart and payment validations #4641.createPosCart()is now exported (it was already referenced in the harness docs) and backs the cart event factory.Both READMEs updated per the tester's documentation requirements.
🎩
pos-intercepts.test.tscovering registration rules, unregistration, fire semantics, sync enforcement, and factory defaults — 116 total passingyarn build, eslint, prettier — greenERR_REQUIRE_ESM, pre-existing on the base branch); relying on CI for thoseChecklist