Skip to content

chore: test coverage sonarqube - #3319

Merged
lemagnetic merged 19 commits into
devfrom
chore/test-coverage-sonarqube
May 15, 2026
Merged

lemagnetic merged 19 commits into
devfrom
chore/test-coverage-sonarqube

Conversation

@lemagnetic

@lemagnetic lemagnetic commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

Sets up the SonarQube quality gate for FastStore. This is the foundation for "Clean as You Code" enforcement on new code: the monorepo now produces aggregated test coverage and runs a Sonar scan on every PR.

How it works?

  • Coverage: each tested package (api, cli, components, core, sdk) generates LCOV via Vitest (@vitest/coverage-v8, pinned in pnpm-workspace.yaml catalog) through a new test:coverage Turbo task.
  • Aggregation: a root ci:dkcicd script runs build → lint → size → test:coverage sequentially (avoids esbuild OOM) and merges all per-package LCOVs into coverage/lcov.info with lcov-result-merger.
  • Pipeline: .vtex/deployment.yaml runs node-ci-v2 on PRs (amd64, Node 24, pnpm), pointing at sonarqube.vtex.systems with gitBaseBranchName: dev so "New Code" is compared against the right base.

Summary by CodeRabbit

  • Tests

    • Added code coverage reporting across packages (unit & integration) and a new comprehensive test suite for the Toast component with accessibility checks.
  • Chores

    • Improved test scripts/configuration to consolidate coverage outputs and made a minor internal typing alignment for toast timeouts.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a1bf4c5a-d32e-4313-b2cc-1a3e7132b9cf

📥 Commits

Reviewing files that changed from the base of the PR and between d4cc5af and 4f0df57.

⛔ Files ignored due to path filters (7)
  • .github/workflows/ci.yml is excluded by none and included by none
  • .vtex/deployment.yaml is excluded by none and included by none
  • package.json is excluded by none and included by none
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml and included by none
  • pnpm-workspace.yaml is excluded by none and included by none
  • sonar-project.properties is excluded by none and included by none
  • turbo.json is excluded by none and included by none
📒 Files selected for processing (12)
  • packages/api/package.json
  • packages/api/vitest.config.ts
  • packages/cli/package.json
  • packages/cli/vitest.config.ts
  • packages/components/package.json
  • packages/components/src/molecules/Toast/Toast.tsx
  • packages/components/test/molecules/Toast/Toast.test.tsx
  • packages/components/vitest.config.mts
  • packages/core/package.json
  • packages/core/vitest.config.ts
  • packages/sdk/package.json
  • packages/sdk/vitest.config.mts
✅ Files skipped from review due to trivial changes (5)
  • packages/components/src/molecules/Toast/Toast.tsx
  • packages/components/vitest.config.mts
  • packages/cli/package.json
  • packages/components/package.json
  • packages/api/vitest.config.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/core/vitest.config.ts
  • packages/sdk/package.json
  • packages/core/package.json
  • packages/sdk/vitest.config.mts
  • packages/cli/vitest.config.ts
  • packages/components/test/molecules/Toast/Toast.test.tsx
  • packages/api/package.json

Walkthrough

Adds Vitest v8 coverage configuration and test:coverage scripts across API, CLI, Core, Components, and SDK packages; updates devDependencies. Separately, aligns Toast timeoutRef typing and adds a comprehensive Toast test suite with accessibility checks.

Changes

Vitest Coverage Infrastructure Setup

