Skip to content

test(themes): add an MSW mock backend for the store API - #62

Merged
salahmyn merged 4 commits into
feature/quality-gates-twig-parity-auditfrom
feature/SAL-3521-add-msw-mock-backend-for-store-api
Oct 27, 2026
Merged

salahmyn merged 4 commits into
feature/quality-gates-twig-parity-auditfrom
feature/SAL-3521-add-msw-mock-backend-for-store-api

Conversation

@salahmyn

@salahmyn salahmyn commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a shared MSW mock backend for the store API (tests/mocks/), so unit tests, and later Storybook and Playwright, stop hand-rolling per-file mocks.

  • Handlers for the endpoints the engine's api modules request (store settings, products with sources/paging/sort, product details, categories, brands, header/footer menus, blog and articles, cart, current user).
  • Typed factories (product variants: sold out, on sale, options, booking, digital; category, brand, menu item, cart, article, user, currency, store) and scenarios: default, empty store, sold-out product, store with blog, multi-currency.
  • server.ts (node, for vitest/jsdom, opt in with installMockServer()) and browser.ts (worker for Storybook/Playwright).
  • tests/components/home/ProductsSlider.test.tsx now uses the shared handlers and the real engine api client instead of mocking the engine module. tests/mocks/handlers.test.ts exercises the handlers through the engine client.
  • README in tests/mocks/.

Not confirmed

  • Testimonials, reviews, orders, wallet, loyalty, notifications and pages have no handler: the engine types/paths were not verified, so nothing was invented. Real sort values and the real cursor.next format were not confirmed either.
  • createStore fills the fields the theme reads, cast to the engine's Store.
  • Only ProductsSlider was converted (the other engine-api mocking tests assert synchronous call params and are tied to module mocks); Blog's fixtures use shapes that differ from the engine types.

Verification

lint, format:check, typecheck, check:manifest and build exit 0. pnpm test has 4 failures in ProductDetails.test.tsx (localStorage undefined) that also fail on the base branch under Node 26 here; CI pins Node 22. Because of them test:coverage exited 1 locally.

Closes SAL-3521

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; the previous tag-filter issue is fixed and no new blocking issues were found.

Summary

Adds a shared MSW backend with store API handlers, typed factories, and reusable scenarios.

  • Tests and browser demos can use one shared mock store API.
  • The ProductsSlider test checks requests through the engine API client.

Reviews (4) · Last reviewed commit: "test(themes): filter the tags source in ..." · Reviewed by Greptile

Handlers, typed factories and scenarios shared by unit tests, with a node server and a browser worker. ProductsSlider test now uses them.

Made-with: agent
Co-authored-by: mc-agents[bot] <298817976+mc-agents[bot]@users.noreply.github.com>
@salahmyn

Copy link
Copy Markdown
Member Author

@greptileai please review this pull request.

Comment thread tests/mocks/handlers.test.ts Resolved
Comment thread tests/mocks/factories.ts Resolved
@salahmyn

Copy link
Copy Markdown
Member Author

This branch conflicts with the base branch feature/quality-gates-twig-parity-audit, which has moved (CI, knip, F4 and F7 are merged), so CI and the review have not run on it. Please rebase on the base branch, resolve the conflicts (likely package.json and pnpm-lock.yaml), run build, typecheck, lint, format:check, test:coverage, check:manifest and knip, push, and wait for the Greptile review and the Quality gates check to pass.

salahmyn and others added 2 commits October 27, 2026 06:59
Assert the offers source returns a product, and derive a cart item's total from its overridden price.

Made-with: agent
Co-authored-by: mc-agents[bot] <298817976+mc-agents[bot]@users.noreply.github.com>
Made-with: agent
Co-authored-by: mc-agents[bot] <298817976+mc-agents[bot]@users.noreply.github.com>

Copy link
Copy Markdown
Member Author

@greptile-apps please review

@salahmyn

Copy link
Copy Markdown
Member Author

@greptileai review

Comment thread tests/mocks/handlers.ts Resolved
Made-with: agent
Co-authored-by: mc-agents[bot] <298817976+mc-agents[bot]@users.noreply.github.com>
@salahmyn
salahmyn marked this pull request as ready for review October 27, 2026 10:48
@greptile-apps

greptile-apps Bot commented Oct 27, 2026

Copy link
Copy Markdown

Automatic reviews are disabled for this repository.

@salahmyn
salahmyn merged commit c8bf519 into feature/quality-gates-twig-parity-audit Oct 27, 2026
4 checks passed
@salahmyn
salahmyn deleted the feature/SAL-3521-add-msw-mock-backend-for-store-api branch October 27, 2026 10:49
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.

1 participant