Skip to content

Conversation

@priscilladeroode
Copy link
Contributor

@priscilladeroode priscilladeroode commented Feb 24, 2025

Acceptance Criteria

As a user, I would like to be able to click on users's profile photo and name in the comments so I can be redirected to their profile.

Users should be able to click on a user's avatar and name in the comments and comment thread and be redirected to the user-they-clicked-on's profile page in the same window/tab

Summary by CodeRabbit

  • New Features

    • Enhanced comment interaction: avatars and usernames within comments are now clickable, allowing seamless redirection to user profile pages. A default profile path is preset to ensure smooth navigation while still allowing for customization.
  • Chores

    • Updated the package version to 1.0.15.
  • Tests

    • Introduced a new custom Cypress command to mock the Next.js router, improving testing capabilities for components relying on routing. Enhanced the testing framework to better simulate routing behavior for the Comments component.

@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2025

⚠️ No Changeset found

Latest commit: 67817d2

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

@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2025

Walkthrough

This pull request updates the CommentItem component by introducing a new ClickableAvatar with an onClick event that navigates to the user profile page. The username is also wrapped with a clickable link leading to the same profile path. A new profilePath prop (with a default value of /profile) is added to the component and its TypeScript interface. Additionally, a custom Cypress command mockNextRouter is introduced for testing, and the package.json version is incremented.

Changes

File(s) Change Summary
packages/components/.../CommentItem/index.tsx
packages/components/.../CommentItem/types.ts
- Added a new optional profilePath prop (default: /profile) to CommentItem and its type definition.
- Replaced AvatarWithPlaceholder with ClickableAvatar and added navigation via an onClick event.
- Wrapped the user’s name in a Link component to navigate to the profile page.
packages/components/package.json - Updated version from 1.0.14 to 1.0.15.
packages/components/cypress/support/commands.ts
packages/components/cypress/support/types.ts
- Introduced a new custom Cypress command mockNextRouter to simulate router behavior in tests.
- Added RouterChainable type definition for encapsulating router-related methods and state.
packages/components/modules/comments/web/Comments/__tests__/Comments.cy.tsx - Integrated AppRouterContext from Next.js for testing the Comments component, ensuring accurate routing behavior during tests.
packages/components/CHANGELOG.md - Added new version entry ## 1.0.15 with a patch change for "clickable profile on comments".

Suggested reviewers

  • Ronan-Fernandes
  • anicioalexandre
  • deboracosilveira

Poem

Hoppin' through the lines of code so bright,
I tweak a link and set the path just right.
Clickable avatars now lead the way,
Navigating profiles with just one play.
A rabbit's cheer in every line—let's hop and code all day!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/components/cypress/support/types.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /packages/components/.eslintrc.js
Error: Cannot find module '@baseapp-frontend/config/.eslintrc-with-restricted-paths.js'
Require stack:

  • /packages/components/.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/packages/components/.eslintrc.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
packages/components/modules/comments/web/Comments/__tests__/Comments.cy.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /packages/components/.eslintrc.js
Error: Cannot find module '@baseapp-frontend/config/.eslintrc-with-restricted-paths.js'
Require stack:

  • /packages/components/.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/packages/components/.eslintrc.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
packages/components/cypress/support/commands.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /packages/components/.eslintrc.js
Error: Cannot find module '@baseapp-frontend/config/.eslintrc-with-restricted-paths.js'
Require stack:

  • /packages/components/.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/packages/components/.eslintrc.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
  • 2 others

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e43ea0 and 67817d2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • packages/components/CHANGELOG.md (2 hunks)
  • packages/components/cypress/support/commands.ts (2 hunks)
  • packages/components/cypress/support/types.ts (1 hunks)
  • packages/components/modules/comments/web/CommentItem/index.tsx (4 hunks)
  • packages/components/modules/comments/web/CommentItem/types.ts (1 hunks)
  • packages/components/modules/comments/web/Comments/__tests__/Comments.cy.tsx (4 hunks)
  • packages/components/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/components/modules/comments/web/CommentItem/types.ts
  • packages/components/cypress/support/types.ts
  • packages/components/package.json
  • packages/components/modules/comments/web/CommentItem/index.tsx
  • packages/components/cypress/support/commands.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Build and Lint Packages
  • GitHub Check: Component Test Packages
🔇 Additional comments (6)
packages/components/CHANGELOG.md (1)

3-8: LGTM! Changelog entry correctly documents the new feature.

The addition of version 1.0.15 with the "Clickable profile on comments" feature aligns well with the PR objectives to allow users to click on profile photos and names in comments to navigate to user profiles.

packages/components/modules/comments/web/Comments/__tests__/Comments.cy.tsx (5)

