Skip to content

fix: keep store stories and Jest mocks out of the .faststore type-check - #3477

Merged
eduardoformiga merged 1 commit into
devfrom
fix/cli-storefront-tsconfig-stories
Sep 3, 2026
Merged

eduardoformiga merged 1 commit into
devfrom
fix/cli-storefront-tsconfig-stories

Conversation

@eduardoformiga

@eduardoformiga eduardoformiga commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

What's the purpose of this pull request?

Follow-up to #3459 (test files being type-checked inside .faststore).

next build type-checks everything included by .faststore/tsconfig.json. #3459 stopped copying the core unit tests and excluded *.test.* / __tests__, but stores also keep Storybook stories (*.stories.tsx) and Jest manual mocks (__mocks__/) next to their components under src/. That folder is copied into .faststore/src/customizations/src, so the build compiled those files against dev-only dependencies (@storybook/*, @jest/globals) and failed.

Validated against a real v3 store being migrated to v4 (on top of #3476): 331 type errors → 13; the 316 removed were all in the store's own *.stories.tsx / __mocks__. The remaining 13 are genuine v3 → v4 migration items in the store code (deep @faststore/sdk/dist/... imports, changed core internals, @types/react 19 hoisted).

How it works?

STOREFRONT_TEST_EXCLUDE_GLOBS (merged into the exclude of the tsconfig written to .faststore) gains **/*.stories.ts, **/*.stories.tsx and **/__mocks__/**. Files are still copied — nothing changes for the store's own tooling — they just stop being part of the Next type-check program. Story files are never imported by application code, so no build output changes.

How to test it?

  • cd packages/cli && pnpm test (storefrontCopy.test.ts asserts the new globs).
  • In a store with src/**/*.stories.tsx importing @storybook/react, run yarn build with this CLI: the generated .faststore/tsconfig.json lists the new excludes and Running TypeScript ... no longer reports the stories.

Starters Deploy Preview

Pending CodeSandbox / pkg.pr.new build for this PR.

References

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes
    • Storefront builds now exclude Storybook stories and Jest manual-mock directories from test-related processing.

…e-check

`next build` type-checks everything the `.faststore/tsconfig.json` includes.
Stores keep `*.stories.tsx` and `__mocks__/` next to their components under
`src/`, which is copied into `.faststore/src/customizations/src`, so the build
compiled them against dev-only dependencies (`@storybook/*`, `@jest/globals`)
and failed. Validated with the Whirlpool monorepo: 316 of the 331 type errors
in its v4 build came from its own stories.

Extend the exclude globs added in #3459 for test files to cover stories and
manual mocks as well.
@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 91bba8c2-d490-4e58-af05-e01d5a270748

📥 Commits

Reviewing files that changed from the base of the PR and between cc7941a and 2caafc1.

📒 Files selected for processing (2)
  • packages/cli/src/utils/storefrontCopy.test.ts
  • packages/cli/src/utils/storefrontCopy.ts

Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


Walkthrough

The storefront TypeScript configuration now excludes Storybook story files and Jest manual-mock directories. Tests verify these exclusions and preserve the configured exclude list.

Changes

Storefront test exclusions

Layer / File(s) Summary
Configure and validate exclusion globs
packages/cli/src/utils/storefrontCopy.ts, packages/cli/src/utils/storefrontCopy.test.ts
STOREFRONT_TEST_EXCLUDE_GLOBS excludes Storybook stories and Jest manual mocks. Tests verify the generated configuration and retain existing exclusions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 2caaf

This localized CLI change excludes store stories and Jest mocks from the Faststore type-check while preserving them for store tooling; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: excluding store stories and Jest mocks from the .faststore TypeScript check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cli-storefront-tsconfig-stories

Comment @coderabbitai help to get the list of available commands.

@eduardoformiga eduardoformiga changed the title fix(cli): keep store stories and Jest mocks out of the .faststore type-check fix: keep store stories and Jest mocks out of the .faststore type-check Sep 2, 2026
@eduardoformiga
eduardoformiga marked this pull request as ready for review September 2, 2026 21:11
@eduardoformiga
eduardoformiga requested a review from a team as a code owner September 2, 2026 21:11
@eduardoformiga
eduardoformiga requested review from lucasfp13 and renatamottam and removed request for a team September 2, 2026 21:11
@sonar-workflows

Copy link
Copy Markdown

@eduardoformiga
eduardoformiga merged commit 1509019 into dev Sep 3, 2026
18 of 21 checks passed
@eduardoformiga
eduardoformiga deleted the fix/cli-storefront-tsconfig-stories branch September 3, 2026 19:30
eduardoformiga added a commit that referenced this pull request Sep 8, 2026
)

## What's the purpose of this pull request?

A store cloned under a directory whose name contains a space (e.g.
`/Users/me/My Store/store`, `C:\Users\John Doe\...`) cannot run
`faststore build` / `faststore dev` / `faststore generate`:

```
[STARTED] Load GraphQL documents
[FAILED] Failed to load documents from /Users/me/My Store/store/.faststore/src/**/*.{ts,tsx},!/Users/me/My Store/store/.faststore/@generated/:
[FAILED] Failed to parse the GraphQL document. Syntax Error: Unexpected character: "/".
```

This had been assumed fixed by #3454 — it is not: #3454 fixed the `next`
binary resolution, this is a different failure in the GraphQL codegen
step. Reproduced on `4.6.0` and on `dev` (`4.7.1-dev.2`) with a real
Yarn 1 workspaces store cloned under a path with a space.

