Skip to content

Test/remove email code todo comment #6603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

Sahil4883
Copy link

@Sahil4883 Sahil4883 commented Aug 21, 2025

Description

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other: useless TODO removal

Summary by CodeRabbit

  • Tests

    • Enabled a previously skipped unit test by converting it to Vitest, improving coverage of memoized state listener behavior.
    • Removed a redundant skipped integration test related to sign-in flow.
  • Chores

    • Updated development dependencies, including @types/node, and added tooling packages (@vitejs/plugin-vue, csstype).
    • No user-facing changes; build and test tooling improved.

Copy link

changeset-bot bot commented Aug 21, 2025

⚠️ No Changeset found

Latest commit: 8b763c9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Aug 21, 2025

@Sahil4883 is attempting to deploy a commit to the Clerk Production Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Aug 21, 2025

📝 Walkthrough

Walkthrough

  • integration/tests/email-code.test.ts: Removed a skipped test block and its TODO comment; no functional test logic added or changed.
  • package.json: Bumped @types/node devDependency to ^22.17.2; added devDependencies @vitejs/plugin-vue ^5.2.4 and csstype 3.1.3.
  • packages/clerk-js/src/utils/tests/memoizeStateListenerCallback.spec.ts: Replaced a skipped Jest scaffold with an active Vitest test validating memoizeListenerCallback returns the same user reference when state is unchanged; added necessary Vitest imports.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts (2)

13-18: Avoid any in tests; keep types tight and local

You can keep this test type-safe without leaking repo types by deriving from the local literals.

Apply:

