Skip to content
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

550-refactor: Widget mentors wanted #599

Merged
merged 13 commits into from
Oct 22, 2024
Merged

Conversation

KristiBo
Copy link
Collaborator

@KristiBo KristiBo commented Oct 9, 2024

What type of PR is this? (select all that apply)

  • πŸ• Feature
  • πŸ› Bug Fix
  • 🚧 Breaking Change
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ“ Documentation Update

Description

Widget mentors wanted refactor

Related Tickets & Documents

Screenshots, Recordings

image

Added/updated tests?

  • πŸ‘Œ Yes
  • πŸ™…β€β™‚οΈ No, because they aren't needed
  • πŸ™‹β€β™‚οΈ No, because I need help

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced the MentorsWantedCourse component, enhancing the mentoring section with new styling and functionality.
    • Added a new link for Angular mentoring resources.
  • Bug Fixes

    • Updated component references to reflect new naming conventions and ensure correct functionality.
  • Documentation

    • Enhanced testing coverage for the MentorsWantedCourse component to ensure proper rendering and content display.
  • Style

    • Revamped the styling for the "mentors wanted" section, improving layout and responsiveness.
    • Updated styles for the new MentorsWantedCourse component to align with design requirements.

Copy link

github-actions bot commented Oct 9, 2024

Lighthouse Report:

  • Performance: 85 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@KristiBo KristiBo marked this pull request as ready for review October 10, 2024 16:07
Copy link
Contributor

coderabbitai bot commented Oct 10, 2024

πŸ“ Walkthrough
πŸ“ Walkthrough

Walkthrough

The pull request introduces significant changes to the "mentors wanted" section, including a restructuring of CSS classes and the introduction of a new component, MentorsWantedCourse. The .mentors-wanted class is renamed to .mentors-container, with various layout adjustments and new styles added. Additionally, the Angular page is updated to utilize the new MentorsWantedCourse component, which links to an Angular mentoring resource. Unit tests for the new component are also established, ensuring its functionality within the application.

Changes

File Change Summary
src/widgets/mentors-wanted/ui/mentors-wanted.module.scss Renamed .mentors-wanted to .mentors-container, added .mentors-content, .mentors-info, and .sloth-mascot, modified styles.
src/app/const/index.ts Added ANGULAR_MENTORING link to LINKS constant.
src/pages/angular.tsx Replaced MentorsWanted with MentorsWantedCourse including link prop.
src/widgets/mentors-wanted-course/index.ts Added export for MentorsWantedCourse.
src/widgets/mentors-wanted-course/ui/mentors-wanted-course.module.scss Added new styles: .mentors-wanted, .mentors-wanted-content, .content-left, .sloth-mascot.
src/widgets/mentors-wanted-course/ui/mentors-wanted-course.test.tsx Created unit tests for MentorsWantedCourse.
src/widgets/mentors-wanted-course/ui/mentors-wanted-course.tsx Defined MentorsWantedCourse component with link prop.
src/pages/home.tsx Replaced Mentors component with MentorsWanted.
src/widgets/mentors-wanted/ui/mentors-wanted.test.tsx Updated tests to reflect the renaming of Mentors to MentorsWanted.
src/widgets/mentors-wanted/ui/mentors-wanted.tsx Updated imports and structure, added new class names and attributes.
src/widgets/mentors/index.ts Deleted file exporting Mentors component.

Assessment against linked issues

Objective Addressed Explanation
Refactor mentors-wanted.tsx's scss (550) βœ…
Create unit test for mentors-wanted component (550) βœ…
Encapsulate Angular mentoring link in LINKS constant (550) βœ…

Possibly related issues

Possibly related PRs

Suggested reviewers

  • dzmitry-varabei
  • andron13
  • natanchik
  • Quiddlee
  • SpaNb4
  • ansivgit

πŸ“œ Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Files that changed from the base of the PR and between f048dd3 and 9b03195.

πŸ“’ Files selected for processing (1)
  • src/widgets/mentors-wanted-course/ui/mentors-wanted-course.test.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/widgets/mentors-wanted-course/ui/mentors-wanted-course.test.tsx

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 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.

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
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: 0

🧹 Outside diff range and nitpick comments (3)
src/widgets/mentors-wanted/ui/mentors-wanted.test.tsx (1)

27-44: Comprehensive content rendering test.

