-
Notifications
You must be signed in to change notification settings - Fork 61
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
fix(j-s): E2E Tests #16133
fix(j-s): E2E Tests #16133
Conversation
WalkthroughThe changes involve modifications to the logic and selectors used in various components and test files within the judicial system application. Specifically, the validity assessment for the Changes
Possibly related PRs
Suggested labels
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)
apps/system-e2e/src/tests/judicial-system/regression/indictment-tests.spec.ts (2)
42-45
: LGTM! Consider adding comments for clarity.The updates to the selectors for national ID and name input fields are appropriate and align with the PR objectives. These changes make the tests more specific and robust.
Consider adding a brief comment explaining the reason for these selector changes, e.g.:
// Updated selectors to match new input component IDs await page.getByTestId('inputNationalId').click() await page.getByTestId('inputNationalId').fill('01.01.2000') await page.getByTestId('inputName').click() await page.getByTestId('inputName').fill(accusedName)
81-84
: Good addition. Consider adding a comment for context.The new Promise.all block effectively handles the concurrent operations of clicking the 'Nei' button and verifying the case update request. This addition improves the test's robustness.
To enhance readability, consider adding a brief comment explaining the purpose of this block, e.g.:
// Handle 'No' response and verify case update await Promise.all([ page.getByText('Nei').last().click(), verifyRequestCompletion(page, '/api/graphql', 'UpdateCase'), ])apps/judicial-system/web/src/routes/Prosecutor/RestrictionCase/HearingArrangements/HearingArrangements.tsx (1)
Line range hint
1-238
: Consider component decomposition for improved maintainability.The
HearingArrangements
component demonstrates good practices:
- Proper use of React hooks and context
- Effective use of TypeScript for type safety
- Appropriate use of Next.js
useRouter
hookHowever, the component is quite large and handles multiple responsibilities. To improve maintainability and adhere to the Single Responsibility Principle, consider the following refactoring suggestions:
- Extract the modal logic and state into a separate component.
- Create a custom hook for case-related operations (e.g.,
useCaseOperations
) to encapsulate the logic currently in theuseCase
hook.- Consider breaking down the form sections into smaller, reusable components.
These changes would make the code more modular and easier to test and maintain.
Here's a high-level example of how you might start refactoring:
// Extract modal to a separate component const NotificationModal = ({ isOpen, onClose, onSend, onContinue, workingCase, isSending, error }) => { // Modal JSX here } // Extract case operations to a custom hook const useCaseOperations = () => { // Case-related operations here } // Main component export const HearingArrangements = () => { const { workingCase, setWorkingCase } = useContext(FormContext) const { sendNotification, transitionCase, updateCase } = useCaseOperations() // Component logic here return ( <PageLayout> {/* Other components */} <NotificationModal isOpen={navigateTo !== undefined} onClose={() => setNavigateTo(undefined)} onSend={handleSendNotification} onContinue={handleContinue} workingCase={workingCase} isSending={isSendingNotification} error={sendNotificationError} /> </PageLayout> ) }This refactoring would improve the component's structure and make it easier to understand and maintain.
apps/system-e2e/src/tests/judicial-system/regression/custody-tests.spec.ts (2)
66-66
: Approved, but consider using a more descriptive input name.The change from 'accusedName' to 'inputName' has been implemented correctly. However, 'inputName' is less specific and might reduce clarity in the test. Consider using a more descriptive name that reflects the purpose of the input, such as 'accusedFullName' or 'defendantName', to maintain clarity in the test code.
Line range hint
1-486
: Consider refactoring for improved maintainability.The overall structure of the E2E tests follows good practices for Playwright, including well-organized test cases, proper use of async/await, and comprehensive page object interactions. However, the file is quite long, which could make maintenance challenging. Consider the following improvements:
- Split the tests into smaller, more focused files based on specific workflows or features.
- Extract common setup and teardown logic into separate helper functions or fixtures.
- Create reusable page object models for frequently used UI components.
- Consider using custom test commands for repetitive actions to reduce code duplication.
These refactoring steps could enhance the maintainability and readability of your E2E test suite.
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (4)
- apps/judicial-system/web/src/routes/Prosecutor/RestrictionCase/HearingArrangements/HearingArrangements.tsx (1 hunks)
- apps/system-e2e/src/tests/judicial-system/regression/custody-tests.spec.ts (1 hunks)
- apps/system-e2e/src/tests/judicial-system/regression/indictment-tests.spec.ts (2 hunks)
- apps/system-e2e/src/tests/judicial-system/regression/search-warrant-tests.spec.ts (1 hunks)
Additional context used
Path-based instructions (4)
apps/judicial-system/web/src/routes/Prosecutor/RestrictionCase/HearingArrangements/HearingArrangements.tsx (1)
Pattern
apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
apps/system-e2e/src/tests/judicial-system/regression/custody-tests.spec.ts (1)
Pattern
apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
apps/system-e2e/src/tests/judicial-system/regression/indictment-tests.spec.ts (1)
Pattern
apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
apps/system-e2e/src/tests/judicial-system/regression/search-warrant-tests.spec.ts (1)
Pattern
apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (5)
apps/system-e2e/src/tests/judicial-system/regression/indictment-tests.spec.ts (2)
89-89
: LGTM! Good for readability.The addition of this empty line improves the code structure by clearly separating different sections of the test. This enhances readability and maintainability.
Line range hint
1-146
: Overall, excellent updates to the E2E tests.The changes in this file successfully address the PR objectives by updating selectors for new input components and enhancing the test's robustness. The additions of new asynchronous operations and improved error handling are particularly noteworthy. The code adheres to NextJS best practices and makes efficient use of TypeScript for type safety.
A few minor suggestions have been made to improve code clarity through comments, but these are not critical. Great job on keeping the E2E tests up-to-date and functional!
apps/judicial-system/web/src/routes/Prosecutor/RestrictionCase/HearingArrangements/HearingArrangements.tsx (1)
96-96
: Verify the impact of simplifying thestepIsValid
condition.The condition for
stepIsValid
has been simplified by removing theisTransitioningCase
check. While this improves code readability, it may change the component's behavior during case transitions.Please confirm that this change is intentional and doesn't introduce any issues in the following scenarios:
- When a case is in the process of transitioning.
- In the context of the
handleNavigationTo
function, which still usesisTransitioningCase
.Consider adding a comment explaining the rationale behind this change to improve code maintainability.
To verify the impact, you can run the following script to check for other occurrences of
isTransitioningCase
in the codebase:apps/system-e2e/src/tests/judicial-system/regression/search-warrant-tests.spec.ts (2)
Line range hint
1-248
: Overall, the changes look good. Ensure comprehensive E2E testing.The modification to update the input selector for the accused's name is in line with the PR objectives. The change is minimal and focused, which reduces the risk of introducing new issues.
To ensure the E2E test suite remains robust after this change:
Run the entire E2E test suite and verify all tests pass:
Check for any deprecation warnings or console errors during test execution:
These steps will help validate that the selector change hasn't inadvertently affected other parts of the test suite.
44-44
: LGTM! Consider reviewing similar selectors.The change from
input[name=accusedName]
toinput[name=inputName]
aligns with the PR objectives of updating E2E tests for new input components. This modification correctly updates the selector for the accused's name input field.To ensure consistency, please verify if there are any other similar selectors in this file or related test files that might need updating. You can use the following script to check for other potential instances:
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16133 +/- ##
==========================================
- Coverage 36.69% 36.65% -0.05%
==========================================
Files 6761 6759 -2
Lines 139064 138971 -93
Branches 39498 39488 -10
==========================================
- Hits 51035 50942 -93
Misses 88029 88029
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 18 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportAll test runs ✅ 5 Total Test Services: 0 Failed, 5 Passed Test Services
🔻 Code Coverage Decreases vs Default Branch (1)
|
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.
LGTM
E2E Tests
Update e2e tests
What
Why
Checklist:
Summary by CodeRabbit