3-5: LGTM! Added necessary imports for router functionality.

The additional imports from Next.js router are required to support testing the new clickable profile functionality.


32-43: LGTM! Proper test setup with router context.

The test has been properly updated to mount the component within a router context using AppRouterContext.Provider, which is necessary for testing components that use routing functionality.


190-201: LGTM! Consistent router context implementation.

This test case also correctly implements the router context pattern, ensuring consistent testing of navigation behavior across different test scenarios.


238-241: Remove duplicate router mocking.

The router is already being mocked by cy.mockNextRouter() on line 244. The manual router stub here is redundant and could lead to inconsistencies.

Apply this diff to remove the duplicate mocking:

-    const router = {
-      push: cy.stub().as('router:push'),
-    }
-    cy.stub(Router, 'useRouter').returns(router)

244-254: LGTM! Proper test setup with router context.

The test correctly uses mockNextRouter() and wraps the component in AppRouterContext.Provider to provide the routing context needed for testing the clickable profile functionality.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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

@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 (1)
packages/components/modules/comments/web/CommentItem/index.tsx (1)

39-39: Consider making the default profile path configurable.

While '/profile' is a reasonable default, consider making it configurable through environment variables or constants for better maintainability.

-  profilePath = '/profile',
+  profilePath = process.env.NEXT_PUBLIC_PROFILE_PATH || '/profile',

Also applies to: 46-46

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ebcd7a6 and af29c70.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/components/modules/comments/web/CommentItem/index.tsx (4 hunks)
  • packages/components/modules/comments/web/CommentItem/types.ts (1 hunks)
  • packages/components/package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
packages/components/modules/comments/web/CommentItem/types.ts (1)

37-37: LGTM! Well-structured interface extension.

The optional profilePath prop is correctly typed and maintains backward compatibility.

packages/components/modules/comments/web/CommentItem/index.tsx (1)

5-9: LGTM! Appropriate imports for navigation.

The imports align well with the feature requirements, using Next.js built-in components for client-side navigation.

packages/components/package.json (1)

69-100: LGTM! Explicit version pinning improves reproducibility.

Moving from catalog references to specific versions helps ensure consistent builds across environments.

Copy link

@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: 1

🧹 Nitpick comments (1)
packages/components/modules/comments/web/Comments/__tests__/Comments.cy.tsx (1)

32-42: Standardize test setup pattern across all test cases.

The test setup pattern varies across test cases. Consider extracting the common setup into a beforeEach hook or helper function for consistency.

Example refactor:

describe('Comments', () => {
  const setupTest = () => {
    const { environment, resolveMostRecentOperation } = createTestEnvironment()
    return cy.mockNextRouter()
      .then((router) => {
        cy.mount(
          <AppRouterContext.Provider value={router}>
            <CommentsForTesting environment={environment} />
          </AppRouterContext.Provider>,
        )
        return { environment, resolveMostRecentOperation }
      })
  }

  it('should render comments...', () => {
    setupTest().then(({ resolveMostRecentOperation }) => {
      resolveMostRecentOperation({ mockResolvers: commentsResolver })
      // rest of the test
    })
  })
})

Also applies to: 190-200, 244-254

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af29c70 and 6e43ea0.

📒 Files selected for processing (4)
  • packages/components/cypress/support/commands.ts (2 hunks)
  • packages/components/cypress/support/types.ts (1 hunks)
  • packages/components/modules/comments/web/CommentItem/index.tsx (4 hunks)
  • packages/components/modules/comments/web/Comments/__tests__/Comments.cy.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/components/modules/comments/web/CommentItem/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build and Lint Packages
  • GitHub Check: Component Test Packages
🔇 Additional comments (3)
packages/components/cypress/support/types.ts (1)

1-9: LGTM! Well-structured type definition for router mocking.

The RouterChainable type correctly defines all necessary router methods and properties needed for mocking the Next.js router in Cypress tests.

packages/components/cypress/support/commands.ts (2)

47-60: LGTM! Well-implemented router mocking command.

The command thoroughly stubs all router methods with proper aliasing for test assertions and returns a correctly typed mock router object.


62-68: LGTM! Proper type declaration for the custom command.

The global type declaration ensures TypeScript support for the new command.

@priscilladeroode priscilladeroode force-pushed the BA-2270-clickable-profile-in-comments branch from 6e43ea0 to 67817d2 Compare February 28, 2025 01:00
@sonarqubecloud
Copy link

@priscilladeroode priscilladeroode merged commit a271d70 into master Feb 28, 2025
8 checks passed
marcelopessini pushed a commit that referenced this pull request Feb 28, 2025
@nossila nossila deleted the BA-2270-clickable-profile-in-comments branch May 26, 2025 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants