Skip to content

fix: harden product service price filters#147

Merged
adm01-debug merged 1 commit into
mainfrom
fix/product-service-price-filters
May 23, 2026
Merged

fix: harden product service price filters#147
adm01-debug merged 1 commit into
mainfrom
fix/product-service-price-filters

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

@adm01-debug adm01-debug commented May 23, 2026

Summary

  • Normalizes product service price bounds with finite-number checks before filtering.
  • Skips price comparisons for non-finite mapped product prices instead of relying on direct JS comparisons.
  • Removes the non-null assertion in category filtering and updates product service tests to use typed Vitest mocks.

Validation

  • npx.cmd eslint src/services/productService.ts src/services/__tests__/productService.test.ts
  • npx.cmd vitest run src/services/__tests__/productService.test.ts
  • git diff --check
  • VITE_SUPABASE_URL=... VITE_SUPABASE_PUBLISHABLE_KEY=... npm.cmd run build

Notes

  • npm.cmd run typecheck:full -- --pretty false did not complete locally after 5 minutes and produced no diagnostic output. The focused lint/test suite and production build passed.

Summary by cubic

Fixes price filtering to ignore NaN/Infinity bounds and non-finite product prices so valid items aren’t dropped. Also normalizes category filtering and updates tests with typed vitest mocks.

  • Bug Fixes
    • Apply min/max only when bounds are finite; skip comparisons for non-finite product prices.
    • Category filter is case-insensitive by name or matches exact id; removed non-null assertion.
    • Tests use vi.mocked and add coverage to ensure invalid price bounds are ignored.

Written for commit a748857. Summary will update on new commits. Review in cubic

Copilot AI review requested due to automatic review settings May 23, 2026 15:02
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Warning

Review limit reached

@adm01-debug, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 2 reviews/hour. Refill in 26 minutes and 31 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b4b99114-344e-4d40-bd7f-27da212fea22

📥 Commits

Reviewing files that changed from the base of the PR and between aa00993 and a748857.

📒 Files selected for processing (2)
  • src/services/__tests__/productService.test.ts
  • src/services/productService.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/product-service-price-filters

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

@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
we-dream-big Ready Ready Preview, Comment May 23, 2026 3:03pm

@supabase
Copy link
Copy Markdown

supabase Bot commented May 23, 2026

This pull request has been ignored for the connected project doufsxqlfjyuvxuezpln because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens productService.fetchProducts client-side filtering by ensuring price bounds and product prices are finite numbers before performing comparisons, and updates the corresponding unit tests to use typed Vitest mocks.

Changes:

  • Normalize minPrice/maxPrice via finite-number checks and only apply filters when bounds are finite.
  • Avoid direct comparisons against non-finite mapped product prices by validating p.price before comparing.
  • Refactor category filtering to remove the non-null assertion and add a test asserting invalid price bounds don’t filter out products.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/services/productService.ts Adds getFiniteNumber and applies finite checks for category and price filtering logic.
src/services/__tests__/productService.test.ts Switches to vi.mocked for typed mocks and adds coverage for invalid price bounds behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 39 to 46
it('should apply search filter', async () => {
await productService.fetchProducts({ search: 'caneca' });
expect(externalDb.fetchPromobrindProducts).toHaveBeenCalledWith(expect.objectContaining({
search: 'caneca'
}));
expect(externalDb.fetchPromobrindProducts).toHaveBeenCalledWith(
expect.objectContaining({
search: 'caneca',
}),
);
});
@adm01-debug adm01-debug merged commit b08997c into main May 23, 2026
28 of 30 checks passed
@adm01-debug adm01-debug deleted the fix/product-service-price-filters branch May 23, 2026 15:23
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