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

524-refactor: Widget OptionItem #542

Closed
wants to merge 15 commits into from
Closed

Conversation

YulikK
Copy link
Collaborator

@YulikK YulikK commented Sep 23, 2024

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

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

Description

  1. move option-item.test.tsx to ui folder
  2. replace div with article
  3. remove export from props type
  4. remove props type re-export from index.ts
  5. remove all OptionItemProps from other components
  6. remove todo comment
  7. replace p tag with Paragraph
  8. replace h3 tag with Subtitle
  9. update selector for option description in the test file

Related Tickets & Documents

Screenshots, Recordings

Please replace this line with any relevant images for UI changes.

Added/updated tests?

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

[optional] Are there any post deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

Summary by CodeRabbit

  • New Features

    • Introduced a new SCSS module for the .option-item class, enhancing responsive design.
    • Added a new test file for the OptionItem component to verify rendering and functionality.
  • Bug Fixes

    • Updated tests for the StudyWithUs component to improve element selection and verification.
  • Refactor

    • Simplified type declarations for contributeOptions and studyOptions.
    • Refactored the OptionItem component to use more semantic HTML and improved styling.
  • Chores

    • Removed outdated test files and type exports to streamline codebase.

@github-actions github-actions bot changed the title Refactor/524 widget option item 524-refactor: Widget OptionItem Sep 23, 2024
Copy link

Lighthouse Report:

  • Performance: 47 / 100
  • Accessibility: 98 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

Copy link

Lighthouse Report:

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

View detailed report

Copy link
Collaborator

@KristiBo KristiBo left a comment

Choose a reason for hiding this comment

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

Refactor option-item.tsx's scss to scss modules

Copy link

Lighthouse Report:

  • Performance: 96 / 100
  • Accessibility: 98 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@YulikK YulikK requested a review from ansivgit September 24, 2024 09:53
Copy link

Lighthouse Report:

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

View detailed report

Copy link

Lighthouse Report:

  • Performance: 88 / 100
  • Accessibility: 98 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@YulikK YulikK requested review from ansivgit and SpaNb4 September 25, 2024 10:21
@KristiBo KristiBo marked this pull request as ready for review September 25, 2024 10:40
Copy link
Contributor

coderabbitai bot commented Sep 25, 2024

πŸ“ Walkthrough

Walkthrough

The changes involve refactoring the OptionItem component and related files. Key modifications include removing type definitions, updating import/export statements, and transitioning from traditional SCSS to CSS modules. The OptionItem component has been restructured for improved semantics, and unit tests have been reorganized to align with these changes. Additionally, a new SCSS module has been introduced for styling, enhancing the component's layout and responsiveness.

Changes

Files Change Summary
src/widgets/contribute/ui/contribute.tsx Removed OptionItemProps import and simplified contributeOptions declaration.
src/widgets/option-item/index.ts Removed export of OptionItemProps type, retaining only the OptionItem component.
src/widgets/option-item/option-item.test.tsx Deleted unit tests for OptionItem component.
src/widgets/option-item/ui/option-item.module.scss Introduced new SCSS module for .option-item with responsive styles.
src/widgets/option-item/ui/option-item.scss Deleted old SCSS file containing styles for the option component.
src/widgets/option-item/ui/option-item.test.tsx Added new unit tests for OptionItem, verifying rendering and functionality.
src/widgets/option-item/ui/option-item.tsx Refactored to use <article> instead of <div>, updated class names, and modified internal structure.
src/widgets/study-with-us/constants.ts Removed type annotation from studyOptions, changing to a more general export.
src/widgets/study-with-us/study-with-us.test.tsx Updated test implementation for StudyWithUs component, changing element selection methods.

Assessment against linked issues

Objective Addressed Explanation
Refactor option-item.tsx's scss to scss modules (524) βœ…
Move option-item.test.tsx to ui folder (524) βœ…
Replace div with article (524) βœ…
Remove export from props type (524) βœ…
Remove props type re-export from index.ts (524) βœ…
Remove all OptionItemProps from other components (524) ❌ Not all instances of OptionItemProps were removed.

Possibly related PRs

Suggested reviewers

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

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 (5)
src/widgets/study-with-us/study-with-us.test.tsx (1)

30-35: Test case update approved with suggestion.

The new implementation using test IDs is more robust. Consider extracting the test ID strings to constants for consistency and easier maintenance.

+const OPTION_ITEM_TEST_ID = 'option-item';
+const PARAGRAPH_TEST_ID = 'paragraph';

-const options = screen.getAllByTestId('option-item');
+const options = screen.getAllByTestId(OPTION_ITEM_TEST_ID);

-const description = within(option).getByTestId('paragraph');
+const description = within(option).getByTestId(PARAGRAPH_TEST_ID);
src/widgets/option-item/ui/option-item.test.tsx (3)

