Repository navigation
[Tests] Cover the theme JSON output schema helpers - #8980
Draft
github-actions[bot] wants to merge 1 commit into
Draft
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This branch has not been deployed
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.
WHY are these changes introduced?
packages/theme/src/cli/services/json-output/schema.tsdefines the shared JSON output contract for the theme commands —themeId,storeDomain,projectThemeanddefineThemeJsonOutputSchemaare imported by 11 theme commands and 18 service types — and has no co-located test. The projection helpers in particular are the layer that decides what leaves the CLI as public JSON, so their guards are a contract rather than incidental validation.Nothing in the repository asserts them directly.
themeIdis never exercised with a GID, a negative number or a non-integer, so itsTypeErrorbranch is dead in tests;storeDomainis never given a non-myshopify.comhost, so the null fallback that hides a custom domain is unverified;projectThemeis never checked for dropping the extra fields that come back on an upstream theme (shop,editor_url,preview_url). A refactor could widen any of these and the whole suite would still pass. The downstream tests that touch this code —push/result.test.ts,info/types.test.ts— assert their own command's shape, not the shared helpers.This is not a flaky-test fix. Reviewing Main tests runs created between 2026-10-15T00:24Z and 2026-10-22T00:24Z UTC (28 runs, all first attempts — I confirmed via the attempts API that none had a rerun hiding an earlier failure) found four failures, all on
windows-latest, all timeouts, reducing to two signatures: the PowerShell record test inapp-security-commands.test.ts(runs 39241753364, 38773610537, 38766274961, 38709303616) and the 32-hex secret test insecret-safety.test.ts(run 38766274961). Both already have open fixes, #8832 and #8928, so no actionable flake remains in the window.WHAT is this pull request doing?
Adds
packages/theme/src/cli/services/json-output/schema.test.tscovering the four exported helpers with table-driven cases.The rejection cases pin
themeIdto both of its failure modes, which are not the same check: a GID or a negative string fails Zod's^\d+$pattern, while-1,1.5andMAX_SAFE_INTEGER + 1fail the numeric guard that runs before the string is ever parsed. ThestoreDomaincases make the regex boundary explicit —a.b.myshopify.comandMy-Shop.myshopify.comboth end inmyshopify.combut are still reported as unavailable, so a looser rewrite using a suffix match would not slip through. FordefineThemeJsonOutputSchemathe tests cover the branch that matters most: acancelledresult must reach the output unprojected in both the single and batched forms, since the command projections assume a real result and would throw on it.The helpers are pure and synchronous, so the test needs no temporary directory and no filesystem access. No production code is changed.
Validation: the new file passes locally on Linux Node 22.20.1 (22 passed), five times under
--sequence.shuffle, and alongside all 30 test files underpackages/theme/src/cli/services(287 passed).nx type-check themeand ESLint on the new file both pass. I confirmed the tests earn their keep by temporarily neutralizing each guard in turn and restoring it: removing the numeric guard and the domain validation and the cancellation passthrough fails 8 cases, and makingprojectThemespread the upstream theme instead of selecting fields fails its case.Remaining uncertainty: the cases named for Windows-shaped input do not exist here — these helpers are plain string and schema matching with no platform branch, so the Linux run covers the same code paths CI will run on macOS and Windows. This PR does not address the two Windows timeouts cited above; those are separate flakes with their own open fixes.
How to manually test your changes?
Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add