-
Notifications
You must be signed in to change notification settings - Fork 5
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
test: add test for submission popup header #1296
base: dev
Are you sure you want to change the base?
Conversation
WalkthroughWalkthroughNew test files, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SubmissionPopup
participant Localization
User->>SubmissionPopup: Render component
SubmissionPopup->>Localization: Fetch "communities.submission"
Localization-->>SubmissionPopup: Return text
SubmissionPopup-->>User: Display component with text
User->>SubmissionPopup: Click arrow icon
SubmissionPopup->>SubmissionPopup: Call onClose
SubmissionPopup-->>User: Component closes
User->>SubmissionPopup: Click close button
SubmissionPopup->>SubmissionPopup: Call onClose
SubmissionPopup-->>User: Component closes
Assessment against linked issues
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 as PR comments)
Additionally, you can add Documentation and Community
|
✅ Deploy Preview for staging-dacade ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- tests/components/popups/submission/_partials/Header.test.tsx (1 hunks)
Additional comments not posted (6)
__tests__/components/popups/submission/_partials/Header.test.tsx (6)
1-3
: LGTM!The import statements are correctly importing the necessary modules for the tests.
The code changes are approved.
5-8
: LGTM!The jest mock is correctly mocking the SVG icon for use in the tests.
The code changes are approved.
11-13
: LGTM!The test suite is correctly set up with a mock function for
onClose
.The code changes are approved.
15-18
: LGTM!The test case correctly tests rendering the component with the correct text.
The code changes are approved.
20-26
: LGTM!The test case correctly tests the
onClose
function when clicking the arrow icon.The code changes are approved.
28-33
: LGTM!The test case correctly tests the
onClose
function when clicking the close button.The code changes are approved.
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: 2
Outside diff range, codebase verification and nitpick comments (1)
__tests__/components/popups/submission/indext.test.tsx (1)
9-14
: Consider using constants for hardcoded strings.The test uses
"communities.submission"
directly. If this string changes frequently or is used in multiple tests, consider replacing it with a constant to avoid multiple updates and potential errors in the future.Consider defining a constant for reusable strings:
+const SUBMISSION_TEXT = "communities.submission"; renderWithRedux(<SubmissionPopup show={true} onClose={mockOnClose} submissionId="123" />); - expect(screen.getByText("communities.submission")).toBeInTheDocument(); + expect(screen.getByText(SUBMISSION_TEXT)).toBeInTheDocument();
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- tests/components/popups/submission/_partials/Header.test.tsx (1 hunks)
- tests/components/popups/submission/indext.test.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/components/popups/submission/_partials/Header.test.tsx
Additional comments not posted (1)
__tests__/components/popups/submission/indext.test.tsx (1)
16-19
: Test implementation is correct.This test correctly checks that the popup does not render when the
show
prop is set tofalse
.The test is well-implemented and covers the expected behavior based on the prop value.
expect(mockOnClose).toHaveBeenCalled(); | ||
}); | ||
|
||
it("calls onClose when clicking the close button", () => { |
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.
it("calls onClose when clicking the close button", () => { | |
it("Invokes the onClose function when the close button is clicked", () => { |
__tests__/components/popups/submission/_partials/Header.test.tsx
Outdated
Show resolved
Hide resolved
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
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (3)
- tests/components/popups/submission/_partials/Header.test.tsx (1 hunks)
- tests/components/popups/submission/index.test.tsx (1 hunks)
- src/components/popups/submission/_partials/Header.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
- src/components/popups/submission/_partials/Header.tsx
Files skipped from review as they are similar to previous changes (1)
- tests/components/popups/submission/_partials/Header.test.tsx
Additional comments not posted (5)
__tests__/components/popups/submission/index.test.tsx (5)
1-4
: LGTM!The import statements are correct and necessary for the tests.
The code changes are approved.
5-8
: LGTM!The test suite setup and mock function creation are appropriate.
The code changes are approved.
9-14
: LGTM!The first test case correctly verifies that the popup renders when
show
is true.The code changes are approved.
16-19
: LGTM!The second test case correctly verifies that the popup does not render when
show
is false.The code changes are approved.
21-26
: Verify the correct element for the close button.The test case correctly verifies that the
onClose
function is called when the close button is clicked. However, ensure thatscreen.getByTestId("overlay")
is the correct element for the close button.Please verify if
screen.getByTestId("overlay")
is the correct element for the close button. If not, update the test to select the correct element.
Submit a pull request
Pull Request Details
This pr adds tests for
SubmissionPopup
andHeader
componentsBreaking Changes
none
Issues Fixed
Closes #1148
Other Relevant Information
none