18-37: "Without linkLabel" tests are comprehensive.

The tests cover the essential aspects of rendering without a link. Consider adding a test for the article element to ensure the correct semantic markup.

Add a test to verify the presence of the article element:

it('uses correct semantic markup', () => {
  expect(screen.getByRole('article')).toBeInTheDocument();
});

39-51: "With linkLabel" test is good, but could be more comprehensive.

The test covers the essential aspects of rendering with a link. Consider adding tests for the title and description in this scenario as well.

Add tests for title and description:

it('displays correct content', () => {
  expect(screen.getByTestId('subtitle')).toHaveTextContent(mockProps.title);
  expect(screen.getByTestId('paragraph')).toHaveTextContent(mockProps.description);
});

1-52: Well-structured tests with good coverage.

The tests are organized logically and cover the main functionality. Consider adding tests for edge cases, such as empty strings for title or description.

Add tests for edge cases:

it('handles empty strings for title and description', () => {
  renderWithRouter(<OptionItem title="" description="" />);
  expect(screen.getByTestId('subtitle')).toBeEmptyDOMElement();
  expect(screen.getByTestId('paragraph')).toBeEmptyDOMElement();
});
src/widgets/contribute/ui/contribute.tsx (1)

9-9: Type annotation removal approved.

Removal of OptionItemProps[] type is consistent with import changes. Consider using a more generic type like Array<{ title: string, description: string, linkLabel: string, href: string }> for clarity if needed.

πŸ“œ Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Files that changed from the base of the PR and between c8b226e and dec10ee.

πŸ“’ Files selected for processing (9)
  • src/widgets/contribute/ui/contribute.tsx (1 hunks)
  • src/widgets/option-item/index.ts (1 hunks)
  • src/widgets/option-item/option-item.test.tsx (0 hunks)
  • src/widgets/option-item/ui/option-item.module.scss (1 hunks)
  • src/widgets/option-item/ui/option-item.scss (0 hunks)
  • src/widgets/option-item/ui/option-item.test.tsx (1 hunks)
  • src/widgets/option-item/ui/option-item.tsx (1 hunks)
  • src/widgets/study-with-us/constants.ts (1 hunks)
  • src/widgets/study-with-us/study-with-us.test.tsx (2 hunks)
πŸ’€ Files not reviewed due to no reviewable changes (2)
  • src/widgets/option-item/option-item.test.tsx
  • src/widgets/option-item/ui/option-item.scss
πŸ”‡ Additional comments not posted (10)
src/widgets/option-item/index.ts (1)

1-1: Export modification approved.

The change aligns with the PR objectives. Remember to verify that removing OptionItemProps export doesn't break other components.

src/widgets/option-item/ui/option-item.module.scss (1)

1-14: LGTM. Responsive design implemented effectively.

The SCSS module for .option-item is well-structured and implements responsive design appropriately.

src/widgets/study-with-us/constants.ts (1)

Line range hint 1-18: Approved: Type annotation removal aligns with PR objectives.

The removal of explicit type annotation for studyOptions is in line with the PR objectives and previous discussions. TypeScript's type inference is sufficient here.

src/widgets/option-item/ui/option-item.tsx (2)

1-1: Import changes look good.

The new imports and use of CSS modules align with the refactoring objectives.

Also applies to: 3-4, 6-6, 8-8


18-20: Component implementation looks great.

The changes improve semantics, accessibility, and maintainability. Good job addressing previous review comments.

Also applies to: 26-26

src/widgets/study-with-us/study-with-us.test.tsx (2)

1-1: Import change approved.

The addition of within is necessary for the updated test implementation.


29-29: Clarification needed on test retention.

A previous review suggested skipping this test due to potential redundancy with option-item component tests. However, recent updates indicate a decision to keep and improve it. Could you clarify the current stance on retaining this test?

src/widgets/option-item/ui/option-item.test.tsx (2)

1-12: Imports and mock props look good.

The necessary testing utilities are imported, and the mock props provide a solid foundation for the tests.


20-20: Good use of custom renderWithRouter function.

Using a custom render function that provides router context is a best practice for components that might interact with routing features.

Also applies to: 41-41

src/widgets/contribute/ui/contribute.tsx (1)

5-5: Import cleanup approved.

Removal of OptionItemProps import aligns with PR objectives.

@ansivgit ansivgit marked this pull request as draft September 25, 2024 17:56
@ansivgit ansivgit added duplicate This issue or pull request already exists draft PR draft labels Sep 25, 2024
Copy link

Lighthouse Report:

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

View detailed report

@SpaNb4 SpaNb4 closed this Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
draft PR draft duplicate This issue or pull request already exists preview refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FSD: Widget OptionItem
6 participants