The test case thoroughly checks all major component elements. Consider splitting this into multiple smaller test cases for better organization and easier debugging.

Example refactor:

it('renders visible elements', () => {
  // visibility checks
});

it('renders correct content', () => {
  // content checks
});

it('has correct attributes', () => {
  // attribute checks
});
src/widgets/mentors-wanted/ui/mentors-wanted.module.scss (2)

19-19: Consider using a variable for 'max-width: 50%'

To maintain consistency and ease future updates, consider replacing 50% with a variable if one exists in your design system.


28-28: Consider using a variable for 'max-width: 290px'

Similarly, using a variable for 290px can enhance maintainability.

πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Files that changed from the base of the PR and between f2ba874 and 5644808.

πŸ“’ Files selected for processing (4)
  • src/app/const/index.ts (1 hunks)
  • src/widgets/mentors-wanted/ui/mentors-wanted.module.scss (1 hunks)
  • src/widgets/mentors-wanted/ui/mentors-wanted.test.tsx (1 hunks)
  • src/widgets/mentors-wanted/ui/mentors-wanted.tsx (2 hunks)
🧰 Additional context used
πŸ”‡ Additional comments (15)
src/app/const/index.ts (1)

11-11: LGTM: New constant added as requested.

The ANGULAR_MENTORING constant has been correctly added to the LINKS object.

Verify the usage of this new constant:

src/widgets/mentors-wanted/ui/mentors-wanted.tsx (5)

2-2: LGTM: Import of LINKS constant added.

This change aligns with the PR objective to encapsulate the URL into a constant.


15-15: LGTM: Test ID added to section element.

The addition of data-testid improves component testability.


16-16: LGTM: Article class name updated.

The new class name mentors-wanted-content is more specific and descriptive.


24-24: LGTM: LinkCustom updated with constant and test ID.

The href now uses LINKS.ANGULAR_MENTORING, and a data-testid has been added for improved testability.


31-36: LGTM: Image component refactored.

The Image component now has a className for better styling control and a data-testid for improved testability.

src/widgets/mentors-wanted/ui/mentors-wanted.test.tsx (5)

1-6: Imports look good.

All necessary dependencies are imported, and the import order is logical.


8-14: Well-structured mocked data.

The mocked data object is clear and uses constants appropriately. Good use of regex for partial text matching.


16-19: Solid test suite structure.

The describe block and beforeEach hook follow testing best practices. Good use of renderWithRouter for potential routing scenarios.


21-25: First test case is concise and effective.

The test checks for basic rendering, using data-testid for reliable component selection.


1-45: Overall, excellent test implementation.

The test file is well-structured, covers all major aspects of the MentorsWanted component, and follows testing best practices. The suggested refactoring of the second test case into smaller, focused tests is the only minor improvement to consider.

src/widgets/mentors-wanted/ui/mentors-wanted.module.scss (4)

5-14: Good refactoring with flexbox for responsive design

The introduction of the .mentors-wanted-content class and the use of flexbox properties effectively restructure the layout. Utilizing @include media-tablet for responsive adjustments aligns well with the refactoring objectives.


16-25: Effective use of media queries in '.content-left'

Adjusting .content-left with media queries improves responsiveness, meeting the refactoring goals.


26-30: Well-structured addition of '.sloth-mascot' class

Adding .sloth-mascot centralizes the styling for the mascot image and properly applies flex properties.


6-6: ⚠️ Potential issue

Replace 'align-items: start' with 'align-items: flex-start'

The value start is not valid for align-items. The correct value is flex-start to ensure proper alignment in flex containers.

Apply this fix:

-  align-items: start;
+  align-items: flex-start;

Likely invalid or redundant comment.

Copy link

Lighthouse Report:

  • Performance: 81 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

Lighthouse Report:

  • Performance: 79 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

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

🧹 Outside diff range and nitpick comments (1)
src/widgets/mentors-wanted-course/ui/mentors-wanted-course.test.tsx (1)

27-44: Second test case is comprehensive.

The test thoroughly checks the visibility and content of all major component elements. Consider adding a test for the paragraph's exact content instead of using a regex.

You could replace line 39 with:

expect(paragraph).toHaveTextContent(mockedData.paragraph);

And update the mockedData.paragraph to contain the exact expected text.

πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Files that changed from the base of the PR and between 5644808 and 26eb2f7.

πŸ“’ Files selected for processing (7)
  • src/app/const/index.ts (1 hunks)
  • src/pages/angular.tsx (2 hunks)
  • src/widgets/mentors-wanted-course/index.ts (1 hunks)
  • src/widgets/mentors-wanted-course/ui/mentors-wanted-course.module.scss (1 hunks)
  • src/widgets/mentors-wanted-course/ui/mentors-wanted-course.test.tsx (1 hunks)
  • src/widgets/mentors-wanted-course/ui/mentors-wanted-course.tsx (1 hunks)
  • src/widgets/mentors-wanted/index.ts (0 hunks)
πŸ’€ Files with no reviewable changes (1)
  • src/widgets/mentors-wanted/index.ts
βœ… Files skipped from review due to trivial changes (1)
  • src/widgets/mentors-wanted-course/index.ts
🧰 Additional context used
πŸ”‡ Additional comments (15)
src/widgets/mentors-wanted-course/ui/mentors-wanted-course.module.scss (5)

1-3: LGTM: Good use of variable for color.


5-14: LGTM: Responsive design implemented correctly.


16-24: LGTM: Good responsive layout for content.


26-30: LGTM: Proper image handling with object-fit.


1-30: Well-structured SCSS file meeting PR objectives.

The file demonstrates good use of SCSS features, responsive design, and aligns with the refactoring goals.

src/app/const/index.ts (1)

14-14: LGTM: New constant added correctly.

The ANGULAR_MENTORING constant has been added to the LINKS object, following the existing naming convention.

Verify constant usage:

βœ… Verification successful

Verification Successful: Constant Usage Confirmed

  • ANGULAR_MENTORING is correctly used in src/widgets/mentors-wanted-course/ui/mentors-wanted-course.test.tsx and src/widgets/mentors-wanted-course/ui/mentors-wanted-course.tsx.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of the new constant
rg "LINKS\.ANGULAR_MENTORING" --type ts

Length of output: 296

src/pages/angular.tsx (2)

7-7: Import statement updated.

The import for MentorsWantedCourse reflects the component's new location.


28-28: Component usage updated.

MentorsWantedCourse is now used instead of MentorsWanted, consistent with the import change.

src/widgets/mentors-wanted-course/ui/mentors-wanted-course.tsx (4)

2-2: Import changes look good.

LINKS constant and updated styles import align with PR objectives.

Also applies to: 9-9


15-16: Structure and class name updates are good.

Improved testability with data-testid and more specific class names.


24-24: Link href update is correct.

Using LINKS.ANGULAR_MENTORING constant improves maintainability.


31-36: Image component updates look good.

Simplified structure and improved testability with data-testid.

src/widgets/mentors-wanted-course/ui/mentors-wanted-course.test.tsx (3)

1-14: Imports and mocked data look good.

Necessary testing libraries and component imports are present. Mocked data structure is appropriate for the component.


16-19: Test suite setup is correct.

The describe block and beforeEach hook are used appropriately, ensuring a fresh component render for each test.


21-25: First test case is valid.

The test correctly checks if the component renders without crashing using the appropriate test ID.

Copy link

Lighthouse Report:

  • Performance: 86 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

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: 0

🧹 Outside diff range and nitpick comments (1)
src/widgets/mentors-wanted-course/ui/mentors-wanted-course.tsx (1)

17-43: Implementation looks good with room for minor improvement.

Well-structured component with semantic HTML and testing attributes. Consider extracting the text content to constants for easier maintenance and potential internationalization.

πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Files that changed from the base of the PR and between 26eb2f7 and f048dd3.

πŸ“’ Files selected for processing (10)
  • src/app/const/index.ts (1 hunks)
  • src/pages/angular.tsx (2 hunks)
  • src/pages/home.tsx (2 hunks)
  • src/widgets/mentors-wanted-course/ui/mentors-wanted-course.module.scss (1 hunks)
  • src/widgets/mentors-wanted-course/ui/mentors-wanted-course.test.tsx (1 hunks)
  • src/widgets/mentors-wanted-course/ui/mentors-wanted-course.tsx (1 hunks)
  • src/widgets/mentors-wanted/ui/mentors-wanted.module.scss (1 hunks)
  • src/widgets/mentors-wanted/ui/mentors-wanted.test.tsx (1 hunks)
  • src/widgets/mentors-wanted/ui/mentors-wanted.tsx (1 hunks)
  • src/widgets/mentors/index.ts (0 hunks)
