-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Conversation
Lighthouse Report:
|
Lighthouse Report:
|
There was a problem hiding this 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
β¦ponent and study-with-us component
Lighthouse Report:
|
Lighthouse Report:
|
Lighthouse Report:
|
π WalkthroughWalkthroughThe changes involve refactoring the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
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? πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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 likeArray<{ title: string, description: string, linkLabel: string, href: string }>
for clarity if needed.
π Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
π 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.
Lighthouse Report:
|
What type of PR is this? (select all that apply)
Description
Related Tickets & Documents
Screenshots, Recordings
Please replace this line with any relevant images for UI changes.
Added/updated tests?
[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
.option-item
class, enhancing responsive design.OptionItem
component to verify rendering and functionality.Bug Fixes
StudyWithUs
component to improve element selection and verification.Refactor
contributeOptions
andstudyOptions
.OptionItem
component to use more semantic HTML and improved styling.Chores