-    let calledWith: any;
+    let calledWith: typeof user1 | undefined;
     const listener = memoizeListenerCallback(
-      vi.fn((e: any) => {
+      vi.fn((e: { user: typeof user1 }) => {
         calledWith = e.user;
       }),
     );

7-23: Strengthen the assertion by inspecting both callback invocations

Capturing only the last call hides whether the first and second user refs matched. Using the spy’s call history makes the intent explicit.

Alternative (if you prefer clearer assertions):

-    let calledWith: typeof user1 | undefined;
-    const listener = memoizeListenerCallback(
-      vi.fn((e: { user: typeof user1 }) => {
-        calledWith = e.user;
-      }),
-    );
-
-    listener({ user: user1 });
-    listener({ user: user2 });
-    expect(calledWith).toBe(user1);
-    expect(calledWith).not.toBe(user2);
+    const cb = vi.fn((e: { user: typeof user1 }) => e);
+    const listener = memoizeListenerCallback(cb as any);
+    listener({ user: user1 });
+    listener({ user: user2 });
+    const firstUser = (cb.mock.calls[0][0] as any).user;
+    const secondUser = (cb.mock.calls[1][0] as any).user;
+    expect(secondUser).toBe(firstUser);

Also, the top-of-file TODO about “jest” looks stale now that this file runs under Vitest—consider removing or updating it.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ce49740 and 8b763c9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • integration/tests/email-code.test.ts (0 hunks)
  • package.json (1 hunks)
  • packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • integration/tests/email-code.test.ts
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • package.json
  • packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
**/*

⚙️ CodeRabbit configuration file

If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.

Files:

  • package.json
  • packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
packages/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Unit tests should use Jest or Vitest as the test runner.

Files:

  • packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Visual regression testing should be performed for UI components.

Files:

  • packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
**/__tests__/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces

Files:

  • packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
🧬 Code graph analysis (1)
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts (1)
packages/clerk-js/src/utils/memoizeStateListenerCallback.ts (1)
  • memoizeListenerCallback (139-146)
🪛 ESLint
packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts

[error] 4-5: Run autofix to sort these imports!

(simple-import-sort/imports)

⏰ 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: semgrep-cloud-platform/scan
🔇 Additional comments (3)
package.json (2)

96-96: Verify placement of csstype dependency

Our search shows csstype is only imported in the types package (packages/types/src/appearance.ts), not at the root or in UI/leaf packages. To prevent scope creep, please:

  • Confirm that csstype is declared in packages/types/package.json (e.g., under dependencies or devDependencies as appropriate).
  • Remove the "csstype": "3.1.3" entry from the root package.json if it isn’t needed by any other package.

This ensures type-only dependencies stay colocated with the code that consumes them.


85-85: Node types bump: resolve csstype declaration error and verify workspace-wide type compatibility

It looks like the pnpm build:declarations step is currently failing in @clerk/types due to a missing module declaration for csstype. Before you can confidently validate that bumping @types/node to ^22.17.2 introduces no regressions, please:

• packages/types/package.json
– Confirm csstype: "3.1.3" is installed (it is), and that its .d.ts files are being picked up by the compiler.
– If necessary, add a "types" entry or adjust your tsconfig.json’s typeRoots/include so that node_modules/csstype is scanned.

• packages/types/src/appearance.ts (line 1)
– Fix the import error on import type * as CSS from 'csstype'; so that the DTS build completes without errors.

Once the above is addressed, rerun your workspace type-validation pipeline:

pnpm install
pnpm build:declarations
pnpm -w turbo lint
pnpm -w tsc --noEmit

This will surface any subtle changes to globals (e.g., fetch, Blob, WebSocket) or timer types that may have shifted with the new @types/node release.

packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts (1)

4-5: Action: Sort imports in memoizeStateListenerCallback.spec.ts

The test file packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts is still triggering the ESLint rule simple-import-sort/imports. To resolve:

  • Ensure your local dependencies are up to date:
    pnpm install
  • Apply the autofix for the Clerk-JS package:
    pnpm --filter @clerk/clerk-js lint --fix
    or, from the monorepo root:
    pnpm lint:fix
  • Commit any import-order changes in that spec file.

If running pnpm lint:fix still errors out (e.g. due to unrelated build issues in other packages), please manually reorder the imports in this file to match the project’s import grouping and sorting conventions so that CI no longer reports an import-order failure.

"@types/react": "catalog:react",
"@types/react-dom": "catalog:react",
"@vitejs/plugin-react": "^4.5.2",
"@vitejs/plugin-vue": "^5.2.4",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Out-of-scope dependency: confirm @vitejs/plugin-vue is actually needed at the repo root

Adding @vitejs/plugin-vue at the root increases install time and security surface. If it’s only used by a specific integration app/example, keep it local to that package. If unused, remove it to keep this PR scoped to “remove TODO”.

Search for usages:

If unused at the root, apply:

-    "@vitejs/plugin-vue": "^5.2.4",

🏁 Script executed:

#!/bin/bash
rg -n --hidden --glob '!**/node_modules/**' "@vitejs/plugin-vue|pluginVue|vue\(\)" -C2

Length of output: 5278


Remove unused @vitejs/plugin-vue from root package.json

This dependency is only imported and used within packages/vue (in its Vitest config) and in the integration templates—not by any root-level Vite or test configuration. Keeping it at the repo root adds unnecessary install time and security surface.

• File: package.json (root)
Line 89:

-    "@vitejs/plugin-vue": "^5.2.4",

Please remove this line to scope @vitejs/plugin-vue only to the packages that actually consume it.

📝 Committable suggestion

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

Suggested change
"@vitejs/plugin-vue": "^5.2.4",
// (Line removed; no remaining lines in this snippet)
🤖 Prompt for AI Agents
In package.json around line 89, remove the root dependency entry for
"@vitejs/plugin-vue" (the line at 89) because it is only used in packages/vue
and integration templates; delete that single dependency line from the root
package.json, run the package manager (npm/yarn/pnpm) to update the lockfile,
and verify no root-level code or configs import it (leave the dependency in
packages/vue and templates where it is actually consumed).


listener({ user: user1 });
listener({ user: user2 });
expect(calledWith).toStrictEqual(user1);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix assertion to verify referential equality (identity), not deep equality

toStrictEqual checks structural equality and will pass even if a new object with the same shape is produced. To ensure memoization preserves the same reference, use toBe.

Apply:

-    expect(calledWith).toStrictEqual(user1);
+    expect(calledWith).toBe(user1);
+    expect(calledWith).not.toBe(user2);
📝 Committable suggestion

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

Suggested change
expect(calledWith).toStrictEqual(user1);
expect(calledWith).toBe(user1);
expect(calledWith).not.toBe(user2);
🤖 Prompt for AI Agents
In packages/clerk-js/src/utils/__tests__/memoizeStateListenerCallback.spec.ts
around line 22, the test currently uses toStrictEqual to assert the callback
argument which checks deep equality; update the assertion to use toBe so it
verifies referential identity (the same object instance) to ensure memoization
preserved the exact reference. Replace the expect(...) assertion to use toBe
with the original user1 variable and run the test suite to confirm behavior.

@wobsoriano
Copy link
Member

We're closing this and similar PRs as they appear to be arbitrary code changes rather than targeted fixes. For future contributions, please ensure PRs include clear explanations of the changes and their necessity.

@wobsoriano wobsoriano closed this Aug 24, 2025
This was referenced Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants