Skip to content

[Tests] Add unit tests for theme batching utilities - #8538

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

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

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

packages/theme/src/cli/utilities/batching.ts had no co-located test. Its two exported helpers chunk theme files before they are sent to the Admin GraphQL API, and three call sites rely on that contract: theme-downloader.ts, theme-environment/theme-polling.ts, and theme-environment/theme-reconciliation.ts. Off-by-one errors in the chunk stride, or in the start index handed to task builders, would silently skip or duplicate theme files during push/pull while every existing test still passed.

WHAT is this pull request doing?

Adds packages/theme/src/cli/utilities/batching.test.ts covering the behavior both call paths depend on:

  • batchedRequests — chunk boundaries with a smaller trailing batch, one promise per batch resolving to the callback result, no callback invocation for empty input, and a single batch when the batch size exceeds the item count.
  • batchedTasks — one task per batch, the index of the first item in each batch passed to the builder (theme-downloader uses it to render download progress), empty input, and that work stays deferred until a task is run.

Test-only; no production code is touched. Verified the assertions fail against mutations to the chunk stride and to the start-index argument, so they would catch a real regression rather than just execute the lines.

How to manually test your changes?

shopify theme pull --store <store> --theme <id>
shopify theme push --store <store> --theme <id>

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

Cover batchedRequests and batchedTasks in packages/theme: chunk
boundaries, the start index handed to task builders, empty input, and
deferred task execution.

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

@Suleimanlatrsh Suleimanlatrsh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tested locally and checked the batch boundaries. The tests catch skipped items and wrong indexes. Looks good 👍

@gonzaloriestra
gonzaloriestra marked this pull request as ready for review September 16, 2026 08:56
@gonzaloriestra
gonzaloriestra requested a review from a team as a code owner September 16, 2026 08:56
@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants