Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds new Outlook E2E drafting tests and a reusable test helper to dynamically locate old messages; replaces hardcoded message IDs across tests with dynamic lookups; refactors email provider typing usage; centralizes Outlook not-found error detection; propagates modelName into LLM error handling; increases logging visibility; bumps version. Changes
Sequence Diagram(s)sequenceDiagram
participant Test as E2E Test
participant Provider as Email Provider
participant DB as Server/Prisma
participant Cleanup as Cleanup
Note over Test: Test setup
Test->>DB: Validate TEST_OUTLOOK_EMAIL / fetch account
DB-->>Test: account record
Test->>Provider: createEmailProvider(account)
Test->>Provider: findOldMessage(daysOld) / selectReplySourceMessage()
Provider->>DB: getMessagesWithPagination / getMessage
DB-->>Provider: messages
Provider-->>Test: {threadId, messageId} / reply source
rect rgb(200,220,255)
Note over Test,Provider: Draft create → fetch → assert
Test->>Provider: createDraft(content)
Provider-->>Test: draftId
Test->>Provider: getDraft(draftId)
Provider-->>Test: draft (id, threadId, content)
end
rect rgb(220,200,255)
Note over Test,Provider: Draft deletion and cleanup
Test->>Provider: deleteDraft(draftId)
alt known not-found / Outlook limitation
Provider-->>Test: error logged, test may continue
else success
Provider-->>Test: deleted
end
Test->>Cleanup: afterAll -> delete remaining drafted IDs
Cleanup->>Provider: deleteDraft()*
Provider-->>Cleanup: responses
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/__tests__/e2e/outlook-operations.test.ts (1)
460-462: Stop passing a never-resolving params Promise
params: new Promise(() => ({}))never resolves, so the route handler will hang the moment it doesawait params. Please return a resolved value instead so the test reflects real execution.- const response = await POST(mockRequest, { - params: new Promise(() => ({})), - }); + const response = await POST(mockRequest, { + params: Promise.resolve({}), + });
🧹 Nitpick comments (2)
apps/web/utils/llms/model.ts (1)
121-122: Consider inlining the API key resolution.The extraction of
aiGatewayApiKeyinto a separate variable doesn't add clarity since it's only used once immediately after. The inline version is more concise.Apply this diff to inline the API key:
case Provider.AI_GATEWAY: { const modelName = aiModel || Model.GEMINI_2_5_PRO_OPENROUTER; - const aiGatewayApiKey = aiApiKey || env.AI_GATEWAY_API_KEY; - const gateway = createGateway({ apiKey: aiGatewayApiKey }); + const gateway = createGateway({ apiKey: aiApiKey || env.AI_GATEWAY_API_KEY }); return {apps/web/__tests__/e2e/helpers.ts (1)
19-22: Enhance the error message with search criteria.The error message should include the search parameters (daysOld, cutoffDate) to help diagnose why no message was found.
Apply this diff to improve the error message:
const message = response.messages[0]; if (!message?.id || !message?.threadId) { - throw new Error("No old message found for testing"); + throw new Error( + `No old message found for testing (searched for messages before ${cutoffDate.toISOString()}, ${daysOld} days old)`, + ); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
apps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts(1 hunks)apps/web/__tests__/e2e/helpers.ts(1 hunks)apps/web/__tests__/e2e/labeling/microsoft-labeling.test.ts(9 hunks)apps/web/__tests__/e2e/outlook-operations.test.ts(6 hunks)apps/web/utils/llms/index.ts(3 hunks)apps/web/utils/llms/model.ts(1 hunks)apps/web/utils/outlook/draft.ts(2 hunks)apps/web/utils/webhook/process-history-item.ts(1 hunks)apps/web/utils/webhook/validate-webhook-account.ts(2 hunks)version.txt(1 hunks)
🧰 Additional context used
📓 Path-based instructions (18)
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Path aliases: Use@/for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Leverage TypeScript inference for better DX
Files:
apps/web/utils/llms/model.tsapps/web/utils/webhook/validate-webhook-account.tsapps/web/utils/webhook/process-history-item.tsapps/web/utils/outlook/draft.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/helpers.tsapps/web/utils/llms/index.ts
!{.cursor/rules/*.mdc}
📄 CodeRabbit inference engine (.cursor/rules/cursor-rules.mdc)
Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location
Files:
apps/web/utils/llms/model.tsapps/web/utils/webhook/validate-webhook-account.tsapps/web/utils/webhook/process-history-item.tsversion.txtapps/web/utils/outlook/draft.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/helpers.tsapps/web/utils/llms/index.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod
Files:
apps/web/utils/llms/model.tsapps/web/utils/webhook/validate-webhook-account.tsapps/web/utils/webhook/process-history-item.tsapps/web/utils/outlook/draft.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/helpers.tsapps/web/utils/llms/index.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)
**/*.{ts,tsx}: UsecreateScopedLoggerfor logging in backend TypeScript files
Typically add the logger initialization at the top of the file when usingcreateScopedLogger
Only use.with()on a logger instance within a specific function, not for a global loggerImport Prisma in the project using
import prisma from "@/utils/prisma";
**/*.{ts,tsx}: Don't use TypeScript enums.
Don't use TypeScript const enum.
Don't use the TypeScript directive @ts-ignore.
Don't use primitive type aliases or misleading types.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use implicit any type on variable declarations.
Don't let variables evolve into any type through reassignments.
Don't use non-null assertions with the ! postfix operator.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use export type for types.
Use import type for types.
Don't declare empty interfaces.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use TypeScript namespaces.
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 parameter properties in class constructors.
Use either T[] or Array consistently.
Initialize each enum member value explicitly.
Make sure all enum members are literal values.
Files:
apps/web/utils/llms/model.tsapps/web/utils/webhook/validate-webhook-account.tsapps/web/utils/webhook/process-history-item.tsapps/web/utils/outlook/draft.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/helpers.tsapps/web/utils/llms/index.ts
apps/web/utils/**
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
Create utility functions in
utils/folder for reusable logic
Files:
apps/web/utils/llms/model.tsapps/web/utils/webhook/validate-webhook-account.tsapps/web/utils/webhook/process-history-item.tsapps/web/utils/outlook/draft.tsapps/web/utils/llms/index.ts
apps/web/utils/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
apps/web/utils/**/*.ts: Use lodash utilities for common operations (arrays, objects, strings)
Import specific lodash functions to minimize bundle size
Files:
apps/web/utils/llms/model.tsapps/web/utils/webhook/validate-webhook-account.tsapps/web/utils/webhook/process-history-item.tsapps/web/utils/outlook/draft.tsapps/web/utils/llms/index.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useelements in Next.js projects.
Don't use elements in Next.js projects.
Don't use namespace imports.
Don't access namespace imports dynamically.
Don't use global eval().
Don't use console.
Don't use debugger.
Don't use var.
Don't use with statements in non-strict contexts.
Don't use the arguments object.
Don't use consecutive spaces in regular expression literals.
Don't use the comma operator.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names th...
Files:
apps/web/utils/llms/model.tsapps/web/utils/webhook/validate-webhook-account.tsapps/web/utils/webhook/process-history-item.tsapps/web/utils/outlook/draft.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/helpers.tsapps/web/utils/llms/index.ts
!pages/_document.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
!pages/_document.{js,jsx,ts,tsx}: Don't import next/document outside of pages/_document.jsx in Next.js projects.
Don't import next/document outside of pages/_document.jsx in Next.js projects.
Files:
apps/web/utils/llms/model.tsapps/web/utils/webhook/validate-webhook-account.tsapps/web/utils/webhook/process-history-item.tsversion.txtapps/web/utils/outlook/draft.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/helpers.tsapps/web/utils/llms/index.ts
apps/web/utils/llms/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/llm.mdc)
Place core LLM utilities and configurations under apps/web/utils/llms/
Files:
apps/web/utils/llms/model.tsapps/web/utils/llms/index.ts
apps/web/utils/llms/model.ts
📄 CodeRabbit inference engine (.cursor/rules/llm.mdc)
Define model definitions and configurations in apps/web/utils/llms/model.ts
Files:
apps/web/utils/llms/model.ts
apps/web/utils/{ai,llms}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/llm.mdc)
Keep related AI functions co-located and extract common patterns into utilities; document complex AI logic with clear comments
Files:
apps/web/utils/llms/model.tsapps/web/utils/llms/index.ts
**/*.test.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/security.mdc)
Include security tests in your test suites to verify authentication, authorization, and error handling.
Files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.ts
**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{test,spec}.{js,jsx,ts,tsx}: Don't use export or module.exports in test files.
Don't use focused tests.
Don't use disabled tests.
Make sure the assertion function, like expect, is placed inside an it() function call.
Don't nest describe() blocks too deeply in test files.
Don't use focused tests.
Don't use disabled tests.
Don't use export or module.exports in test files.
Files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.ts
apps/web/__tests__/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/llm.mdc)
Place LLM-specific tests under apps/web/tests/
Files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/helpers.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
**/*.test.{ts,tsx}: Use Vitest (vitest) as the testing framework
Colocate tests next to the file under test (e.g., dir/format.ts with dir/format.test.ts)
In tests, mock theserver-onlymodule withvi.mock("server-only", () => ({}));
When testing code that uses Prisma, mock it withvi.mock("@/utils/prisma")and use the mock from@/utils/__mocks__/prisma
Use provided helpers for mocks: import{ getEmail, getEmailAccount, getRule }from@/__tests__/helpers
Each test should be independent
Use descriptive test names
Mock external dependencies in tests
Clean up mocks between tests (e.g.,vi.clearAllMocks()inbeforeEach)
Avoid testing implementation details; focus on observable behavior
Do not mock the Logger
Files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.ts
**/__tests__/**
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
Place AI tests in the
__tests__directory and exclude them from the default test run (they use a real LLM)
Files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/helpers.ts
apps/web/__tests__/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/llm-test.mdc)
apps/web/__tests__/**/*.test.ts: Place all LLM-related tests under apps/web/tests/
Use Vitest in LLM tests and import { describe, expect, test, vi, beforeEach } from "vitest"
Mock the Next.js server runtime marker by adding vi.mock("server-only", () => ({})) in LLM tests
Gate LLM tests behind RUN_AI_TESTS using describe.runIf(process.env.RUN_AI_TESTS === "true")
Call vi.clearAllMocks() in a beforeEach for LLM tests
Set a TIMEOUT of 15_000ms for LLM-related tests and pass it to long-running tests/describe blocks
Create helper functions for common test data (e.g., getUser, getTestData) to reduce duplication
Include standard test cases: happy path, error handling, edge cases (empty/null), different user configurations, and various input formats
Use console.debug to log generated LLM content for inspection (e.g., console.debug("Generated content:\n", result.content))
Do not mock the actual LLM call in these tests; exercise real LLM integrations
Test both AI and non-AI paths, including cases where no AI processing is required
Prefer existing helpers from @/tests/helpers.ts (getEmailAccount, getEmail, getRule, getMockMessage, getMockExecutedRule) over custom helpers
Files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.ts
apps/web/utils/llms/index.ts
📄 CodeRabbit inference engine (.cursor/rules/llm.mdc)
Maintain core LLM functionality in apps/web/utils/llms/index.ts
Files:
apps/web/utils/llms/index.ts
🧠 Learnings (31)
📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-09-17T22:05:28.646Z
Learning: Applies to apps/web/utils/{ai,llms}/**/*.{ts,tsx} : Keep related AI functions co-located and extract common patterns into utilities; document complex AI logic with clear comments
Applied to files:
apps/web/utils/llms/model.tsapps/web/utils/webhook/validate-webhook-account.tsapps/web/utils/llms/index.ts
📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-09-17T22:05:28.646Z
Learning: Applies to apps/web/utils/ai/**/*.{ts,tsx} : Use proper error types and logging for failures
Applied to files:
apps/web/utils/webhook/validate-webhook-account.tsapps/web/utils/webhook/process-history-item.tsapps/web/utils/llms/index.ts
📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-09-17T22:05:28.646Z
Learning: Applies to apps/web/utils/ai/**/*.{ts,tsx} : Log inputs and outputs with appropriate log levels and include relevant context
Applied to files:
apps/web/utils/webhook/validate-webhook-account.ts
📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-09-17T22:05:28.646Z
Learning: Applies to apps/web/utils/ai/**/*.{ts,tsx} : Use descriptive scoped loggers for each feature
Applied to files:
apps/web/utils/webhook/validate-webhook-account.tsapps/web/utils/webhook/process-history-item.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Test both AI and non-AI paths, including cases where no AI processing is required
Applied to files:
apps/web/utils/webhook/validate-webhook-account.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/helpers.ts
📚 Learning: 2025-07-18T15:04:30.467Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.467Z
Learning: Applies to apps/web/app/api/**/route.ts : Use `withEmailAccount` for email-account-level operations
Applied to files:
apps/web/utils/webhook/validate-webhook-account.ts
📚 Learning: 2025-07-20T09:03:06.318Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/ultracite.mdc:0-0
Timestamp: 2025-07-20T09:03:06.318Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Make sure to pass a message value when creating a built-in error.
Applied to files:
apps/web/utils/webhook/process-history-item.ts
📚 Learning: 2025-07-18T15:04:30.467Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: apps/web/CLAUDE.md:0-0
Timestamp: 2025-07-18T15:04:30.467Z
Learning: Applies to apps/web/**/*.{ts,tsx} : Use proper error handling with try/catch blocks
Applied to files:
apps/web/utils/webhook/process-history-item.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Prefer existing helpers from @/__tests__/helpers.ts (getEmailAccount, getEmail, getRule, getMockMessage, getMockExecutedRule) over custom helpers
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/helpers.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : Use provided helpers for mocks: import `{ getEmail, getEmailAccount, getRule }` from `@/__tests__/helpers`
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/helpers.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Include standard test cases: happy path, error handling, edge cases (empty/null), different user configurations, and various input formats
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/helpers.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : Avoid testing implementation details; focus on observable behavior
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Create helper functions for common test data (e.g., getUser, getTestData) to reduce duplication
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/helpers.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : Mock external dependencies in tests
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : In tests, mock the `server-only` module with `vi.mock("server-only", () => ({}));`
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Mock the Next.js server runtime marker by adding vi.mock("server-only", () => ({})) in LLM tests
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : When testing code that uses Prisma, mock it with `vi.mock("@/utils/prisma")` and use the mock from `@/utils/__mocks__/prisma`
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : Clean up mocks between tests (e.g., `vi.clearAllMocks()` in `beforeEach`)
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use Vitest in LLM tests and import { describe, expect, test, vi, beforeEach } from "vitest"
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Call vi.clearAllMocks() in a beforeEach for LLM tests
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Do not mock the actual LLM call in these tests; exercise real LLM integrations
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Gate LLM tests behind RUN_AI_TESTS using describe.runIf(process.env.RUN_AI_TESTS === "true")
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use console.debug to log generated LLM content for inspection (e.g., console.debug("Generated content:\n", result.content))
Applied to files:
apps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Run AI tests using: pnpm test-ai <feature>
Applied to files:
apps/web/__tests__/e2e/labeling/microsoft-labeling.test.ts
📚 Learning: 2025-07-18T15:05:34.899Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-07-18T15:05:34.899Z
Learning: Applies to apps/web/utils/gmail/**/*.ts : Keep provider-specific implementation details isolated in the appropriate utils subfolder (e.g., 'apps/web/utils/gmail/')
Applied to files:
apps/web/__tests__/e2e/helpers.ts
📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-09-17T22:05:28.646Z
Learning: Applies to apps/web/utils/ai/**/*.{ts,tsx} : LLM feature functions should follow the provided TypeScript pattern (separate system/user prompts, use createGenerateObject, Zod schema validation, early validation, return result.object)
Applied to files:
apps/web/utils/llms/index.ts
📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-09-17T22:05:28.646Z
Learning: Applies to apps/web/utils/llms/model.ts : Define model definitions and configurations in apps/web/utils/llms/model.ts
Applied to files:
apps/web/utils/llms/index.ts
📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-09-17T22:05:28.646Z
Learning: Applies to apps/web/utils/llms/index.ts : Maintain core LLM functionality in apps/web/utils/llms/index.ts
Applied to files:
apps/web/utils/llms/index.ts
📚 Learning: 2025-09-17T22:05:28.646Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm.mdc:0-0
Timestamp: 2025-09-17T22:05:28.646Z
Learning: Applies to apps/web/utils/ai/**/*.{ts,tsx} : Implement fallbacks for AI failures
Applied to files:
apps/web/utils/llms/index.ts
📚 Learning: 2025-07-20T09:00:41.968Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-07-20T09:00:41.968Z
Learning: Applies to apps/web/app/api/**/*.{ts,js} : Error messages in API routes must not reveal internal details; use generic errors and SafeError for user-facing errors.
Applied to files:
apps/web/utils/llms/index.ts
📚 Learning: 2025-07-20T09:00:41.968Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/security-audit.mdc:0-0
Timestamp: 2025-07-20T09:00:41.968Z
Learning: Applies to apps/web/app/api/**/*.{ts,js} : Review all new withError usage in API routes to ensure custom authentication is implemented where required.
Applied to files:
apps/web/utils/llms/index.ts
🧬 Code graph analysis (4)
apps/web/utils/llms/model.ts (1)
apps/web/env.ts (1)
env(16-242)
apps/web/utils/outlook/draft.ts (1)
apps/web/utils/prisma-helpers.ts (1)
isNotFoundError(14-19)
apps/web/__tests__/e2e/outlook-operations.test.ts (2)
apps/web/utils/email/provider.ts (1)
createEmailProvider(13-29)apps/web/__tests__/e2e/helpers.ts (1)
findOldMessage(7-28)
apps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts (4)
apps/web/utils/email/microsoft.ts (1)
OutlookProvider(70-1375)apps/web/utils/types.ts (1)
ParsedMessage(47-62)apps/web/utils/email/provider.ts (1)
createEmailProvider(13-29)apps/web/utils/email.ts (1)
extractEmailAddress(19-52)
⏰ 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). (1)
- GitHub Check: cubic · AI code reviewer
🔇 Additional comments (9)
apps/web/utils/webhook/process-history-item.ts (1)
210-212: LGTM!The error logging enhancement provides better observability while maintaining the existing error propagation flow.
apps/web/__tests__/e2e/labeling/microsoft-labeling.test.ts (2)
5-6: LGTM!The usage documentation correctly reflects the RUN_E2E_TESTS gating pattern.
216-216: Explicitly passinglabelName: nullis correct—ignore the original review comment.The
labelMessageinterface defineslabelName: string | null(no?), which makes it a required field. Since it is not optional (with?), it must always be provided; passingnullis the correct and necessary approach when no label name is available. This differs from optional fields, which can be omitted entirely.Likely an incorrect or invalid review comment.
apps/web/utils/outlook/draft.ts (2)
17-27: LGTM!The refactored error handling using the centralized
isNotFoundErrorhelper improves code maintainability.
39-59: LGTM!The
isNotFoundErrorhelper effectively centralizes not-found error detection across multiple Microsoft Graph API error formats, and the updateddeleteDraftgracefully handles already-deleted drafts.apps/web/utils/webhook/validate-webhook-account.ts (1)
122-125: LGTM!Upgrading these log statements from trace to info level appropriately reflects their operational significance, as these conditions trigger webhook unwatching or early returns.
Also applies to: 136-136
apps/web/utils/llms/index.ts (3)
108-108: LGTM!The error handling correctly propagates
modelNameto provide better debugging context for LLM failures.Also applies to: 113-113
176-176: LGTM!Error handling updated consistently with the new signature.
265-271: LGTM!The enhanced error handling signature provides valuable debugging context by logging the model name alongside error details.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts(1 hunks)apps/web/__tests__/e2e/gmail-operations.test.ts(2 hunks)apps/web/__tests__/e2e/labeling/google-labeling.test.ts(2 hunks)apps/web/__tests__/e2e/labeling/microsoft-labeling.test.ts(11 hunks)apps/web/__tests__/e2e/outlook-operations.test.ts(8 hunks)
🧰 Additional context used
📓 Path-based instructions (12)
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (apps/web/CLAUDE.md)
apps/web/**/*.{ts,tsx}: Use TypeScript with strict null checks
Path aliases: Use@/for imports from project root
Use proper error handling with try/catch blocks
Format code with Prettier
Leverage TypeScript inference for better DX
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
!{.cursor/rules/*.mdc}
📄 CodeRabbit inference engine (.cursor/rules/cursor-rules.mdc)
Never place rule files in the project root, in subdirectories outside .cursor/rules, or in any other location
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/form-handling.mdc)
**/*.ts: The same validation should be done in the server action too
Define validation schemas using Zod
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/logging.mdc)
**/*.{ts,tsx}: UsecreateScopedLoggerfor logging in backend TypeScript files
Typically add the logger initialization at the top of the file when usingcreateScopedLogger
Only use.with()on a logger instance within a specific function, not for a global loggerImport Prisma in the project using
import prisma from "@/utils/prisma";
**/*.{ts,tsx}: Don't use TypeScript enums.
Don't use TypeScript const enum.
Don't use the TypeScript directive @ts-ignore.
Don't use primitive type aliases or misleading types.
Don't use empty type parameters in type aliases and interfaces.
Don't use any or unknown as type constraints.
Don't use implicit any type on variable declarations.
Don't let variables evolve into any type through reassignments.
Don't use non-null assertions with the ! postfix operator.
Don't misuse the non-null assertion operator (!) in TypeScript files.
Don't use user-defined types.
Use as const instead of literal types and type annotations.
Use export type for types.
Use import type for types.
Don't declare empty interfaces.
Don't merge interfaces and classes unsafely.
Don't use overload signatures that aren't next to each other.
Use the namespace keyword instead of the module keyword to declare TypeScript namespaces.
Don't use TypeScript namespaces.
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 parameter properties in class constructors.
Use either T[] or Array consistently.
Initialize each enum member value explicitly.
Make sure all enum members are literal values.
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
**/*.test.{ts,js}
📄 CodeRabbit inference engine (.cursor/rules/security.mdc)
Include security tests in your test suites to verify authentication, authorization, and error handling.
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{js,jsx,ts,tsx}: Don't useelements in Next.js projects.
Don't use elements in Next.js projects.
Don't use namespace imports.
Don't access namespace imports dynamically.
Don't use global eval().
Don't use console.
Don't use debugger.
Don't use var.
Don't use with statements in non-strict contexts.
Don't use the arguments object.
Don't use consecutive spaces in regular expression literals.
Don't use the comma operator.
Don't use unnecessary boolean casts.
Don't use unnecessary callbacks with flatMap.
Use for...of statements instead of Array.forEach.
Don't create classes that only have static members (like a static namespace).
Don't use this and super in static contexts.
Don't use unnecessary catch clauses.
Don't use unnecessary constructors.
Don't use unnecessary continue statements.
Don't export empty modules that don't change anything.
Don't use unnecessary escape sequences in regular expression literals.
Don't use unnecessary labels.
Don't use unnecessary nested block statements.
Don't rename imports, exports, and destructured assignments to the same name.
Don't use unnecessary string or template literal concatenation.
Don't use String.raw in template literals when there are no escape sequences.
Don't use useless case statements in switch statements.
Don't use ternary operators when simpler alternatives exist.
Don't use useless this aliasing.
Don't initialize variables to undefined.
Don't use the void operators (they're not familiar).
Use arrow functions instead of function expressions.
Use Date.now() to get milliseconds since the Unix Epoch.
Use .flatMap() instead of map().flat() when possible.
Use literal property access instead of computed property access.
Don't use parseInt() or Number.parseInt() when binary, octal, or hexadecimal literals work.
Use concise optional chaining instead of chained logical expressions.
Use regular expression literals instead of the RegExp constructor when possible.
Don't use number literal object member names th...
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
!pages/_document.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
!pages/_document.{js,jsx,ts,tsx}: Don't import next/document outside of pages/_document.jsx in Next.js projects.
Don't import next/document outside of pages/_document.jsx in Next.js projects.
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/ultracite.mdc)
**/*.{test,spec}.{js,jsx,ts,tsx}: Don't use export or module.exports in test files.
Don't use focused tests.
Don't use disabled tests.
Make sure the assertion function, like expect, is placed inside an it() function call.
Don't nest describe() blocks too deeply in test files.
Don't use focused tests.
Don't use disabled tests.
Don't use export or module.exports in test files.
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
apps/web/__tests__/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/llm.mdc)
Place LLM-specific tests under apps/web/tests/
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
**/*.test.{ts,tsx}: Use Vitest (vitest) as the testing framework
Colocate tests next to the file under test (e.g., dir/format.ts with dir/format.test.ts)
In tests, mock theserver-onlymodule withvi.mock("server-only", () => ({}));
When testing code that uses Prisma, mock it withvi.mock("@/utils/prisma")and use the mock from@/utils/__mocks__/prisma
Use provided helpers for mocks: import{ getEmail, getEmailAccount, getRule }from@/__tests__/helpers
Each test should be independent
Use descriptive test names
Mock external dependencies in tests
Clean up mocks between tests (e.g.,vi.clearAllMocks()inbeforeEach)
Avoid testing implementation details; focus on observable behavior
Do not mock the Logger
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
**/__tests__/**
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
Place AI tests in the
__tests__directory and exclude them from the default test run (they use a real LLM)
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
apps/web/__tests__/**/*.test.ts
📄 CodeRabbit inference engine (.cursor/rules/llm-test.mdc)
apps/web/__tests__/**/*.test.ts: Place all LLM-related tests under apps/web/tests/
Use Vitest in LLM tests and import { describe, expect, test, vi, beforeEach } from "vitest"
Mock the Next.js server runtime marker by adding vi.mock("server-only", () => ({})) in LLM tests
Gate LLM tests behind RUN_AI_TESTS using describe.runIf(process.env.RUN_AI_TESTS === "true")
Call vi.clearAllMocks() in a beforeEach for LLM tests
Set a TIMEOUT of 15_000ms for LLM-related tests and pass it to long-running tests/describe blocks
Create helper functions for common test data (e.g., getUser, getTestData) to reduce duplication
Include standard test cases: happy path, error handling, edge cases (empty/null), different user configurations, and various input formats
Use console.debug to log generated LLM content for inspection (e.g., console.debug("Generated content:\n", result.content))
Do not mock the actual LLM call in these tests; exercise real LLM integrations
Test both AI and non-AI paths, including cases where no AI processing is required
Prefer existing helpers from @/tests/helpers.ts (getEmailAccount, getEmail, getRule, getMockMessage, getMockExecutedRule) over custom helpers
Files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
🧠 Learnings (22)
📓 Common learnings
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Prefer existing helpers from @/__tests__/helpers.ts (getEmailAccount, getEmail, getRule, getMockMessage, getMockExecutedRule) over custom helpers
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Prefer existing helpers from @/__tests__/helpers.ts (getEmailAccount, getEmail, getRule, getMockMessage, getMockExecutedRule) over custom helpers
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
📚 Learning: 2025-07-18T15:05:34.899Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/gmail-api.mdc:0-0
Timestamp: 2025-07-18T15:05:34.899Z
Learning: Applies to apps/web/utils/gmail/**/*.ts : Keep provider-specific implementation details isolated in the appropriate utils subfolder (e.g., 'apps/web/utils/gmail/')
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : Use provided helpers for mocks: import `{ getEmail, getEmailAccount, getRule }` from `@/__tests__/helpers`
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Test both AI and non-AI paths, including cases where no AI processing is required
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Gate LLM tests behind RUN_AI_TESTS using describe.runIf(process.env.RUN_AI_TESTS === "true")
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : When testing code that uses Prisma, mock it with `vi.mock("@/utils/prisma")` and use the mock from `@/utils/__mocks__/prisma`
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Create helper functions for common test data (e.g., getUser, getTestData) to reduce duplication
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : Mock external dependencies in tests
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use Vitest in LLM tests and import { describe, expect, test, vi, beforeEach } from "vitest"
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Include standard test cases: happy path, error handling, edge cases (empty/null), different user configurations, and various input formats
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : In tests, mock the `server-only` module with `vi.mock("server-only", () => ({}));`
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.tsapps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-07-08T13:14:07.449Z
Learnt from: elie222
Repo: elie222/inbox-zero PR: 537
File: apps/web/app/(app)/[emailAccountId]/clean/onboarding/page.tsx:30-34
Timestamp: 2025-07-08T13:14:07.449Z
Learning: The clean onboarding page in apps/web/app/(app)/[emailAccountId]/clean/onboarding/page.tsx is intentionally Gmail-specific and should show an error for non-Google email accounts rather than attempting to support multiple providers.
Applied to files:
apps/web/__tests__/e2e/gmail-operations.test.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : Use Vitest (`vitest`) as the testing framework
Applied to files:
apps/web/__tests__/e2e/labeling/microsoft-labeling.test.ts
📚 Learning: 2025-06-23T12:26:53.882Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/prisma.mdc:0-0
Timestamp: 2025-06-23T12:26:53.882Z
Learning: In this project, Prisma should be imported using 'import prisma from "@/utils/prisma";' in TypeScript files.
Applied to files:
apps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/labeling/google-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : Clean up mocks between tests (e.g., `vi.clearAllMocks()` in `beforeEach`)
Applied to files:
apps/web/__tests__/e2e/labeling/microsoft-labeling.test.tsapps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-09-20T18:24:34.280Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-09-20T18:24:34.280Z
Learning: Applies to **/*.test.{ts,tsx} : Avoid testing implementation details; focus on observable behavior
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.tsapps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Mock the Next.js server runtime marker by adding vi.mock("server-only", () => ({})) in LLM tests
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-07-19T17:50:28.270Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/utilities.mdc:0-0
Timestamp: 2025-07-19T17:50:28.270Z
Learning: The `utils` folder also contains core app logic such as Next.js Server Actions and Gmail API requests.
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Call vi.clearAllMocks() in a beforeEach for LLM tests
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Do not mock the actual LLM call in these tests; exercise real LLM integrations
Applied to files:
apps/web/__tests__/e2e/outlook-operations.test.ts
📚 Learning: 2025-10-02T23:23:48.064Z
Learnt from: CR
Repo: elie222/inbox-zero PR: 0
File: .cursor/rules/llm-test.mdc:0-0
Timestamp: 2025-10-02T23:23:48.064Z
Learning: Applies to apps/web/__tests__/**/*.test.ts : Use console.debug to log generated LLM content for inspection (e.g., console.debug("Generated content:\n", result.content))
Applied to files:
apps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts
🧬 Code graph analysis (5)
apps/web/__tests__/e2e/gmail-operations.test.ts (2)
apps/web/utils/email/provider.ts (1)
createEmailProvider(13-29)apps/web/__tests__/e2e/helpers.ts (1)
findOldMessage(7-28)
apps/web/__tests__/e2e/labeling/microsoft-labeling.test.ts (2)
apps/web/utils/email/provider.ts (1)
createEmailProvider(13-29)apps/web/__tests__/e2e/helpers.ts (1)
findOldMessage(7-28)
apps/web/__tests__/e2e/labeling/google-labeling.test.ts (1)
apps/web/__tests__/e2e/helpers.ts (1)
findOldMessage(7-28)
apps/web/__tests__/e2e/outlook-operations.test.ts (2)
apps/web/utils/email/provider.ts (1)
createEmailProvider(13-29)apps/web/__tests__/e2e/helpers.ts (1)
findOldMessage(7-28)
apps/web/__tests__/e2e/drafting/microsoft-drafting.test.ts (4)
apps/web/utils/types.ts (1)
ParsedMessage(47-62)apps/web/utils/email/provider.ts (1)
createEmailProvider(13-29)apps/web/__tests__/e2e/helpers.ts (1)
findOldMessage(7-28)apps/web/utils/email.ts (1)
extractEmailAddress(19-52)
⏰ 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). (2)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: test
| await prisma.emailAccount.update({ | ||
| where: { id: emailAccount.id }, | ||
| data: { watchEmailsSubscriptionId: MOCK_SUBSCRIPTION_ID }, | ||
| }); | ||
|
|
||
| // Make the account premium for testing | ||
| const user = await prisma.user.findUniqueOrThrow({ | ||
| where: { id: emailAccount.userId }, | ||
| include: { premium: true }, | ||
| }); | ||
|
|
||
| // Clear any existing aiApiKey to use env defaults | ||
| await prisma.user.update({ | ||
| where: { id: user.id }, | ||
| data: { aiApiKey: null }, | ||
| }); | ||
|
|
||
| if (!user.premium) { | ||
| const premium = await prisma.premium.create({ | ||
| data: { | ||
| tier: "BUSINESS_MONTHLY", | ||
| stripeSubscriptionStatus: "active", | ||
| }, | ||
| }); | ||
|
|
||
| await prisma.user.update({ | ||
| where: { id: user.id }, | ||
| data: { premiumId: premium.id }, | ||
| }); | ||
| } else { | ||
| await prisma.premium.update({ | ||
| where: { id: user.premium.id }, | ||
| data: { | ||
| stripeSubscriptionStatus: "active", | ||
| tier: "BUSINESS_MONTHLY", | ||
| }, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Avoid leaving fake subscription state behind
This block permanently overwrites watchEmailsSubscriptionId, clears the user’s aiApiKey, and forces the premium record to “BUSINESS_MONTHLY”. Because we don’t restore the previous values (or remove the synthetic premium we created), the Outlook account stays in this mocked state after the suite finishes, which breaks subsequent webhook runs and any other tests that rely on the real subscription/AI credentials.
Please capture the original subscription ID, AI key, and premium details before mutating them, run the webhook assertions inside a try/finally, and restore everything afterwards (deleting the temporary premium row if we created one). That keeps the fixture data stable between runs.
🤖 Prompt for AI Agents
In apps/web/__tests__/e2e/outlook-operations.test.ts around lines 353 to 390,
the test mutates watchEmailsSubscriptionId, aiApiKey, and the user's premium
record without restoring originals; capture the current
watchEmailsSubscriptionId, the user's aiApiKey, and the premiumId/premium row
(if any) before making changes, wrap the webhook assertions and any mutations in
a try/finally block, and in the finally restore the original
watchEmailsSubscriptionId and aiApiKey and revert the premium row to its
original values or delete the premium row you created if it didn’t exist prior
(or reset premiumId on the user if you created one), ensuring no synthetic
subscription or API key state is left after the test.
There was a problem hiding this comment.
1 issue found across 12 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="apps/web/__tests__/e2e/labeling/google-labeling.test.ts">
<violation number="1" location="apps/web/__tests__/e2e/labeling/google-labeling.test.ts:92">
Replacing the prior fallback with findOldMessage now searches for messages *older* than seven days (it calls getMessagesWithPagination({ before: cutoffDate })). Accounts that only contain recent mail—supported by the previous after>=7-days logic—will now throw "No old message found" and abort the test setup. This is a functional regression.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
|
|
||
| _TEST_GMAIL_MESSAGE_ID = messages[0].id; | ||
| _TEST_GMAIL_THREAD_ID = messages[0].threadId; | ||
| const oldMessage = await findOldMessage(provider, 7); |
There was a problem hiding this comment.
Replacing the prior fallback with findOldMessage now searches for messages older than seven days (it calls getMessagesWithPagination({ before: cutoffDate })). Accounts that only contain recent mail—supported by the previous after>=7-days logic—will now throw "No old message found" and abort the test setup. This is a functional regression.
Prompt for AI agents
Address the following comment on apps/web/__tests__/e2e/labeling/google-labeling.test.ts at line 92:
<comment>Replacing the prior fallback with findOldMessage now searches for messages *older* than seven days (it calls getMessagesWithPagination({ before: cutoffDate })). Accounts that only contain recent mail—supported by the previous after>=7-days logic—will now throw "No old message found" and abort the test setup. This is a functional regression.</comment>
<file context>
@@ -88,23 +89,9 @@ describe.skipIf(!RUN_E2E_TESTS)("Google Gmail Labeling E2E Tests", () => {
-
- _TEST_GMAIL_MESSAGE_ID = messages[0].id;
- _TEST_GMAIL_THREAD_ID = messages[0].threadId;
+ const oldMessage = await findOldMessage(provider, 7);
+ _TEST_GMAIL_MESSAGE_ID = oldMessage.messageId;
+ _TEST_GMAIL_THREAD_ID = oldMessage.threadId;
</file context>
Summary by CodeRabbit
Tests
Bug Fixes
Refactor
Chores