tests: add tests for mail, url, and rule validation utilities#1235
tests: add tests for mail, url, and rule validation utilities#1235
Conversation
Add 83 new tests covering critical utility functions: - mail.test.ts: email parsing, content extraction, HTML conversion - url.test.ts: provider-specific URL building for Gmail/Outlook - rule.validation.test.ts: Zod schema validation for rules Also fixes whitespace-only name validation in rule schema and removes ineffective default from conditionalOperator field. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds many new unit tests for web utilities (rules, mail, URLs, templates, text, action items, action sorting, parsing). Also a minor rule validation schema change: Changes
Sequence Diagram(s)(omitted — changes are tests and small schema/utility tweaks; no new multi-component control flow to diagram) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="apps/web/utils/mail.test.ts">
<violation number="1" location="apps/web/utils/mail.test.ts:230">
P2: Test asserts that result contains the new message but doesn't verify that quoted content is actually stripped, as the comment claims. Add an assertion like `expect(result).not.toContain("Old quoted content")` to verify the core functionality.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @apps/web/utils/url.test.ts:
- Around line 60-68: getProviderConfig currently only falls back when provider
is undefined, so PROVIDER_CONFIG[unknownKey] becomes undefined and later calls
like config.buildUrl in getEmailUrl throw; update getProviderConfig to guard
against missing keys by resolving the provider key then defaulting to
PROVIDER_CONFIG["default"] when the lookup returns undefined (e.g., compute a
resolvedKey = provider ?? "default" then return PROVIDER_CONFIG[resolvedKey] ??
PROVIDER_CONFIG["default"]) so unknown provider strings fall back to the default
config.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.tsapps/web/utils/mail.test.tsapps/web/utils/url.test.ts
🧰 Additional context used
📓 Path-based instructions (22)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/data-fetching.mdc)
**/*.{ts,tsx}: For API GET requests to server, use theswrpackage
Useresult?.serverErrorwithtoastErrorfrom@/components/Toastfor error handling in async operations
**/*.{ts,tsx}: Use wrapper functions for Gmail message operations (get, list, batch, etc.) from @/utils/gmail/message.ts instead of direct API calls
Use wrapper functions for Gmail thread operations from @/utils/gmail/thread.ts instead of direct API calls
Use wrapper functions for Gmail label operations from @/utils/gmail/label.ts instead of direct API calls
**/*.{ts,tsx}: For early access feature flags, create hooks using the naming conventionuse[FeatureName]Enabledthat return a boolean fromuseFeatureFlagEnabled("flag-key")
For A/B test variant flags, create hooks using the naming conventionuse[FeatureName]Variantthat define variant types, useuseFeatureFlagVariantKey()with type casting, and provide a default "control" fallback
Use kebab-case for PostHog feature flag keys (e.g.,inbox-cleaner,pricing-options-2)
Always define types for A/B test variant flags (e.g.,type PricingVariant = "control" | "variant-a" | "variant-b") and provide type safety through type casting
**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use empty type parameters in type aliases and interfaces
Don't use this and super in static contexts
Don't use any or unknown as type constraints
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
Don't export imported variables
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions
Don't use TypeScript namespaces
Don't use non-null assertions with the!postfix operator
Don't use parameter properties in class constructors
Don't use user-defined types
Useas constinstead of literal types and type annotations
Use eitherT[]orArray<T>consistently
Initialize each enum member value explicitly
Useexport typefor types
Use `impo...
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/prisma-enum-imports.mdc)
Always import Prisma enums from
@/generated/prisma/enumsinstead of@/generated/prisma/clientto avoid Next.js bundling errors in client componentsImport Prisma using the project's centralized utility:
import prisma from '@/utils/prisma'
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Import specific lodash functions rather than entire lodash library to minimize bundle size (e.g.,
import groupBy from 'lodash/groupBy')
apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Do not export types/interfaces that are only used within the same file. Export later if needed
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/security.mdc)
**/*.ts: ALL database queries MUST be scoped to the authenticated user/account by including user/account filtering in WHERE clauses to prevent unauthorized data access
Always validate that resources belong to the authenticated user before performing operations, using ownership checks in WHERE clauses or relationships
Always validate all input parameters for type, format, and length before using them in database queries
Use SafeError for error responses to prevent information disclosure. Generic error messages should not reveal internal IDs, logic, or resource ownership details
Only return necessary fields in API responses using Prisma'sselectoption. Never expose sensitive data such as password hashes, private keys, or system flags
Prevent Insecure Direct Object References (IDOR) by validating resource ownership before operations. AllfindUnique/findFirstcalls MUST include ownership filters
Prevent mass assignment vulnerabilities by explicitly whitelisting allowed fields in update operations instead of accepting all user-provided data
Prevent privilege escalation by never allowing users to modify system fields, ownership fields, or admin-only attributes through user input
AllfindManyqueries MUST be scoped to the user's data by including appropriate WHERE filters to prevent returning data from other users
Use Prisma relationships for access control by leveraging nested where clauses (e.g.,emailAccount: { id: emailAccountId }) to validate ownership
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
**/*.{tsx,ts}: Use Shadcn UI and Tailwind for components and styling
Usenext/imagepackage for images
For API GET requests to server, use theswrpackage with hooks likeuseSWRto fetch data
For text inputs, use theInputcomponent withregisterPropsfor form integration and error handling
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
**/*.{tsx,ts,css}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
Implement responsive design with Tailwind CSS using a mobile-first approach
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useaccessKeyattribute on any HTML element
Don't setaria-hidden="true"on focusable elements
Don't add ARIA roles, states, and properties to elements that don't support them
Don't use distracting elements like<marquee>or<blink>
Only use thescopeprop on<th>elements
Don't assign non-interactive ARIA roles to interactive HTML elements
Make sure label elements have text content and are associated with an input
Don't assign interactive ARIA roles to non-interactive HTML elements
Don't assigntabIndexto non-interactive HTML elements
Don't use positive integers fortabIndexproperty
Don't include "image", "picture", or "photo" in img alt prop
Don't use explicit role property that's the same as the implicit/default role
Make static elements with click handlers use a valid role attribute
Always include atitleelement for SVG elements
Give all elements requiring alt text meaningful information for screen readers
Make sure anchors have content that's accessible to screen readers
AssigntabIndexto non-interactive HTML elements witharia-activedescendant
Include all required ARIA attributes for elements with ARIA roles
Make sure ARIA properties are valid for the element's supported roles
Always include atypeattribute for button elements
Make elements with interactive roles and handlers focusable
Give heading elements content that's accessible to screen readers (not hidden witharia-hidden)
Always include alangattribute on the html element
Always include atitleattribute for iframe elements
AccompanyonClickwith at least one of:onKeyUp,onKeyDown, oronKeyPress
AccompanyonMouseOver/onMouseOutwithonFocus/onBlur
Include caption tracks for audio and video elements
Use semantic elements instead of role attributes in JSX
Make sure all anchors are valid and navigable
Ensure all ARIA properties (aria-*) are valid
Use valid, non-abstract ARIA roles for elements with ARIA roles
Use valid AR...
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{test,spec}.{js,jsx,ts,tsx}: Don't nest describe() blocks too deeply in test files
Don't use callbacks in asynchronous tests and hooks
Don't have duplicate hooks in describe blocks
Don't use export or module.exports in test files
Don't use focused tests
Make sure the assertion function, like expect, is placed inside an it() function call
Don't use disabled tests
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.ts
!(pages/_document).{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
Don't use the next/head module in pages/_document.js on Next.js projects
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/utilities.mdc)
**/*.{js,ts,jsx,tsx}: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size (e.g.,import groupBy from 'lodash/groupBy')
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
**/{utils,helpers,lib}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)
Logger should be passed as a parameter to helper functions instead of creating their own logger instances
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
apps/web/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.{ts,tsx,js,jsx}: Use@/path aliases for imports from project root
Prefer self-documenting code over comments; use descriptive variable and function names instead of explaining intent with comments
Add helper functions to the bottom of files, not the top
All imports go at the top of files, no mid-file dynamic imports
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
apps/web/**/*.{ts,tsx,js,jsx,json,css}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Format code with Prettier
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
apps/web/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Co-locate test files next to source files (e.g.,
utils/example.test.ts). Only E2E and AI tests go in__tests__/
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.ts
apps/web/**/*.{example,ts,json}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Add environment variables to
.env.example,env.ts, andturbo.json
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
**/*.test.{ts,tsx}: Usevitestas the testing framework
Colocate test files next to the tested file with.test.tsor.test.tsxnaming convention (e.g.,dir/format.tsanddir/format.test.ts)
Mockserver-onlyusingvi.mock("server-only", () => ({}))
Mock Prisma usingvi.mock("@/utils/prisma")and the provided mock from@/utils/__mocks__/prisma
Use test helper functionsgetEmail,getEmailAccount, andgetRulefrom@/__tests__/helpersfor creating mock data
Clear all mocks between tests usingbeforeEach(() => { vi.clearAllMocks(); })
Use descriptive test names that clearly indicate what is being tested
Do not mock the Logger in tests
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.ts
**/*.test.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/notes.mdc)
Co-locate test files next to source files (e.g.,
utils/example.test.ts). Only E2E and AI tests go in__tests__/
Files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.ts
apps/web/utils/actions/*.ts
📄 CodeRabbit inference engine (.cursor/rules/fullstack-workflow.mdc)
apps/web/utils/actions/*.ts: Usenext-safe-actionwith Zod schemas for all server actions (create/update/delete mutations), storing validation schemas inapps/web/utils/actions/*.validation.ts
Server actions should use 'use server' directive and automatically receive authentication context (emailAccountId) from theactionClient
apps/web/utils/actions/*.ts: Create corresponding server action implementation files using the naming conventionapps/web/utils/actions/NAME.tswith 'use server' directive
Use 'use server' directive at the top of server action implementation files
Implement all server actions using thenext-safe-actionlibrary with actionClient, actionClientUser, or adminActionClient for type safety and validation
UseactionClientUserwhen only authenticated user context (userId) is needed
UseactionClientwhen both authenticated user context and a specific emailAccountId are needed, with emailAccountId bound when calling from the client
UseadminActionClientfor actions restricted to admin users
Add metadata with a meaningful action name using.metadata({ name: "actionName" })for Sentry instrumentation and monitoring
Use.schema()method with Zod validation schemas from corresponding.validation.tsfiles in next-safe-action configuration
Access context (userId, emailAccountId, etc.) via thectxobject parameter in the.action()handler
UserevalidatePathorrevalidateTagfrom 'next/cache' within server action handlers when mutations modify data displayed elsewhere
Files:
apps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
apps/web/utils/actions/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
apps/web/utils/actions/**/*.ts: Server actions must be located inapps/web/utils/actionsfolder
Server action files must start withuse serverdirective
apps/web/utils/actions/**/*.ts: Use proper error handling with try/catch blocks
Usenext-safe-actionwith Zod schemas for server actions to handle mutations
UserevalidatePathin server actions for cache invalidation after mutations
Files:
apps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
apps/web/utils/actions/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Infer types from Zod schemas using
z.infer<typeof schema>instead of duplicating as separate interfaces
Files:
apps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
**/*.validation.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.validation.{ts,tsx}: Define validation schemas using Zod
Use descriptive error messages in validation schemas
Files:
apps/web/utils/actions/rule.validation.ts
apps/web/utils/actions/*.validation.ts
📄 CodeRabbit inference engine (.cursor/rules/fullstack-workflow.mdc)
apps/web/utils/actions/*.validation.ts: Define Zod validation schemas in separate*.validation.tsfiles and export both the schema and inferred type (e.g.,CreateExampleBody)
Export types from Zod schemas usingz.infer<>to maintain type safety between validation and client usage
apps/web/utils/actions/*.validation.ts: Create separate validation files for server actions using the naming conventionapps/web/utils/actions/NAME.validation.tscontaining Zod schemas and inferred types
Define input validation schemas using Zod in.validation.tsfiles and export both the schema and its inferred TypeScript type
Files:
apps/web/utils/actions/rule.validation.ts
🧠 Learnings (26)
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use test helper functions `getEmail`, `getEmailAccount`, and `getRule` from `@/__tests__/helpers` for creating mock data
Applied to files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Prefer using existing helpers from `@/__tests__/helpers.ts` (`getEmailAccount`, `getEmail`, `getRule`, `getMockMessage`, `getMockExecutedRule`) instead of creating custom test data helpers
Applied to files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use `console.debug()` for outputting generated LLM content in tests, e.g., `console.debug("Generated content:\n", result.content);`
Applied to files:
apps/web/utils/mail.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to **/*.{ts,tsx} : Use wrapper functions for Gmail message operations (get, list, batch, etc.) from @/utils/gmail/message.ts instead of direct API calls
Applied to files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to **/*.{ts,tsx} : Use wrapper functions for Gmail thread operations from @/utils/gmail/thread.ts instead of direct API calls
Applied to files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use descriptive test names that clearly indicate what is being tested
Applied to files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to apps/web/utils/gmail/**/*.{ts,tsx} : Keep Gmail provider-specific implementation details isolated within the apps/web/utils/gmail/ directory
Applied to files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.ts
📚 Learning: 2025-12-21T12:21:37.794Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-12-21T12:21:37.794Z
Learning: Applies to apps/web/**/*.test.{ts,tsx} : Co-locate test files next to source files (e.g., `utils/example.test.ts`). Only E2E and AI tests go in `__tests__/`
Applied to files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use vitest imports (`describe`, `expect`, `test`, `vi`, `beforeEach`) in LLM test files
Applied to files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Place all LLM-related tests in `apps/web/__tests__/` directory
Applied to files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Design Gmail wrapper functions to be provider-agnostic to support future email providers like Outlook and ProtonMail
Applied to files:
apps/web/utils/mail.test.tsapps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:39:23.326Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:23.326Z
Learning: Applies to **/*.test.ts : Include security tests in test suites to verify: authentication is required, IDOR protection works (other users cannot access resources), parameter validation rejects invalid inputs, and error messages don't leak information
Applied to files:
apps/web/utils/url.test.tsapps/web/utils/actions/rule.validation.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/{utils/ai,utils/llms,__tests__}/**/*.ts : LLM-related code must be organized in specific directories: `apps/web/utils/ai/` for main implementations, `apps/web/utils/llms/` for core utilities and configurations, and `apps/web/__tests__/` for LLM-specific tests
Applied to files:
apps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to apps/web/utils/gmail/**/*.{ts,tsx} : Always use wrapper functions from @/utils/gmail/ for Gmail API operations instead of direct provider API calls
Applied to files:
apps/web/utils/url.test.ts
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Create separate validation files for server actions using the naming convention `apps/web/utils/actions/NAME.validation.ts` containing Zod schemas and inferred types
Applied to files:
apps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:37:09.306Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-11-25T14:37:09.306Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define Zod validation schemas in separate `*.validation.ts` files and export both the schema and inferred type (e.g., `CreateExampleBody`)
Applied to files:
apps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.ts : Use `.schema()` method with Zod validation schemas from corresponding `.validation.ts` files in next-safe-action configuration
Applied to files:
apps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:37:09.306Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-11-25T14:37:09.306Z
Learning: Applies to apps/web/utils/actions/*.ts : Use `next-safe-action` with Zod schemas for all server actions (create/update/delete mutations), storing validation schemas in `apps/web/utils/actions/*.validation.ts`
Applied to files:
apps/web/utils/actions/rule.validation.test.ts
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Define input validation schemas using Zod in `.validation.ts` files and export both the schema and its inferred TypeScript type
Applied to files:
apps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:36:51.389Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-11-25T14:36:51.389Z
Learning: Applies to **/*.validation.ts : Define validation schemas using Zod
Applied to files:
apps/web/utils/actions/rule.validation.test.tsapps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Set timeout constant `const TIMEOUT = 15_000;` for LLM tests
Applied to files:
apps/web/utils/actions/rule.validation.test.ts
📚 Learning: 2025-11-25T14:36:51.389Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/form-handling.mdc:0-0
Timestamp: 2025-11-25T14:36:51.389Z
Learning: Applies to **/*.validation.ts : Use descriptive error messages in Zod validation schemas
Applied to files:
apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:39:23.326Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:23.326Z
Learning: Applies to app/api/**/*.ts : All input parameters must be validated - check for presence, type, and format before use; use Zod schemas to validate request bodies with type guards and constraints
Applied to files:
apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Use XML-like tags to structure data in prompts, remove excessive whitespace and truncate long inputs, and format data consistently across similar LLM functions
Applied to files:
apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:42:08.869Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-11-25T14:42:08.869Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Remove redundant terms from logical expressions
Applied to files:
apps/web/utils/actions/rule.validation.ts
📚 Learning: 2025-11-25T14:42:08.869Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-11-25T14:42:08.869Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Use `String.trimStart()` and `String.trimEnd()` over `String.trimLeft()` and `String.trimRight()`
Applied to files:
apps/web/utils/actions/rule.validation.ts
🧬 Code graph analysis (2)
apps/web/utils/mail.test.ts (1)
apps/web/utils/mail.ts (4)
emailToContent(74-103)convertEmailHtmlToText(105-126)parseReply(9-13)getEmailClient(33-41)
apps/web/utils/actions/rule.validation.test.ts (2)
apps/web/utils/actions/rule.validation.ts (3)
delayInMinutesSchema(11-15)CreateRuleBody(205-205)createRuleBody(141-204)apps/web/utils/date.ts (1)
NINETY_DAYS_MINUTES(16-16)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Baz Reviewer
- GitHub Check: cubic · AI code reviewer
- GitHub Check: test
🔇 Additional comments (5)
apps/web/utils/url.test.ts (1)
1-190: Excellent test coverage for URL utilities!The test suite comprehensively covers all URL building functions across multiple providers with edge cases including:
- Email address presence/absence
- Special character encoding
- Provider-specific behavior
- Search and filter URL construction
apps/web/utils/mail.test.ts (1)
1-264: Comprehensive test coverage for mail utilities!The test suite thoroughly validates all mail utility functions with excellent edge case coverage including:
- Content source fallback hierarchy
- Truncation behavior with various maxLength values
- Forward content removal for multiple email clients
- HTML-to-text conversion with link handling
- Email client identification
The
server-onlymock on line 9 is appropriately used for unit testing.apps/web/utils/actions/rule.validation.ts (2)
143-143: Good fix: Whitespace-only names now properly rejected.Adding
.trim()before.min(1)ensures that names consisting only of whitespace are correctly rejected. This is validated by the test at line 97-103 in the test file.
200-202: Good fix: Removed ineffective default value.Removing
.default(LogicalOperator.AND)makes the field truly optional. The previous.default()after.optional()was ineffective since.optional()already allows undefined values. This change is validated by the test at lines 384-390 in the test file.apps/web/utils/actions/rule.validation.test.ts (1)
1-392: Excellent comprehensive validation test suite!The test suite thoroughly validates all aspects of rule creation including:
- Delay boundaries (1 minute to 90 days)
- Name validation (non-empty, non-whitespace)
- Actions and conditions requirements
- Action-specific field requirements (LABEL, FORWARD, CALL_WEBHOOK, MOVE_FOLDER)
- Duplicate condition detection
- Optional field handling
The tests properly validate both success and failure paths with appropriate error message assertions.
Add 54 more tests for additional utility functions: - template.test.ts: hasVariables and TEMPLATE_VARIABLE_PATTERN (22 tests) - text.test.ts: slugify and extractTextFromPortableTextBlock (22 tests) - filter-ignored-senders.test.ts: isIgnoredSender (10 tests) Also improved parseReply test to verify quoted content is actually stripped per PR feedback. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="apps/web/utils/template.test.ts">
<violation number="1" location="apps/web/utils/template.test.ts:44">
P3: Duplicate test case - this test uses the identical string `"Hello {{name}}"` as the "detects simple variable" test above. Consider using a different input like `"said hello {{name}}"` to genuinely test a variable-at-end scenario.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| it("detects variable at end", () => { | ||
| expect(hasVariables("Hello {{name}}")).toBe(true); | ||
| }); |
There was a problem hiding this comment.
P3: Duplicate test case - this test uses the identical string "Hello {{name}}" as the "detects simple variable" test above. Consider using a different input like "said hello {{name}}" to genuinely test a variable-at-end scenario.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/utils/template.test.ts, line 44:
<comment>Duplicate test case - this test uses the identical string `"Hello {{name}}"` as the "detects simple variable" test above. Consider using a different input like `"said hello {{name}}"` to genuinely test a variable-at-end scenario.</comment>
<file context>
@@ -0,0 +1,104 @@
+ expect(hasVariables("{{name}} said hello")).toBe(true);
+ });
+
+ it("detects variable at end", () => {
+ expect(hasVariables("Hello {{name}}")).toBe(true);
+ });
</file context>
| it("detects variable at end", () => { | |
| expect(hasVariables("Hello {{name}}")).toBe(true); | |
| }); | |
| it("detects variable at end", () => { | |
| expect(hasVariables("said hello {{name}}")).toBe(true); | |
| }); |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/web/utils/text.test.ts (1)
5-79: Consolidate duplicateslugifyimplementations.The codebase has two separate
slugifyfunctions with different implementations:
apps/web/utils/string.ts- actively used insso.tsandorganization/create/page.tsx, includes trim, Unicode-aware regex, and removes leading/trailing hyphensapps/web/utils/text.ts- only used in its own test file, simpler regex without trim or edge case handlingThe
text.tsimplementation has no production usage. Consolidating to a single, well-tested implementation instring.tswill eliminate duplication and reduce maintenance overhead. Iftext.tsrequires Portable Text-specific logic, consider either: (a) extending the unified implementation with an optional parameter, or (b) clearly documenting the purpose of the text.ts version.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/web/utils/filter-ignored-senders.test.tsapps/web/utils/mail.test.tsapps/web/utils/template.test.tsapps/web/utils/text.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/web/utils/mail.test.ts
🧰 Additional context used
📓 Path-based instructions (17)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/data-fetching.mdc)
**/*.{ts,tsx}: For API GET requests to server, use theswrpackage
Useresult?.serverErrorwithtoastErrorfrom@/components/Toastfor error handling in async operations
**/*.{ts,tsx}: Use wrapper functions for Gmail message operations (get, list, batch, etc.) from @/utils/gmail/message.ts instead of direct API calls
Use wrapper functions for Gmail thread operations from @/utils/gmail/thread.ts instead of direct API calls
Use wrapper functions for Gmail label operations from @/utils/gmail/label.ts instead of direct API calls
**/*.{ts,tsx}: For early access feature flags, create hooks using the naming conventionuse[FeatureName]Enabledthat return a boolean fromuseFeatureFlagEnabled("flag-key")
For A/B test variant flags, create hooks using the naming conventionuse[FeatureName]Variantthat define variant types, useuseFeatureFlagVariantKey()with type casting, and provide a default "control" fallback
Use kebab-case for PostHog feature flag keys (e.g.,inbox-cleaner,pricing-options-2)
Always define types for A/B test variant flags (e.g.,type PricingVariant = "control" | "variant-a" | "variant-b") and provide type safety through type casting
**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use empty type parameters in type aliases and interfaces
Don't use this and super in static contexts
Don't use any or unknown as type constraints
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
Don't export imported variables
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions
Don't use TypeScript namespaces
Don't use non-null assertions with the!postfix operator
Don't use parameter properties in class constructors
Don't use user-defined types
Useas constinstead of literal types and type annotations
Use eitherT[]orArray<T>consistently
Initialize each enum member value explicitly
Useexport typefor types
Use `impo...
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/prisma-enum-imports.mdc)
Always import Prisma enums from
@/generated/prisma/enumsinstead of@/generated/prisma/clientto avoid Next.js bundling errors in client componentsImport Prisma using the project's centralized utility:
import prisma from '@/utils/prisma'
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Import specific lodash functions rather than entire lodash library to minimize bundle size (e.g.,
import groupBy from 'lodash/groupBy')
apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Do not export types/interfaces that are only used within the same file. Export later if needed
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/security.mdc)
**/*.ts: ALL database queries MUST be scoped to the authenticated user/account by including user/account filtering in WHERE clauses to prevent unauthorized data access
Always validate that resources belong to the authenticated user before performing operations, using ownership checks in WHERE clauses or relationships
Always validate all input parameters for type, format, and length before using them in database queries
Use SafeError for error responses to prevent information disclosure. Generic error messages should not reveal internal IDs, logic, or resource ownership details
Only return necessary fields in API responses using Prisma'sselectoption. Never expose sensitive data such as password hashes, private keys, or system flags
Prevent Insecure Direct Object References (IDOR) by validating resource ownership before operations. AllfindUnique/findFirstcalls MUST include ownership filters
Prevent mass assignment vulnerabilities by explicitly whitelisting allowed fields in update operations instead of accepting all user-provided data
Prevent privilege escalation by never allowing users to modify system fields, ownership fields, or admin-only attributes through user input
AllfindManyqueries MUST be scoped to the user's data by including appropriate WHERE filters to prevent returning data from other users
Use Prisma relationships for access control by leveraging nested where clauses (e.g.,emailAccount: { id: emailAccountId }) to validate ownership
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
**/*.{tsx,ts}: Use Shadcn UI and Tailwind for components and styling
Usenext/imagepackage for images
For API GET requests to server, use theswrpackage with hooks likeuseSWRto fetch data
For text inputs, use theInputcomponent withregisterPropsfor form integration and error handling
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
**/*.{tsx,ts,css}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
Implement responsive design with Tailwind CSS using a mobile-first approach
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useaccessKeyattribute on any HTML element
Don't setaria-hidden="true"on focusable elements
Don't add ARIA roles, states, and properties to elements that don't support them
Don't use distracting elements like<marquee>or<blink>
Only use thescopeprop on<th>elements
Don't assign non-interactive ARIA roles to interactive HTML elements
Make sure label elements have text content and are associated with an input
Don't assign interactive ARIA roles to non-interactive HTML elements
Don't assigntabIndexto non-interactive HTML elements
Don't use positive integers fortabIndexproperty
Don't include "image", "picture", or "photo" in img alt prop
Don't use explicit role property that's the same as the implicit/default role
Make static elements with click handlers use a valid role attribute
Always include atitleelement for SVG elements
Give all elements requiring alt text meaningful information for screen readers
Make sure anchors have content that's accessible to screen readers
AssigntabIndexto non-interactive HTML elements witharia-activedescendant
Include all required ARIA attributes for elements with ARIA roles
Make sure ARIA properties are valid for the element's supported roles
Always include atypeattribute for button elements
Make elements with interactive roles and handlers focusable
Give heading elements content that's accessible to screen readers (not hidden witharia-hidden)
Always include alangattribute on the html element
Always include atitleattribute for iframe elements
AccompanyonClickwith at least one of:onKeyUp,onKeyDown, oronKeyPress
AccompanyonMouseOver/onMouseOutwithonFocus/onBlur
Include caption tracks for audio and video elements
Use semantic elements instead of role attributes in JSX
Make sure all anchors are valid and navigable
Ensure all ARIA properties (aria-*) are valid
Use valid, non-abstract ARIA roles for elements with ARIA roles
Use valid AR...
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{test,spec}.{js,jsx,ts,tsx}: Don't nest describe() blocks too deeply in test files
Don't use callbacks in asynchronous tests and hooks
Don't have duplicate hooks in describe blocks
Don't use export or module.exports in test files
Don't use focused tests
Make sure the assertion function, like expect, is placed inside an it() function call
Don't use disabled tests
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
!(pages/_document).{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
Don't use the next/head module in pages/_document.js on Next.js projects
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/utilities.mdc)
**/*.{js,ts,jsx,tsx}: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size (e.g.,import groupBy from 'lodash/groupBy')
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
**/{utils,helpers,lib}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)
Logger should be passed as a parameter to helper functions instead of creating their own logger instances
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
apps/web/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.{ts,tsx,js,jsx}: Use@/path aliases for imports from project root
Prefer self-documenting code over comments; use descriptive variable and function names instead of explaining intent with comments
Add helper functions to the bottom of files, not the top
All imports go at the top of files, no mid-file dynamic imports
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
apps/web/**/*.{ts,tsx,js,jsx,json,css}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Format code with Prettier
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
apps/web/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Co-locate test files next to source files (e.g.,
utils/example.test.ts). Only E2E and AI tests go in__tests__/
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
apps/web/**/*.{example,ts,json}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Add environment variables to
.env.example,env.ts, andturbo.json
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
**/*.test.{ts,tsx}: Usevitestas the testing framework
Colocate test files next to the tested file with.test.tsor.test.tsxnaming convention (e.g.,dir/format.tsanddir/format.test.ts)
Mockserver-onlyusingvi.mock("server-only", () => ({}))
Mock Prisma usingvi.mock("@/utils/prisma")and the provided mock from@/utils/__mocks__/prisma
Use test helper functionsgetEmail,getEmailAccount, andgetRulefrom@/__tests__/helpersfor creating mock data
Clear all mocks between tests usingbeforeEach(() => { vi.clearAllMocks(); })
Use descriptive test names that clearly indicate what is being tested
Do not mock the Logger in tests
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
**/*.test.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/notes.mdc)
Co-locate test files next to source files (e.g.,
utils/example.test.ts). Only E2E and AI tests go in__tests__/
Files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
🧠 Learnings (16)
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use vitest imports (`describe`, `expect`, `test`, `vi`, `beforeEach`) in LLM test files
Applied to files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-12-21T12:21:37.794Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-12-21T12:21:37.794Z
Learning: Applies to apps/web/**/*.test.{ts,tsx} : Co-locate test files next to source files (e.g., `utils/example.test.ts`). Only E2E and AI tests go in `__tests__/`
Applied to files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use `describe.runIf(isAiTest)` with environment variable `RUN_AI_TESTS === "true"` to conditionally run LLM tests
Applied to files:
apps/web/utils/template.test.tsapps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use descriptive test names that clearly indicate what is being tested
Applied to files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Place all LLM-related tests in `apps/web/__tests__/` directory
Applied to files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:39:23.326Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:23.326Z
Learning: Applies to **/*.test.ts : Include security tests in test suites to verify: authentication is required, IDOR protection works (other users cannot access resources), parameter validation rejects invalid inputs, and error messages don't leak information
Applied to files:
apps/web/utils/template.test.tsapps/web/utils/text.test.tsapps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use `console.debug()` for outputting generated LLM content in tests, e.g., `console.debug("Generated content:\n", result.content);`
Applied to files:
apps/web/utils/template.test.tsapps/web/utils/text.test.ts
📚 Learning: 2026-01-04T00:25:22.311Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/notes.mdc:0-0
Timestamp: 2026-01-04T00:25:22.311Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Co-locate test files next to source files (e.g., `utils/example.test.ts`). Only E2E and AI tests go in `__tests__/`
Applied to files:
apps/web/utils/template.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Prefer using existing helpers from `@/__tests__/helpers.ts` (`getEmailAccount`, `getEmail`, `getRule`, `getMockMessage`, `getMockExecutedRule`) instead of creating custom test data helpers
Applied to files:
apps/web/utils/template.test.tsapps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-12-21T12:21:37.794Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-12-21T12:21:37.794Z
Learning: Applies to apps/web/**/*.{example,ts,json} : Add environment variables to `.env.example`, `env.ts`, and `turbo.json`
Applied to files:
apps/web/utils/template.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Use XML-like tags to structure data in prompts, remove excessive whitespace and truncate long inputs, and format data consistently across similar LLM functions
Applied to files:
apps/web/utils/text.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/{utils/ai,utils/llms,__tests__}/**/*.ts : LLM-related code must be organized in specific directories: `apps/web/utils/ai/` for main implementations, `apps/web/utils/llms/` for core utilities and configurations, and `apps/web/__tests__/` for LLM-specific tests
Applied to files:
apps/web/utils/text.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use test helper functions `getEmail`, `getEmailAccount`, and `getRule` from `@/__tests__/helpers` for creating mock data
Applied to files:
apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:37:22.660Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-11-25T14:37:22.660Z
Learning: Applies to apps/web/utils/gmail/**/*.{ts,tsx} : Keep Gmail provider-specific implementation details isolated within the apps/web/utils/gmail/ directory
Applied to files:
apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : Place AI tests in the `__tests__` directory and do not run them by default as they use a real LLM
Applied to files:
apps/web/utils/filter-ignored-senders.test.ts
📚 Learning: 2025-11-25T14:42:08.869Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-11-25T14:42:08.869Z
Learning: Applies to **/*.{test,spec}.{js,jsx,ts,tsx} : Make sure the assertion function, like expect, is placed inside an it() function call
Applied to files:
apps/web/utils/filter-ignored-senders.test.ts
🧬 Code graph analysis (1)
apps/web/utils/text.test.ts (1)
apps/web/utils/string.ts (1)
slugify(52-59)
🪛 ast-grep (0.40.4)
apps/web/utils/template.test.ts
[warning] 5-5: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(TEMPLATE_VARIABLE_PATTERN)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
[warning] 10-10: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(TEMPLATE_VARIABLE_PATTERN)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
[warning] 15-15: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(TEMPLATE_VARIABLE_PATTERN)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
[warning] 20-20: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(TEMPLATE_VARIABLE_PATTERN)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Baz Reviewer
- GitHub Check: cubic · AI code reviewer
- GitHub Check: test
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
apps/web/utils/filter-ignored-senders.test.ts (1)
1-52: LGTM! Comprehensive test coverage forisIgnoredSender.The test suite thoroughly covers the expected behavior:
- Exact match validation
- Case sensitivity requirements
- Edge cases (empty strings, partial matches, substrings)
- Different email formats
The tests are well-organized and follow project conventions.
apps/web/utils/template.test.ts (1)
1-104: LGTM! Thorough test coverage for template variable detection.The tests comprehensively validate both
TEMPLATE_VARIABLE_PATTERNandhasVariables:
- Various variable formats (simple, spaces, multiline, special characters)
- Edge cases (empty variables, unmatched braces)
- Null/undefined handling
Note: The static analysis warnings about ReDoS for
new RegExp(TEMPLATE_VARIABLE_PATTERN)are false positives in this context—TEMPLATE_VARIABLE_PATTERNis an imported constant, not user input, and the tests are specifically validating the pattern's behavior.apps/web/utils/text.test.ts (1)
81-136: LGTM! Comprehensive test coverage forextractTextFromPortableTextBlock.The tests thoroughly validate text extraction from PortableText blocks:
- Single and multiple spans
- Empty children arrays
- Non-span children filtering
- Empty text handling
Add 81 more tests: - action-sort.test.ts (12 tests): action priority sorting - action-item.test.ts (27 tests): field extraction and sanitization - parse/unsubscribe.test.ts (16 tests): unsubscribe keyword detection - parse/cta.test.ts (26 tests): CTA keyword detection with length constraints 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="apps/web/utils/parse/cta.test.ts">
<violation number="1" location="apps/web/utils/parse/cta.test.ts:60">
P2: Test name and comment are inconsistent with actual test. The test claims to verify 29 characters, but the string is 23 characters (and the assertion confirms this). Consider fixing the test name and comment, or removing this test since the next test already covers the 29-character case properly.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| it("returns true for text exactly 29 characters with keyword", () => { | ||
| // "view it on GitHub" is 17 chars, add 12 more to get 29 | ||
| const text = "view it on GitHub123456"; |
There was a problem hiding this comment.
P2: Test name and comment are inconsistent with actual test. The test claims to verify 29 characters, but the string is 23 characters (and the assertion confirms this). Consider fixing the test name and comment, or removing this test since the next test already covers the 29-character case properly.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/utils/parse/cta.test.ts, line 60:
<comment>Test name and comment are inconsistent with actual test. The test claims to verify 29 characters, but the string is 23 characters (and the assertion confirms this). Consider fixing the test name and comment, or removing this test since the next test already covers the 29-character case properly.</comment>
<file context>
@@ -0,0 +1,129 @@
+ });
+
+ describe("length constraint (max 30 characters)", () => {
+ it("returns true for text exactly 29 characters with keyword", () => {
+ // "view it on GitHub" is 17 chars, add 12 more to get 29
+ const text = "view it on GitHub123456";
</file context>
| it("returns true for text exactly 29 characters with keyword", () => { | |
| // "view it on GitHub" is 17 chars, add 12 more to get 29 | |
| const text = "view it on GitHub123456"; | |
| it("returns true for text within the 30 character limit", () => { | |
| // "view it on GitHub" is 17 chars, add 6 more to get 23 | |
| const text = "view it on GitHub123456"; |
…DER to action priority - Make containsUnsubscribeKeyword case-insensitive by lowercasing input text - Add NOTIFY_SENDER to ACTION_TYPE_PRIORITY_ORDER (before CALL_WEBHOOK) - Update tests to reflect both fixes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In @apps/web/utils/action-sort.test.ts:
- Around line 55-84: The test "maintains correct priority order for all action
types" is missing ActionType.NOTIFY_SENDER; add { type: ActionType.NOTIFY_SENDER
} to the input actions array and include ActionType.NOTIFY_SENDER in the
expected sorted array returned from sortActionsByPriority, placing it at the
correct position according to the priority defined in action-sort.ts; update the
assertions in apps/web/utils/action-sort.test.ts so the input, call to
sortActionsByPriority, and expected arrays both contain NOTIFY_SENDER using the
same ActionType symbol.
In @apps/web/utils/parse/cta.test.ts:
- Around line 60-65: The test "returns true for text exactly 29 characters with
keyword" is inconsistent: the text variable ("view it on GitHub123456") and its
length assertion use 23, not 29; update the test to be consistent by either (A)
renaming the test description and comment to say 23 characters (and keep
expect(text.length).toBe(23)) or (B) change the text string so it is actually 29
characters and update the expect(text.length) to 29; adjust the inline comment
accordingly and leave the containsCtaKeyword(text) assertion as-is.
- Around line 107-113: The containsCtaKeyword function is case-sensitive and
misses common CTA casing; update it to normalize case like
containsUnsubscribeKeyword by comparing text.toLowerCase() (and keywords
lowercased) when checking includes, and then update the related tests ("is case
sensitive - does not match uppercase"/"title case") to expect true (or remove
those negative tests) so CTA strings like "VIEW IT" and "View It" are
recognized.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
apps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/action-sort.tsapps/web/utils/parse/cta.test.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/unsubscribe.ts
🧰 Additional context used
📓 Path-based instructions (17)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/data-fetching.mdc)
**/*.{ts,tsx}: For API GET requests to server, use theswrpackage
Useresult?.serverErrorwithtoastErrorfrom@/components/Toastfor error handling in async operations
**/*.{ts,tsx}: Use wrapper functions for Gmail message operations (get, list, batch, etc.) from @/utils/gmail/message.ts instead of direct API calls
Use wrapper functions for Gmail thread operations from @/utils/gmail/thread.ts instead of direct API calls
Use wrapper functions for Gmail label operations from @/utils/gmail/label.ts instead of direct API calls
**/*.{ts,tsx}: For early access feature flags, create hooks using the naming conventionuse[FeatureName]Enabledthat return a boolean fromuseFeatureFlagEnabled("flag-key")
For A/B test variant flags, create hooks using the naming conventionuse[FeatureName]Variantthat define variant types, useuseFeatureFlagVariantKey()with type casting, and provide a default "control" fallback
Use kebab-case for PostHog feature flag keys (e.g.,inbox-cleaner,pricing-options-2)
Always define types for A/B test variant flags (e.g.,type PricingVariant = "control" | "variant-a" | "variant-b") and provide type safety through type casting
**/*.{ts,tsx}: Don't use primitive type aliases or misleading types
Don't use empty type parameters in type aliases and interfaces
Don't use this and super in static contexts
Don't use any or unknown as type constraints
Don't use the TypeScript directive @ts-ignore
Don't use TypeScript enums
Don't export imported variables
Don't add type annotations to variables, parameters, and class properties that are initialized with literal expressions
Don't use TypeScript namespaces
Don't use non-null assertions with the!postfix operator
Don't use parameter properties in class constructors
Don't use user-defined types
Useas constinstead of literal types and type annotations
Use eitherT[]orArray<T>consistently
Initialize each enum member value explicitly
Useexport typefor types
Use `impo...
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/prisma-enum-imports.mdc)
Always import Prisma enums from
@/generated/prisma/enumsinstead of@/generated/prisma/clientto avoid Next.js bundling errors in client componentsImport Prisma using the project's centralized utility:
import prisma from '@/utils/prisma'
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Import specific lodash functions rather than entire lodash library to minimize bundle size (e.g.,
import groupBy from 'lodash/groupBy')
apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Do not export types/interfaces that are only used within the same file. Export later if needed
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/security.mdc)
**/*.ts: ALL database queries MUST be scoped to the authenticated user/account by including user/account filtering in WHERE clauses to prevent unauthorized data access
Always validate that resources belong to the authenticated user before performing operations, using ownership checks in WHERE clauses or relationships
Always validate all input parameters for type, format, and length before using them in database queries
Use SafeError for error responses to prevent information disclosure. Generic error messages should not reveal internal IDs, logic, or resource ownership details
Only return necessary fields in API responses using Prisma'sselectoption. Never expose sensitive data such as password hashes, private keys, or system flags
Prevent Insecure Direct Object References (IDOR) by validating resource ownership before operations. AllfindUnique/findFirstcalls MUST include ownership filters
Prevent mass assignment vulnerabilities by explicitly whitelisting allowed fields in update operations instead of accepting all user-provided data
Prevent privilege escalation by never allowing users to modify system fields, ownership fields, or admin-only attributes through user input
AllfindManyqueries MUST be scoped to the user's data by including appropriate WHERE filters to prevent returning data from other users
Use Prisma relationships for access control by leveraging nested where clauses (e.g.,emailAccount: { id: emailAccountId }) to validate ownership
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
**/*.{tsx,ts}: Use Shadcn UI and Tailwind for components and styling
Usenext/imagepackage for images
For API GET requests to server, use theswrpackage with hooks likeuseSWRto fetch data
For text inputs, use theInputcomponent withregisterPropsfor form integration and error handling
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
**/*.{tsx,ts,css}
📄 CodeRabbit inference engine (.cursor/rules/ui-components.mdc)
Implement responsive design with Tailwind CSS using a mobile-first approach
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useaccessKeyattribute on any HTML element
Don't setaria-hidden="true"on focusable elements
Don't add ARIA roles, states, and properties to elements that don't support them
Don't use distracting elements like<marquee>or<blink>
Only use thescopeprop on<th>elements
Don't assign non-interactive ARIA roles to interactive HTML elements
Make sure label elements have text content and are associated with an input
Don't assign interactive ARIA roles to non-interactive HTML elements
Don't assigntabIndexto non-interactive HTML elements
Don't use positive integers fortabIndexproperty
Don't include "image", "picture", or "photo" in img alt prop
Don't use explicit role property that's the same as the implicit/default role
Make static elements with click handlers use a valid role attribute
Always include atitleelement for SVG elements
Give all elements requiring alt text meaningful information for screen readers
Make sure anchors have content that's accessible to screen readers
AssigntabIndexto non-interactive HTML elements witharia-activedescendant
Include all required ARIA attributes for elements with ARIA roles
Make sure ARIA properties are valid for the element's supported roles
Always include atypeattribute for button elements
Make elements with interactive roles and handlers focusable
Give heading elements content that's accessible to screen readers (not hidden witharia-hidden)
Always include alangattribute on the html element
Always include atitleattribute for iframe elements
AccompanyonClickwith at least one of:onKeyUp,onKeyDown, oronKeyPress
AccompanyonMouseOver/onMouseOutwithonFocus/onBlur
Include caption tracks for audio and video elements
Use semantic elements instead of role attributes in JSX
Make sure all anchors are valid and navigable
Ensure all ARIA properties (aria-*) are valid
Use valid, non-abstract ARIA roles for elements with ARIA roles
Use valid AR...
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
!(pages/_document).{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
Don't use the next/head module in pages/_document.js on Next.js projects
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/utilities.mdc)
**/*.{js,ts,jsx,tsx}: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size (e.g.,import groupBy from 'lodash/groupBy')
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
**/{utils,helpers,lib}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)
Logger should be passed as a parameter to helper functions instead of creating their own logger instances
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
apps/web/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.{ts,tsx,js,jsx}: Use@/path aliases for imports from project root
Prefer self-documenting code over comments; use descriptive variable and function names instead of explaining intent with comments
Add helper functions to the bottom of files, not the top
All imports go at the top of files, no mid-file dynamic imports
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
apps/web/**/*.{ts,tsx,js,jsx,json,css}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Format code with Prettier
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
apps/web/**/*.{example,ts,json}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Add environment variables to
.env.example,env.ts, andturbo.json
Files:
apps/web/utils/action-sort.tsapps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.tsapps/web/utils/parse/unsubscribe.ts
**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{test,spec}.{js,jsx,ts,tsx}: Don't nest describe() blocks too deeply in test files
Don't use callbacks in asynchronous tests and hooks
Don't have duplicate hooks in describe blocks
Don't use export or module.exports in test files
Don't use focused tests
Make sure the assertion function, like expect, is placed inside an it() function call
Don't use disabled tests
Files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.ts
apps/web/**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
Co-locate test files next to source files (e.g.,
utils/example.test.ts). Only E2E and AI tests go in__tests__/
Files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
**/*.test.{ts,tsx}: Usevitestas the testing framework
Colocate test files next to the tested file with.test.tsor.test.tsxnaming convention (e.g.,dir/format.tsanddir/format.test.ts)
Mockserver-onlyusingvi.mock("server-only", () => ({}))
Mock Prisma usingvi.mock("@/utils/prisma")and the provided mock from@/utils/__mocks__/prisma
Use test helper functionsgetEmail,getEmailAccount, andgetRulefrom@/__tests__/helpersfor creating mock data
Clear all mocks between tests usingbeforeEach(() => { vi.clearAllMocks(); })
Use descriptive test names that clearly indicate what is being tested
Do not mock the Logger in tests
Files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.ts
**/*.test.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/notes.mdc)
Co-locate test files next to source files (e.g.,
utils/example.test.ts). Only E2E and AI tests go in__tests__/
Files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.ts
🧠 Learnings (23)
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.ts : Add metadata with a meaningful action name using `.metadata({ name: "actionName" })` for Sentry instrumentation and monitoring
Applied to files:
apps/web/utils/action-sort.tsapps/web/utils/action-item.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use `console.debug()` for outputting generated LLM content in tests, e.g., `console.debug("Generated content:\n", result.content);`
Applied to files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Prefer using existing helpers from `@/__tests__/helpers.ts` (`getEmailAccount`, `getEmail`, `getRule`, `getMockMessage`, `getMockExecutedRule`) instead of creating custom test data helpers
Applied to files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use descriptive test names that clearly indicate what is being tested
Applied to files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : Place AI tests in the `__tests__` directory and do not run them by default as they use a real LLM
Applied to files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Place all LLM-related tests in `apps/web/__tests__/` directory
Applied to files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-sort.test.ts
📚 Learning: 2026-01-01T10:42:29.775Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2026-01-01T10:42:29.775Z
Learning: Applies to **/*.test.{ts,tsx} : Use test helper functions `getEmail`, `getEmailAccount`, and `getRule` from `@/__tests__/helpers` for creating mock data
Applied to files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/action-item.test.ts
📚 Learning: 2025-12-21T12:21:37.794Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-12-21T12:21:37.794Z
Learning: Applies to apps/web/**/*.test.{ts,tsx} : Co-locate test files next to source files (e.g., `utils/example.test.ts`). Only E2E and AI tests go in `__tests__/`
Applied to files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use vitest imports (`describe`, `expect`, `test`, `vi`, `beforeEach`) in LLM test files
Applied to files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.tsapps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:42:08.869Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-11-25T14:42:08.869Z
Learning: Applies to **/*.{test,spec}.{js,jsx,ts,tsx} : Make sure the assertion function, like expect, is placed inside an it() function call
Applied to files:
apps/web/utils/parse/unsubscribe.test.tsapps/web/utils/parse/cta.test.ts
📚 Learning: 2025-11-25T14:37:56.430Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-11-25T14:37:56.430Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use `describe.runIf(isAiTest)` with environment variable `RUN_AI_TESTS === "true"` to conditionally run LLM tests
Applied to files:
apps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : Keep related AI functions in the same file or directory, extract common patterns into utility functions, and document complex AI logic with clear comments
Applied to files:
apps/web/utils/parse/cta.test.ts
📚 Learning: 2026-01-04T00:25:22.311Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/notes.mdc:0-0
Timestamp: 2026-01-04T00:25:22.311Z
Learning: Applies to **/*.test.{js,jsx,ts,tsx} : Co-locate test files next to source files (e.g., `utils/example.test.ts`). Only E2E and AI tests go in `__tests__/`
Applied to files:
apps/web/utils/parse/cta.test.tsapps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/{utils/ai,utils/llms,__tests__}/**/*.ts : LLM-related code must be organized in specific directories: `apps/web/utils/ai/` for main implementations, `apps/web/utils/llms/` for core utilities and configurations, and `apps/web/__tests__/` for LLM-specific tests
Applied to files:
apps/web/utils/parse/cta.test.tsapps/web/utils/action-item.test.tsapps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:38:07.606Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-11-25T14:38:07.606Z
Learning: Applies to apps/web/utils/ai/**/*.ts : User prompts must contain the actual data and context, and should be kept separate from system prompts
Applied to files:
apps/web/utils/parse/cta.test.ts
📚 Learning: 2025-11-25T14:39:23.326Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security.mdc:0-0
Timestamp: 2025-11-25T14:39:23.326Z
Learning: Applies to **/*.test.ts : Include security tests in test suites to verify: authentication is required, IDOR protection works (other users cannot access resources), parameter validation rejects invalid inputs, and error messages don't leak information
Applied to files:
apps/web/utils/action-item.test.ts
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.ts : Implement all server actions using the `next-safe-action` library with actionClient, actionClientUser, or adminActionClient for type safety and validation
Applied to files:
apps/web/utils/action-item.test.ts
📚 Learning: 2025-11-25T14:39:49.448Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/server-actions.mdc:0-0
Timestamp: 2025-11-25T14:39:49.448Z
Learning: Applies to apps/web/utils/actions/*.validation.ts : Create separate validation files for server actions using the naming convention `apps/web/utils/actions/NAME.validation.ts` containing Zod schemas and inferred types
Applied to files:
apps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:37:09.306Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/fullstack-workflow.mdc:0-0
Timestamp: 2025-11-25T14:37:09.306Z
Learning: Applies to apps/web/utils/actions/*.ts : Use `next-safe-action` with Zod schemas for all server actions (create/update/delete mutations), storing validation schemas in `apps/web/utils/actions/*.validation.ts`
Applied to files:
apps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:38:56.992Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/project-structure.mdc:0-0
Timestamp: 2025-11-25T14:38:56.992Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Server actions must be located in `apps/web/utils/actions` folder
Applied to files:
apps/web/utils/action-sort.test.ts
📚 Learning: 2025-12-21T12:21:37.794Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-12-21T12:21:37.794Z
Learning: Applies to apps/web/utils/actions/**/*.ts : Use `next-safe-action` with Zod schemas for server actions to handle mutations
Applied to files:
apps/web/utils/action-sort.test.ts
📚 Learning: 2025-11-25T14:38:27.988Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/posthog-feature-flags.mdc:0-0
Timestamp: 2025-11-25T14:38:27.988Z
Learning: Applies to apps/web/hooks/useFeatureFlags.ts : Use kebab-case for feature flag keys (e.g., `inbox-cleaner`, `pricing-options-2`)
Applied to files:
apps/web/utils/parse/unsubscribe.ts
📚 Learning: 2025-11-25T14:38:32.328Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/posthog-feature-flags.mdc:0-0
Timestamp: 2025-11-25T14:38:32.328Z
Learning: Applies to **/*.{ts,tsx} : Use kebab-case for PostHog feature flag keys (e.g., `inbox-cleaner`, `pricing-options-2`)
Applied to files:
apps/web/utils/parse/unsubscribe.ts
🧬 Code graph analysis (3)
apps/web/utils/parse/unsubscribe.test.ts (1)
apps/web/utils/parse/unsubscribe.ts (1)
containsUnsubscribeKeyword(9-12)
apps/web/utils/action-item.test.ts (1)
apps/web/utils/action-item.ts (3)
actionInputs(4-155)getActionFields(157-182)sanitizeActionFields(200-289)
apps/web/utils/action-sort.test.ts (1)
apps/web/utils/action-sort.ts (1)
sortActionsByPriority(41-49)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Baz Reviewer
- GitHub Check: test
🔇 Additional comments (13)
apps/web/utils/parse/unsubscribe.ts (1)
9-12: LGTM! Case-insensitive matching implemented correctly.The implementation efficiently converts the input text to lowercase once and compares against the already-lowercase keywords. This ensures consistent keyword detection regardless of text casing.
apps/web/utils/parse/unsubscribe.test.ts (1)
1-91: LGTM! Excellent test coverage and organization.The test suite is comprehensive and well-structured:
- All five keywords are individually tested
- Matching behavior is verified at different text positions
- Case insensitivity is thoroughly validated with multiple test cases
- Negative cases ensure no false positives
- Test names are descriptive and clearly indicate what's being tested
- Follows coding guidelines (vitest, co-location, proper naming convention)
apps/web/utils/action-sort.ts (1)
23-23: LGTM! NOTIFY_SENDER positioned appropriately.The placement of
NOTIFY_SENDERbetweenMARK_SPAMandCALL_WEBHOOKis logical and matches the test expectations.apps/web/utils/action-sort.test.ts (3)
6-52: LGTM! Basic sorting tests are comprehensive.The tests cover key sorting relationships and action grouping correctly.
87-153: LGTM! Edge case coverage is thorough.Tests properly verify empty arrays, single actions, duplicates, property preservation, and non-mutation of the original array.
155-169: LGTM! NOTIFY_SENDER placement test is correct.The test correctly verifies that
NOTIFY_SENDERappears afterLABELand beforeCALL_WEBHOOK.apps/web/utils/action-item.test.ts (3)
9-44: LGTM! ActionInputs tests are comprehensive.Tests verify all action types have configuration and validate specific field requirements for different action types.
46-103: LGTM! Field extraction tests are thorough.Tests correctly verify that only truthy values are returned, empty strings and nulls are excluded, and all populated fields are preserved.
105-295: LGTM! Sanitization tests comprehensively cover all action types.Tests verify correct field preservation and nullification for each action type, including the new
NOTIFY_SENDERtype anddelayInMinuteshandling.apps/web/utils/parse/cta.test.ts (4)
1-2: LGTM!Imports follow the project's testing conventions with proper vitest usage and co-located test file structure.
5-57: LGTM!Comprehensive coverage of CTA keyword detection with clear, descriptive test cases.
67-92: LGTM!Length constraint boundary tests are accurate and comprehensive, properly testing the 30-character limit.
116-128: LGTM!Position-based matching tests provide good coverage to ensure keywords are detected regardless of their location in the text.
| it("maintains correct priority order for all action types", () => { | ||
| const actions = [ | ||
| { type: ActionType.CALL_WEBHOOK }, | ||
| { type: ActionType.MARK_SPAM }, | ||
| { type: ActionType.DIGEST }, | ||
| { type: ActionType.FORWARD }, | ||
| { type: ActionType.SEND_EMAIL }, | ||
| { type: ActionType.REPLY }, | ||
| { type: ActionType.DRAFT_EMAIL }, | ||
| { type: ActionType.MARK_READ }, | ||
| { type: ActionType.ARCHIVE }, | ||
| { type: ActionType.MOVE_FOLDER }, | ||
| { type: ActionType.LABEL }, | ||
| ]; | ||
|
|
||
| const sorted = sortActionsByPriority(actions); | ||
| expect(sorted.map((a) => a.type)).toEqual([ | ||
| ActionType.LABEL, | ||
| ActionType.MOVE_FOLDER, | ||
| ActionType.ARCHIVE, | ||
| ActionType.MARK_READ, | ||
| ActionType.DRAFT_EMAIL, | ||
| ActionType.REPLY, | ||
| ActionType.SEND_EMAIL, | ||
| ActionType.FORWARD, | ||
| ActionType.DIGEST, | ||
| ActionType.MARK_SPAM, | ||
| ActionType.CALL_WEBHOOK, | ||
| ]); | ||
| }); |
There was a problem hiding this comment.
Test is incomplete – missing NOTIFY_SENDER.
The test claims to "maintain correct priority order for all action types" but doesn't include NOTIFY_SENDER in either the input or expected arrays. Since NOTIFY_SENDER was added to the priority order in action-sort.ts, this test should include it.
🔧 Proposed fix
it("maintains correct priority order for all action types", () => {
const actions = [
{ type: ActionType.CALL_WEBHOOK },
+ { type: ActionType.NOTIFY_SENDER },
{ type: ActionType.MARK_SPAM },
{ type: ActionType.DIGEST },
{ type: ActionType.FORWARD },
{ type: ActionType.SEND_EMAIL },
{ type: ActionType.REPLY },
{ type: ActionType.DRAFT_EMAIL },
{ type: ActionType.MARK_READ },
{ type: ActionType.ARCHIVE },
{ type: ActionType.MOVE_FOLDER },
{ type: ActionType.LABEL },
];
const sorted = sortActionsByPriority(actions);
expect(sorted.map((a) => a.type)).toEqual([
ActionType.LABEL,
ActionType.MOVE_FOLDER,
ActionType.ARCHIVE,
ActionType.MARK_READ,
ActionType.DRAFT_EMAIL,
ActionType.REPLY,
ActionType.SEND_EMAIL,
ActionType.FORWARD,
ActionType.DIGEST,
ActionType.MARK_SPAM,
+ ActionType.NOTIFY_SENDER,
ActionType.CALL_WEBHOOK,
]);
});🤖 Prompt for AI Agents
In @apps/web/utils/action-sort.test.ts around lines 55 - 84, The test "maintains
correct priority order for all action types" is missing
ActionType.NOTIFY_SENDER; add { type: ActionType.NOTIFY_SENDER } to the input
actions array and include ActionType.NOTIFY_SENDER in the expected sorted array
returned from sortActionsByPriority, placing it at the correct position
according to the priority defined in action-sort.ts; update the assertions in
apps/web/utils/action-sort.test.ts so the input, call to sortActionsByPriority,
and expected arrays both contain NOTIFY_SENDER using the same ActionType symbol.
| it("returns true for text exactly 29 characters with keyword", () => { | ||
| // "view it on GitHub" is 17 chars, add 12 more to get 29 | ||
| const text = "view it on GitHub123456"; | ||
| expect(text.length).toBe(23); | ||
| expect(containsCtaKeyword(text)).toBe(true); | ||
| }); |
There was a problem hiding this comment.
Fix test name or text length - inconsistency detected.
The test name claims "text exactly 29 characters" but the assertion on line 63 verifies the text is 23 characters. The comment on line 61 also incorrectly states the math. Either update the test name to reflect 23 characters or adjust the text to actually be 29 characters.
🔧 Suggested fix
Option 1: Update the test name to match the actual length:
- it("returns true for text exactly 29 characters with keyword", () => {
- // "view it on GitHub" is 17 chars, add 12 more to get 29
+ it("returns true for text with keyword (23 characters)", () => {
+ // "view it on GitHub123456" is 23 chars
const text = "view it on GitHub123456";
expect(text.length).toBe(23);
expect(containsCtaKeyword(text)).toBe(true);
});Option 2: Adjust the text to be 29 characters:
it("returns true for text exactly 29 characters with keyword", () => {
- // "view it on GitHub" is 17 chars, add 12 more to get 29
- const text = "view it on GitHub123456";
- expect(text.length).toBe(23);
+ // Exactly 29 characters with keyword
+ const text = "view it on GitHub12345678901"; // 29 chars
+ expect(text.length).toBe(29);
expect(containsCtaKeyword(text)).toBe(true);
});📝 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.
| it("returns true for text exactly 29 characters with keyword", () => { | |
| // "view it on GitHub" is 17 chars, add 12 more to get 29 | |
| const text = "view it on GitHub123456"; | |
| expect(text.length).toBe(23); | |
| expect(containsCtaKeyword(text)).toBe(true); | |
| }); | |
| it("returns true for text with keyword (23 characters)", () => { | |
| // "view it on GitHub123456" is 23 chars | |
| const text = "view it on GitHub123456"; | |
| expect(text.length).toBe(23); | |
| expect(containsCtaKeyword(text)).toBe(true); | |
| }); |
🤖 Prompt for AI Agents
In @apps/web/utils/parse/cta.test.ts around lines 60 - 65, The test "returns
true for text exactly 29 characters with keyword" is inconsistent: the text
variable ("view it on GitHub123456") and its length assertion use 23, not 29;
update the test to be consistent by either (A) renaming the test description and
comment to say 23 characters (and keep expect(text.length).toBe(23)) or (B)
change the text string so it is actually 29 characters and update the
expect(text.length) to 29; adjust the inline comment accordingly and leave the
containsCtaKeyword(text) assertion as-is.
| it("is case sensitive - does not match uppercase", () => { | ||
| expect(containsCtaKeyword("VIEW IT")).toBe(false); | ||
| }); | ||
|
|
||
| it("is case sensitive - does not match title case", () => { | ||
| expect(containsCtaKeyword("View It")).toBe(false); | ||
| }); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat apps/web/utils/parse/cta.tsRepository: elie222/inbox-zero
Length of output: 667
🏁 Script executed:
cat apps/web/utils/parse/unsubscribe.tsRepository: elie222/inbox-zero
Length of output: 382
Make containsCtaKeyword case-insensitive to match common email button formatting.
The function is case-sensitive and will miss CTA buttons using uppercase or title case. Compare the implementations:
containsCtaKeyword: Checkstext.includes(keyword)without lowercasing → rejects "VIEW IT" and "View It"containsUnsubscribeKeyword: Usestext.toLowerCase()before checking → handles all case variations
CTA buttons commonly use uppercase or title case for visual emphasis (e.g., "VIEW DETAILS", "CONFIRM", "Reply Now"). Apply the same case-insensitive pattern used in containsUnsubscribeKeyword to avoid missing valid CTAs.
🤖 Prompt for AI Agents
In @apps/web/utils/parse/cta.test.ts around lines 107 - 113, The
containsCtaKeyword function is case-sensitive and misses common CTA casing;
update it to normalize case like containsUnsubscribeKeyword by comparing
text.toLowerCase() (and keywords lowercased) when checking includes, and then
update the related tests ("is case sensitive - does not match uppercase"/"title
case") to expect true (or remove those negative tests) so CTA strings like "VIEW
IT" and "View It" are recognized.
User description
Summary
Add 83 new tests covering critical utility functions that previously lacked test coverage.
Bug Fixes
.trim()).default()fromconditionalOperatorfieldTest plan
🤖 Generated with Claude Code
Generated description
Below is a concise technical summary of the changes proposed in this PR:
Adds comprehensive test coverage for core utility functions, including email parsing, URL generation, and rule validation schemas. Refines rule validation logic and action sorting behavior.
createRuleBodyanddelayInMinutesSchemaZod schemas, ensuring robust validation for rule creation data. Fixes a bug increateRuleBodywhere rule names with only whitespace were considered valid by adding.trim(), and removes an ineffective.default()value from theconditionalOperatorfield.Modified files (2)
Latest Contributors(2)
getActionFields,sanitizeActionFields), action sorting logic (sortActionsByPriority), ignored sender filtering (isIgnoredSender), CTA and unsubscribe keyword detection (containsCtaKeyword,containsUnsubscribeKeyword), template variable parsing (hasVariables), and text slugification (slugify). Also updates theACTION_PRIORITY_ORDERto includeActionType.NOTIFY_SENDERand modifiescontainsUnsubscribeKeywordfor case-insensitive matching.Modified files (9)
Latest Contributors(1)
emailToContent), HTML-to-text conversion (convertEmailHtmlToText), reply parsing (parseReply), and email client identification (getEmailClient). Also adds tests for URL generation functions, ensuring correct construction of Gmail and Outlook links, search queries, and filter settings URLs.Modified files (2)
Latest Contributors(0)
Summary by CodeRabbit
Bug Fixes
New Features
✏️ Tip: You can customize this high-level summary in your review settings.