πŸ’€ Files with no reviewable changes (1)
  • src/widgets/mentors/index.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/app/const/index.ts
  • src/pages/angular.tsx
  • src/widgets/mentors-wanted-course/ui/mentors-wanted-course.module.scss
  • src/widgets/mentors-wanted-course/ui/mentors-wanted-course.test.tsx
🧰 Additional context used
πŸ”‡ Additional comments (17)
src/widgets/mentors-wanted/ui/mentors-wanted.module.scss (4)

1-2: LGTM. Verify visual impact.

The class renaming aligns with refactoring goals. Ensure the background color change doesn't adversely affect the component's appearance.


4-5: LGTM. Improved structure.

The new .mentors-content class enhances component structure and ensures horizontal content layout.


7-19: LGTM. Verify responsive behavior.

The .mentors-info and .sloth-mascot classes enhance responsiveness. Ensure the layout behaves correctly across different screen sizes.


22-25: LGTM. Good responsive adjustment.

The media query for .mentors-content ensures proper content stacking on smaller screens with appropriate spacing.

src/pages/home.tsx (2)

9-9: Import statement added correctly.

The MentorsWanted component is now imported, aligning with the refactoring objectives.


27-27: Component usage updated correctly.

The MentorsWanted component is now used in the Home component, consistent with the import change.

Verify the component's functionality with this script:

βœ… Verification successful

Component usage verified successfully.

The MentorsWanted component is implemented, tested, and exported correctly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if MentorsWanted component is properly implemented and tested

# Test: Check if MentorsWanted component file exists
fd -t f "mentors-wanted.(tsx|jsx)" src/widgets

# Test: Check if MentorsWanted component has associated test file
fd -t f "mentors-wanted.test.(tsx|jsx)" src/widgets

# Test: Check if MentorsWanted component is exported
rg -i "export.*MentorsWanted" src/widgets

Length of output: 673

src/widgets/mentors-wanted-course/ui/mentors-wanted-course.tsx (2)

1-10: Imports look good.

Organized imports following best practices.


12-16: Component structure is well-defined.

Clear prop type and functional component pattern.

src/widgets/mentors-wanted/ui/mentors-wanted.test.tsx (3)

3-3: Import statement updated correctly.

The import has been properly updated to reflect the component renaming from Mentors to MentorsWanted.


11-11: Component rendering updated in beforeEach.

The test setup now correctly renders the renamed MentorsWanted component.


Line range hint 14-50: Regarding past comment on test redundancy

While some tests might seem redundant, each serves a specific purpose. The granular approach helps pinpoint exact failures and ensures all critical elements are present with correct attributes. This structure aids in maintaining component integrity during future changes.

src/widgets/mentors-wanted/ui/mentors-wanted.tsx (6)

1-2: Imports updated appropriately

The import statements have been correctly updated to include 'classnames/bind' and { ANCHORS, LINKS }, which are necessary for the new functionality.


11-11: Binding styles with classNames.bind

The cx function is properly defined using classNames.bind(styles), enabling scoped CSS class names.


15-15: Section element updated with new classes and attributes

The <section> now uses the updated class 'mentors-container' and includes id and data-testid attributes for navigation and testing.


18-18: WidgetTitle component enhanced with size prop

Adding the size="large" prop to WidgetTitle ensures consistent styling for larger headings.


25-31: LinkCustom component configured correctly

The LinkCustom component is correctly set up with href={LINKS.BECOME_MENTOR}, variant="primary", and the external prop to link users to the mentor application page.


33-38: Image component utilized with appropriate attributes

The Image component includes necessary props like className, src, alt, and data-testid, ensuring proper rendering and accessibility.

Copy link

Lighthouse Report:

  • Performance: 97 / 100
  • Accessibility: 100 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@KristiBo KristiBo merged commit 83ff456 into main Oct 22, 2024
4 checks passed
@KristiBo KristiBo deleted the refactor/550-widget-mentors-wanted branch October 22, 2024 16:18
@coderabbitai coderabbitai bot mentioned this pull request Oct 30, 2024
8 tasks
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.

FSD: Widget MentorsWanted
4 participants