Skip to content

[Tests] Cover the language server skip in theme metafields pull - #8955

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
tests-maintenance-39347363624
Draft

github-actions[bot] wants to merge 1 commit into
mainfrom
tests-maintenance-39347363624

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

I first reviewed every Main tests run created between 2026-10-13T00:24Z and 2026-10-20T00:24Z UTC (38 runs). Five failed, all on windows-latest, and every one was a test timeout rather than a build or infrastructure failure. They reduce to two signatures, and both already have an open fix:

With no actionable flake left, this closes a coverage gap instead. theme metafields pull returns {status: 'skipped', reason: 'not-a-theme'} when the directory is not a theme and SHOPIFY_LANGUAGE_SERVER=1, so the language server gets a quick, quiet answer instead of a confirmation prompt. That outcome is in the published JSON schema and is the only one the command can emit with no test: the projection branch for it in services/metafields-pull/types.ts was never executed, and no test in the repository referenced not-a-theme.

WHAT is this pull request doing?

Adds one test to packages/theme/src/cli/commands/theme/metafields/pull.test.ts asserting the contract a language server depends on: the command exits 0, writes exactly {status: 'skipped', reason: 'not-a-theme'} to stdout, keeps stderr empty, and neither prompts for confirmation nor fetches definitions nor writes .shopify/metafields.json. The emitted document is also checked against themeMetafieldsPullJsonOutputSchema, so the skip stays valid under the published schema.

The test runs the real command in a real temporary directory and asserts only its observable output, so the skip can be reimplemented freely. It follows the neighbouring reports cancellation... test, adding no helper and no shared state. vi.stubEnv is undone in a finally because this config does not set unstubEnvs; without it the variable leaks into later tests in the file and four of them fail.

Validation on Linux / Node 26.1.0: the file passes (15 tests), three shuffled runs alongside metafields-pull.test.ts, package.test.ts and profile.test.ts pass (35 each), and the full theme package was run before and after. nx type-check theme and ESLint on the changed file pass. That run leaves 10 pre-existing failures in delete.test.ts, publish.test.ts and rename.test.ts — identical with and without this change (passing count 307 to 308), in files this PR does not touch and unrelated to the Windows timeouts above.

I confirmed the test earns its keep by temporarily collapsing the not-a-theme projection to {status: 'cancelled'}: the new test is the only one that fails, and it alone raises branch coverage of services/metafields-pull/types.ts from 80% to 90%. Remaining uncertainty: it was verified on Linux only, but it starts no subprocess and touches no platform-specific path, so it should not add Windows risk.

How to manually test your changes?

cd "$(mktemp -d)"
SHOPIFY_LANGUAGE_SERVER=1 shopify theme metafields pull --store your-store.myshopify.com --json

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

The not-a-theme skip is the only JSON outcome of `theme metafields pull`
with no test. Asserts the command emits {status, reason}, validates it
against the published schema, and confirms nothing is fetched or written.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

0 participants