Layer / File(s) Summary
API package coverage with merged LCOV reports
packages/api/package.json, packages/api/vitest.config.ts
Coverage scripts output integration/unit reports into ./coverage/int and ./coverage/unit, test:coverage merges LCOV files into coverage/lcov.info, and @vitest/coverage-v8 added.
Coverage setup for CLI, Core, Components, SDK
packages/cli/package.json, packages/cli/vitest.config.ts, packages/core/package.json, packages/core/vitest.config.ts, packages/components/package.json, packages/components/vitest.config.mts, packages/sdk/package.json, packages/sdk/vitest.config.mts
Adds test:coverage scripts, @vitest/coverage-v8 devDependency, and uniform test.coverage blocks using the v8 provider with text/lcov reporters, ./coverage output, src/** include and test/spec/dist exclusions.

Toast Component TypeScript Safety and Test Coverage

Layer / File(s) Summary
Toast timeoutRef type alignment
packages/components/src/molecules/Toast/Toast.tsx
Changes timeoutRef type from number to ReturnType<typeof setTimeout>.
Toast component test suite
packages/components/test/molecules/Toast/Toast.test.tsx
Adds tests for empty rendering, single toast with role="status", title and message rendering, custom icon rendering, latest-only behavior for multiple toasts, and an accessibility check using vitest-axe.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • ommeirelles
  • eduardoformiga
  • hellofanny

"Coverage flags unfurled, tests take flight,
Toast waits with timers typed just right.
LCOVs merge and axe gives a nod,
Metrics hum along — code and tests applaud.
🚀🎉"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: test coverage sonarqube' is directly related to the main change: implementing test coverage infrastructure with SonarQube integration across the monorepo.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 chore/test-coverage-sonarqube

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codesandbox-ci

codesandbox-ci Bot commented May 13, 2026 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@pkg-pr-new

pkg-pr-new Bot commented May 13, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@faststore/api

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/cli

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/components

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/core

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/diagnostics

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/lighthouse

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/sdk

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

@faststore/ui

yarn add https://pkg.pr.new/vtex/faststore/@faststore/[email protected]

commit: 5b19043

@lemagnetic lemagnetic changed the title test coverage sonarqube chore: test coverage sonarqube May 13, 2026
@lemagnetic
lemagnetic marked this pull request as ready for review May 14, 2026 19:57
@lemagnetic
lemagnetic requested a review from a team as a code owner May 14, 2026 19:57
@lemagnetic
lemagnetic requested review from eduardoformiga and hellofanny and removed request for a team May 14, 2026 19:57

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/components/src/molecules/Toast/Toast.tsx`:
- Line 8: The timeoutRef in Toast is currently created as
useRef<ReturnType<typeof setTimeout>>() without an explicit initial value;
update it to explicitly initialize with undefined and include undefined in the
type so it matches the codebase pattern (e.g., useRef<ReturnType<typeof
setTimeout> | undefined>(undefined)) — change the timeoutRef declaration inside
the Toast component accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5a3e837f-0dd4-4fae-b9ce-b9a6950c275e

📥 Commits

Reviewing files that changed from the base of the PR and between 8baa617 and d4cc5af.

⛔ Files ignored due to path filters (7)
  • .github/workflows/ci.yml is excluded by none and included by none
  • .vtex/deployment.yaml is excluded by none and included by none
  • package.json is excluded by none and included by none
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml and included by none
  • pnpm-workspace.yaml is excluded by none and included by none
  • sonar-project.properties is excluded by none and included by none
  • turbo.json is excluded by none and included by none
📒 Files selected for processing (13)
  • packages/api/package.json
  • packages/api/vitest.config.ts
  • packages/cli/package.json
  • packages/cli/vitest.config.ts
  • packages/components/package.json
  • packages/components/src/molecules/Toast/Toast.tsx
  • packages/components/test/molecules/Toast/Toast.test.tsx
  • packages/components/vitest.config.mts
  • packages/core/package.json
  • packages/core/tsconfig.tsbuildinfo
  • packages/core/vitest.config.ts
  • packages/sdk/package.json
  • packages/sdk/vitest.config.mts

const { toasts, popToast } = useUI()
const toast = toasts[toasts.length - 1]
const timeoutRef = useRef<number>()
const timeoutRef = useRef<ReturnType<typeof setTimeout>>()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether this repo is on React/@types/react 19 and locate zero-arg useRef calls.
set -euo pipefail

echo "== React version hints in manifests =="
rg -n --iglob 'package.json' '"react"|"@types/react"'

echo
echo "== Zero-arg useRef calls in TS/TSX files =="
rg -nP --type-add 'ts:*.ts' --type-add 'tsx:*.tsx' --type ts --type tsx '\buseRef\s*(<[^>]+>)?\s*\(\s*\)' -g '!**/node_modules/**'

Repository: vtex/faststore

Length of output: 1124


🏁 Script executed:

#!/bin/bash
# Check if the file exists and read its content around line 8
if [ -f "packages/components/src/molecules/Toast/Toast.tsx" ]; then
  echo "=== Toast.tsx file exists ==="
  sed -n '1,20p' packages/components/src/molecules/Toast/Toast.tsx | cat -n
else
  echo "Toast.tsx NOT FOUND at specified path"
  # Search for Toast component
  fd -t f "Toast\.tsx" packages/components/src/molecules/
fi

echo
echo "=== Checking root manifest for React version ==="
head -100 package.json | grep -A 50 '"versions":\|"catalog":\|"react"'

Repository: vtex/faststore

Length of output: 767


🏁 Script executed:

#!/bin/bash
# Find version catalog - might be in different location
echo "=== Searching for version catalog ==="
find . -name "*.json" -type f -not -path "*/node_modules/*" | xargs grep -l '"react":' | head -5

echo
echo "=== Check pnpm-workspace or root package.json structure ==="
jq '.pnpm.overrides // .versions // .devDependencies.react // .dependencies.react // empty' package.json 2>/dev/null || echo "Catalog/versions not in root"

echo
echo "=== Check pnpm-lock for resolved React version ==="
if [ -f "pnpm-lock.yaml" ]; then
  rg 'react@' pnpm-lock.yaml | head -5
else
  echo "No pnpm-lock.yaml found"
fi

echo
echo "=== Check tsconfig for strict mode ==="
jq '.compilerOptions.strict' tsconfig.json 2>/dev/null || cat tsconfig.json | head -30

Repository: vtex/faststore

Length of output: 658


🏁 Script executed:

#!/bin/bash
# Check if the project builds successfully
echo "=== Check if project has build/compile script ==="
jq '.scripts | keys[] | select(contains("build") or contains("compile") or contains("check") or contains("type"))' package.json 2>/dev/null | head -10

echo
echo "=== Check TypeScript config strictness ==="
cat tsconfig.json | jq '.compilerOptions | {strict, noUncheckedIndexedAccess, strictNullChecks, strictFunctionTypes}'

echo
echo "=== Check React 18 useRef types in `@types/react` 18.3.28 docs ==="
# Look at how other components in the codebase use useRef to understand current patterns
rg -A2 'useRef<.*>\(\)' packages/components/src/ --type tsx | head -40

Repository: vtex/faststore

Length of output: 408


🏁 Script executed:

#!/bin/bash
# Search for useRef usage patterns in tsx files correctly
echo "=== Actual useRef patterns in components ==="
rg 'useRef' packages/components/src/molecules/ --type-add 'tsx:*.tsx' -A1 | head -50

echo
echo "=== Check if build works and look for compilation errors ==="
# Check if there are any TypeScript compilation checks in CI or scripts
if [ -f "pnpm-workspace.yaml" ]; then
  echo "pnpm workspace detected"
  head -20 pnpm-workspace.yaml
fi

# Look at the Toast component more carefully
echo
echo "=== Full context of Toast.tsx useRef line ==="
sed -n '1,30p' packages/components/src/molecules/Toast/Toast.tsx | cat -n

Repository: vtex/faststore

Length of output: 4920


Initialize useRef explicitly for consistency with codebase patterns.

Toast is the only component initializing useRef without an explicit value. All other molecules in this folder explicitly provide an initial value (e.g., useRef<HTMLButtonElement>(null)). Explicitly initializing with undefined aligns with the rest of the codebase and clarifies intent.

Suggested patch
-  const timeoutRef = useRef<ReturnType<typeof setTimeout>>()
+  const timeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const timeoutRef = useRef<ReturnType<typeof setTimeout>>()
const timeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/components/src/molecules/Toast/Toast.tsx` at line 8, The timeoutRef
in Toast is currently created as useRef<ReturnType<typeof setTimeout>>() without
an explicit initial value; update it to explicitly initialize with undefined and
include undefined in the type so it matches the codebase pattern (e.g.,
useRef<ReturnType<typeof setTimeout> | undefined>(undefined)) — change the
timeoutRef declaration inside the Toast component accordingly.

@eduardoformiga eduardoformiga left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nicee! approves but I left some minor comments.

too much noise in the GH checks:
Screenshot 2026-05-14 at 17 45 44

can we only keep this?
Screenshot 2026-05-14 at 17 45 50

Comment thread packages/core/tsconfig.tsbuildinfo Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we need to commit it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

noooo, it was an accident

Comment thread sonar-project.properties
@@ -0,0 +1,19 @@
sonar.projectKey=vtex_faststore_f0a862d5-9557-49f9-8d09-de40caa76622

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not sure if this should be here or in some env var

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is not sensitive information

@lemagnetic
lemagnetic force-pushed the chore/test-coverage-sonarqube branch from d4cc5af to 4f0df57 Compare May 15, 2026 16:12
@sonar-workflows

Copy link
Copy Markdown

@lemagnetic
lemagnetic merged commit 925323b into dev May 15, 2026
9 checks passed
@lemagnetic
lemagnetic deleted the chore/test-coverage-sonarqube branch May 15, 2026 16:43
@eduardoformiga eduardoformiga mentioned this pull request May 15, 2026
1 of 3 tasks
eduardoformiga added a commit that referenced this pull request May 15, 2026
## Summary

Graduation PR from `dev` to `main`. Promotes the `4.1.0-dev.10`
prerelease cycle to the next stable, expected `4.1.1` (only `fix:` and
`chore:` commits since `4.1.0`).

### Notable changes since 4.1.0

- fix: region slider section render (#3318)
- fix: allow_all_components for CMS (#3312)
- chore: test coverage sonarqube (#3319)
- chore: bump next.js to 16.2.6 (#3327)
- chore: phase 4 — split AGENTS.md, add MCP config and spec-kit check
(#3320)
- chore: Update repo read me files (#3314)
- Dark Kitchen Catalog Setup (#3317)

### Back-merge

`main` was back-merged into `dev` (`3d4d24081`) before this PR to bring
in the `4.1.0` release commit and avoid silent overwrites. Conflicts
were resolved in favor of `dev` for code/CMS/version files, with
`CHANGELOG` entries merged from both sides.

## Test plan

- [x] dev CD published `4.1.0-dev.10` on the `dev` dist-tag for all 8
packages
- [ ] After merge, main CD graduates to `4.1.1` on the `latest` dist-tag
- [ ] All 8 packages publish (api, cli, components, core, diagnostics,
lighthouse, sdk, ui)


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

---------

Co-authored-by: Larícia Mota <[email protected]>
Co-authored-by: Matheus P. Silva <[email protected]>
Co-authored-by: Leandro Rodrigues <[email protected]>
Co-authored-by: vtexgithubbot <[email protected]>
Co-authored-by: Lucas Feijó <[email protected]>
Co-authored-by: Luiz Falcão <[email protected]>
Co-authored-by: Artur Santiago <[email protected]>
Co-authored-by: Sahan Jayawardana <[email protected]>
Co-authored-by: Mateus Pontes <[email protected]>
Co-authored-by: Matheus Martins <[email protected]>
Co-authored-by: renatomaurovtex <[email protected]>
Co-authored-by: Leandro Rodrigues <[email protected]>
Co-authored-by: Fanny Chien <[email protected]>
Co-authored-by: Arthur Andrade <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Thiago Pereira <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Giuliana Rigaud <[email protected]>
Co-authored-by: renato <[email protected]>
Co-authored-by: Bruna Santos <[email protected]>
Co-authored-by: BrunaCubos <[email protected]>
Co-authored-by: Ícaro Oliveira <[email protected]>
Co-authored-by: Bruna Santos <[email protected]>
Co-authored-by: Everton Ataide <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Otavio Moreira Meirelles <[email protected]>
Co-authored-by: Marco Cardoso <[email protected]>
Co-authored-by: Gabriel Paladino <[email protected]>
Co-authored-by: CodeRabbit <[email protected]>
Co-authored-by: dk-portal[bot] <134092483+dk-portal[bot]@users.noreply.github.com>
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.

3 participants