Root cause: `generate-types.ts` passed the codegen `documents` glob and
the `generates` output dir as **absolute paths**. `@graphql-tools/load`
(`isDocumentString`) treats any pointer that contains whitespace and is
not parseable SDL as a broken inline document and throws instead of
falling through to the glob loader. The `@graphql-codegen/client-preset`
also appends `!<outputDir>` to the documents, so the output dir hit the
same check.

## How it works?

- New `getCodegenPointers(root, cwd = process.cwd())` builds the
`documents` glob, the `schema` path and the output dir **relative to the
directory codegen resolves pointers from**, so the parent directories
(where the space lives) are never part of the pointer:
- `.faststore/src/**/*.{ts,tsx}` /
`.faststore/@generated/schema.graphql` / `.faststore/@generated/`
- Glob-special characters in the relative segments are still escaped
(`globby.convertPathToPattern`, same approach as #3454 for the typeDefs
glob); the schema and output dir are plain paths, not globs, so they are
not escaped.
- Symlinks are resolved on both sides (`/var` → `/private/var` on macOS)
so the relative path does not climb back through the parents.
- `genTsTypes` now awaits the codegen run (it was fire-and-forget).
- CLI `vitest.config.ts`: alias `graphql` to its CJS build. The code
under test and the externalized `@graphql-tools/*` otherwise load two
`graphql` instances and fail `instanceof` checks ("Duplicate graphql
modules"), which made an end-to-end test of the generator impossible.

No behaviour change for paths without spaces: the same files are matched
and written, only the pointer form changes.

## How to test it?

- `cd packages/cli && pnpm test` — 177 tests. New in
`generate-types.test.ts`:
- `getCodegenPointers` never embeds the absolute project path, targets
`.faststore` when present, escapes glob-special characters only in the
glob.
- `genTsTypes` end-to-end from a store under `<tmp>/faststore gen (x86)
XXXX/store`: merges a custom `thirdParty` typeDef and generates
`graphql.ts` containing the query type.
- Manual: clone any store into a directory with a space, install this
CLI build and run `yarn build`. On `dev` it fails at "Load GraphQL
documents"; with this branch the generate step completes.

### Starters Deploy Preview

Pending CodeSandbox / pkg.pr.new build for this PR.

## References

- #3454 (`next` binary resolution — different issue, same symptom
family)
- Companion PRs (independent): #3474, #3475, #3477

Made with [Cursor](https://cursor.com)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved CLI TypeScript type generation for projects located in paths
containing spaces, special characters, or symlinks.
  * Ensured type generation completes reliably before the CLI proceeds.

* **Tests**
* Expanded automated coverage for schema discovery, path handling, and
generated TypeScript output.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
hellofanny added a commit that referenced this pull request Sep 15, 2026
## What's the purpose of this pull request?

Graduation of the `dev` prerelease cycle (`4.8.0-dev.8`) into a stable
`4.8.0` release on `main`. Merging this PR triggers the `release` CD
workflow, which runs `lerna version --conventional-graduate
--force-conventional-graduate` and publishes all 8 `@faststore/*`
packages under the `latest` dist-tag.

The bump is decided by the Conventional Commits accumulated on `dev`
(`feat:` → **minor** `4.8.0`). No unmerged hotfixes on `main`.

## How it works?

No new product code in this PR itself — it is the merge of `dev` into
`main`. After merge, CD graduates `4.8.0-dev.8` → `4.8.0`.

### Highlights (features)

* feat(core): add mini cart recommendation shelf
([#3466](#3466))
* feat(api): export `validateUserAuthentication` and `getAuthCookie`
([#3481](#3481))

### Fixes

* fix(core): align the saved-cards list with the design reference
([#3487](#3487))
* fix: stop retrying upstream 429 responses
([#3453](#3453))
* fix: normalize outputFileTracingRoot to forward slashes on Windows
([#3484](#3484))
* fix: forward contentSource.project as --storeId in cms-sync CP flow
([#3482](#3482))
* fix: generate GraphQL types when the project path contains spaces
([#3476](#3476))
* fix: keep store stories and Jest mocks out of the .faststore
type-check ([#3477](#3477))
* fix(api): export Resolver, GraphqlContext and helper types from the
public entry ([#3474](#3474))
* fix: stop forwarding unvalidated ni output to the shell in the CLI
([#3422](#3422))
* fix: point localized canonical and hreflang at the rendered locale
([#3470](#3470))

## Packages published (latest)

`@faststore/{api,cli,components,core,diagnostics,lighthouse,sdk,ui}` →
`4.8.0`

## How to test it?

* CI green on this PR
* After merge, `release` workflow succeeds on `main`
* All 8 packages report `4.8.0` under the `latest` dist-tag on npm
* Back-merge `main` → `dev` to open the next dev cycle

## Checklist

**PR Title and Commit Messages**

* PR title and commit messages follow the Conventional Commits
specification

**PR Description**

* Added a label according to the PR goal

**Dependencies**

* No extra lockfile changes in this graduation PR

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added configurable product recommendations to the cart drawer,
including campaign selection, carousel options, titles, and product-card
customization.
* Added public authentication utilities, GraphQL types, and resolver
typings.
* **Bug Fixes**
* Improved localized canonical and hreflang URLs across storefront
pages.
  * Prevented automatic retries for rate-limit responses.
* Improved CLI handling of package managers, Windows paths, spaces, and
CMS Sync store IDs.
* **Documentation**
  * Updated package changelogs and recommendation-shelf guidance.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Válber Laux <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: Thiago Pereira <[email protected]>
Co-authored-by: eduardoformiga <[email protected]>
Co-authored-by: vtexgithubbot <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Larícia Mota <[email protected]>
Co-authored-by: Arthur Andrade <[email protected]>
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.

2 participants