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

Cu 86bznypcf notifications end to end testing #287

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from

Conversation

NyashaMuusha
Copy link
Collaborator

@NyashaMuusha NyashaMuusha commented Jul 25, 2024

1. Description of changes

updated ts-config file
created notifications.cy.ts file
added tests

2.How to test

npm run cypress
select end-to-end-testing

Summary by CodeRabbit

  • New Features

    • Introduced comprehensive end-to-end tests for the Dashboard Component, Browse Records feature, and Notification Worklist to ensure functionality and user experience.
    • Added a new fixture for search responses to enhance testing with realistic datasets.
    • Implemented a TypeScript configuration for Cypress to improve type-checking and development efficiency.
    • Enhanced the BrowseRecords component with improved date picker functionality and standardized UI elements.
  • Bug Fixes

    • Enhanced test coverage for various UI components, ensuring better error handling and user interaction.
  • Chores

    • Added Cypress as a development dependency to facilitate end-to-end testing.
    • Updated package dependencies for improved functionality and compatibility.

@rcrichton
Copy link
Member

Copy link
Contributor

coderabbitai bot commented Jul 25, 2024

Walkthrough

This update enhances the JeMPI UI application by introducing comprehensive Cypress testing capabilities for both end-to-end and component testing. New configuration files and test files validate the functionality of critical components like the Dashboard and NotificationWorklist. Additionally, adjustments to component structures improve accessibility and testability. These enhancements significantly boost test coverage, ensuring a more robust and reliable user experience.

Changes

Files Change Summary
cypress.config.ts, cypress/ts.config.json New configuration files for Cypress, establishing settings for e2e and component testing.
cypress/e2e/*.cy.ts Introduced multiple end-to-end test files for key components, enhancing test coverage and validating functionality.
cypress/fixtures/*.json New JSON fixture created for standardized mock data in Cypress tests.
src/components/*.tsx Adjustments to component attributes to improve testability and accessibility.
src/components/notificationWorklist/NotificationWorklist.tsx Public exposure of CustomTextField for reuse across components, enhancing usability.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Cypress
    participant Dashboard
    participant NotificationWorklist

    User->>Cypress: Initiates testing
    Cypress->>Dashboard: Loads Dashboard tests
    Dashboard->>Cypress: Validates dashboard functionalities
    Cypress->>NotificationWorklist: Loads Notification tests
    NotificationWorklist->>Cypress: Validates notifications functionalities
    Cypress->>User: Returns test results
Loading

Poem

🐇 In a world of code where bunnies hop,
Testing's a dance that never will stop.
With Cypress in hand, we leap and we bound,
Ensuring our widgets are safe and sound.
So here’s to the testers, both brave and so spry,
Hopping through functions, oh my, oh my! ✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

Outside diff range, codebase verification and nitpick comments (1)
JeMPI_Apps/JeMPI_UI/cypress/support/component.ts (1)

38-39: Example Usage Comment: No Issues Found

The example usage comment is helpful for developers to understand how to use the custom mount command.

Consider adding more detailed examples or links to documentation for further guidance.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between acd5d0a and 930df4a.

Files ignored due to path filters (2)
  • JeMPI_Apps/JeMPI_UI/package-lock.json is excluded by !**/package-lock.json
  • JeMPI_Apps/JeMPI_UI/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (16)
  • JeMPI_Apps/JeMPI_UI/cypress.config.ts (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/e2e/dashboard.cy.ts (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/e2e/mock_notifications.cy.ts (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/e2e/notifications.cy.ts (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/fixtures/example.json (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/fixtures/notifications.json (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/support/commands.ts (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/support/component-index.html (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/support/component.ts (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/support/e2e.ts (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/ts.config.json (1 hunks)
  • JeMPI_Apps/JeMPI_UI/package.json (3 hunks)
  • JeMPI_Apps/JeMPI_UI/src/components/dashboard/Dashboard.tsx (1 hunks)
  • JeMPI_Apps/JeMPI_UI/src/components/notificationWorklist/NotificationWorklist.tsx (1 hunks)
  • JeMPI_Apps/JeMPI_UI/src/components/shell/PageHeader.tsx (1 hunks)
  • JeMPI_Apps/JeMPI_UI/tsconfig.json (1 hunks)
Files skipped from review due to trivial changes (7)
  • JeMPI_Apps/JeMPI_UI/cypress/fixtures/example.json
  • JeMPI_Apps/JeMPI_UI/cypress/support/component-index.html
  • JeMPI_Apps/JeMPI_UI/cypress/support/e2e.ts
  • JeMPI_Apps/JeMPI_UI/cypress/ts.config.json
  • JeMPI_Apps/JeMPI_UI/src/components/dashboard/Dashboard.tsx
  • JeMPI_Apps/JeMPI_UI/src/components/notificationWorklist/NotificationWorklist.tsx
  • JeMPI_Apps/JeMPI_UI/src/components/shell/PageHeader.tsx
Additional context used
Biome
JeMPI_Apps/JeMPI_UI/cypress/e2e/mock_notifications.cy.ts

[error] 2-2: Don't focus the test.

The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.

(lint/suspicious/noFocusedTests)

Additional comments not posted (41)
JeMPI_Apps/JeMPI_UI/cypress.config.ts (3)

4-4: LGTM!

The projectId setting is correct.


6-6: LGTM!

The baseUrl setting is correct.


7-9: Placeholder comment noted.

The setupNodeEvents function is currently a placeholder. Ensure to implement the necessary node event listeners as needed.

JeMPI_Apps/JeMPI_UI/tsconfig.json (4)

22-22: LGTM!

The paths setting is correct and improves type resolution for Cypress-related files.


29-29: LGTM!

The types setting is correct and improves type safety and autocompletion for Cypress testing.


30-30: LGTM!

The include setting is correct and broadens the scope of files considered for compilation.


31-34: LGTM!

The exclude setting is correct and helps streamline the build process.

JeMPI_Apps/JeMPI_UI/cypress/support/component.ts (3)

1-13: Boilerplate Code: No Issues Found

The initial comments provide useful information about the file's purpose and configuration options. This is standard boilerplate code provided by Cypress.


16-20: Import Commands: No Issues Found

The file imports custom commands using ES2015 syntax and provides an alternative CommonJS syntax. This is a standard practice.


22-37: Extending Cypress with Custom Commands: No Issues Found

The code extends the Cypress namespace to include type definitions for a custom mount command and adds the command. This is a standard way to augment Cypress functionality for React component testing.

JeMPI_Apps/JeMPI_UI/cypress/support/commands.ts (3)

1-10: Boilerplate Code: No Issues Found

The initial comments provide useful information about the file's purpose and configuration options. This is standard boilerplate code provided by Cypress.


13-26: Custom Commands Examples: No Issues Found

The file includes commented-out examples of how to add various types of custom commands in Cypress. This is standard practice and provides a good starting point for developers.


28-37: TypeScript Definitions: No Issues Found

The file includes commented-out TypeScript definitions for custom commands. This is useful for TypeScript users and follows best practices.

JeMPI_Apps/JeMPI_UI/cypress/e2e/notifications.cy.ts (5)

1-4: Setup for NotificationWorklist Tests: No Issues Found

The beforeEach hook visits the /notifications page before each test. This is a standard setup for end-to-end tests.


6-10: Page Header Test: No Issues Found

The test checks if the page header is displayed correctly. This is a basic but necessary test to ensure the UI is rendering as expected.


12-42: Filters Tests: No Issues Found

The tests check the visibility and functionality of various filters on the page. These tests are well-structured and cover essential aspects of the filter functionality.


45-53: Data Grid Tests: No Issues Found

The tests check the visibility of the data grid and pagination. These tests ensure that the main components of the notification worklist are displayed correctly.


56-67: API Calls Tests: No Issues Found

The tests intercept API calls and mock responses to ensure the component handles data correctly. This is a good practice for testing components that rely on external data.

JeMPI_Apps/JeMPI_UI/cypress/e2e/dashboard.cy.ts (6)

6-8: LGTM!

The test case correctly verifies the visibility of the dashboard tabs.


10-24: LGTM!

The test case comprehensively verifies the navigation through multiple tabs and their visibility.


26-33: LGTM!

The test case correctly verifies the visibility of specific widgets within the Confusion Matrix tab.


35-40: LGTM!

The test case correctly verifies the visibility of the M & U widget within the M & U Values tab.


43-63: LGTM!

The test case comprehensively verifies the correct rendering of the page with no data.


65-84: LGTM!

The test cases comprehensively verify the correct handling of loading state and API errors.

JeMPI_Apps/JeMPI_UI/package.json (5)

19-19: LGTM!

The reformatting of the mock:enviroments script does not impact its functionality.


20-20: LGTM!

The addition of the cypress script enhances the testing capabilities by integrating Cypress.


64-64: LGTM!

The update to @testing-library/jest-dom enhances the testing library with new features or fixes.


66-66: LGTM!

The update to @types/jest enhances the type definitions with improvements.


72-72: LGTM!

The addition of Cypress enhances the end-to-end testing capabilities.

JeMPI_Apps/JeMPI_UI/cypress/fixtures/notifications.json (12)

2-16: LGTM!

The data entry for the notification with ID 5407f4b6-504d-479e-9da1-b509b4b08b8f appears to be complete and correct.


17-27: LGTM!

The data entry for the notification with ID 8d7a5e0c-14a0-4cd5-8b7e-875da3560501 appears to be complete and correct.


29-44: LGTM!

The data entry for the notification with ID 51f1c2c2-318f-41fc-a77b-7e1ac32668dc appears to be complete and correct.


46-56: LGTM!

The data entry for the notification with ID d16d8354-41c3-47af-a0aa-d80555654f4e appears to be complete and correct.


58-68: LGTM!

The data entry for the notification with ID ef0819bf-e32d-46dd-a074-c82f01a2ef00 appears to be complete and correct.


70-80: LGTM!

The data entry for the notification with ID e605293e-64ed-4f9a-9b2f-866ecb150448 appears to be complete and correct.


82-97: LGTM!

The data entry for the notification with ID 927c7b9b-3457-48a0-97ff-a54d7d1c2e21 appears to be complete and correct.


99-109: LGTM!

The data entry for the notification with ID 84d6adae-4f21-4114-9c2a-e2c3a668c73d appears to be complete and correct.


111-126: LGTM!

The data entry for the notification with ID 56bc8096-53d8-4c6c-8f99-1d2865240e62 appears to be complete and correct.


128-139: LGTM!

The data entry for the notification with ID 29c60b55-3500-40d2-8c0c-967171ed69d2 appears to be complete and correct.


141-150: LGTM!

The data entry for the notification with ID 7f61a925-7871-434a-987a-b1a76fed3eb3 appears to be complete and correct.


153-167: LGTM!

The data entry for the notification with ID 60aa1cc1-d7a6-46a2-b610-4da4a75f6742 appears to be complete and correct.

@@ -0,0 +1,8 @@
describe('it mocks fetch notifications',()=>{
it.only('checks api call', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove it.only to ensure all tests are executed.

The it.only method is often used for debugging or during implementation. It should be removed before deploying to production to ensure that all tests are executed.

- it.only('checks api call', () => {
+ it('checks api call', () => {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it.only('checks api call', () => {
it('checks api call', () => {
Tools
Biome

[error] 2-2: Don't focus the test.

The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.

(lint/suspicious/noFocusedTests)

@NyashaMuusha NyashaMuusha changed the base branch from dev to CU-86bznvd1v_Dashboard-End-To-End-Testing July 26, 2024 09:08
@rcrichton
Copy link
Member

Task linked: CU-86bznvd1v Dashboard-End-To-End-Testing

…End-Testing' into CU-86bznypcf_Notifications-End-To-End-Testing

# Conflicts:
#	JeMPI_Apps/JeMPI_UI/package-lock.json
#	JeMPI_Apps/JeMPI_UI/tsconfig.json
#	JeMPI_Apps/JeMPI_UI/yarn.lock
…-To-End-Testing' into CU-86bznypcf_Notifications-End-To-End-Testing
@NyashaMuusha NyashaMuusha changed the base branch from CU-86bznvd1v_Dashboard-End-To-End-Testing to dev July 26, 2024 09:33
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 930df4a and ccd2df1.

Files selected for processing (3)
  • JeMPI_Apps/JeMPI_AsyncReceiver/src/main/java/org/jembi/jempi/async_receiver/Main.java (1 hunks)
  • JeMPI_Apps/JeMPI_Linker/src/main/java/org/jembi/jempi/linker/SPInteractions.java (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/e2e/notifications.cy.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • JeMPI_Apps/JeMPI_UI/cypress/e2e/notifications.cy.ts
Additional comments not posted (5)
JeMPI_Apps/JeMPI_Linker/src/main/java/org/jembi/jempi/linker/SPInteractions.java (1)

98-98: LGTM! Enhanced reliability with exactly-once processing.

The addition of StreamsConfig.PROCESSING_GUARANTEE_CONFIG with StreamsConfig.EXACTLY_ONCE_V2 enhances the reliability of message processing by ensuring that records are neither lost nor processed more than once. This aligns with best practices for stateful stream processing.

JeMPI_Apps/JeMPI_AsyncReceiver/src/main/java/org/jembi/jempi/async_receiver/Main.java (4)

167-167: LGTM! Improved flexibility in partitionKey initialization.

Initializing partitionKey as an empty string allows for a more flexible and inclusive way of constructing the partitionKey.


169-170: LGTM! Enhanced partitionKey uniqueness with givenName.

Concatenating the Soundex value of givenName if it is not empty enhances the uniqueness of the partitionKey.


171-172: LGTM! Enhanced partitionKey uniqueness with familyName.

Concatenating the Soundex value of familyName if it is not empty further enhances the uniqueness of the partitionKey.


174-175: LGTM! Handling empty names in partitionKey.

Appending "Unknown" to partitionKey when both givenName and familyName are empty ensures that the partitionKey is not left empty.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ccd2df1 and c14e8a2.

Files selected for processing (8)
  • JeMPI_Apps/JeMPI_UI/cypress.config.ts (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/e2e/browseRecords.cy.ts (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/e2e/dashboard.cy.ts (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/e2e/notifications.cy.ts (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/fixtures/searchResponse.json (1 hunks)
  • JeMPI_Apps/JeMPI_UI/cypress/ts.config.json (1 hunks)
  • JeMPI_Apps/JeMPI_UI/src/components/browseRecords/BrowseRecords.tsx (4 hunks)
  • JeMPI_Apps/JeMPI_UI/src/components/notificationWorklist/NotificationWorklist.tsx (2 hunks)
Files skipped from review due to trivial changes (2)
  • JeMPI_Apps/JeMPI_UI/cypress.config.ts
  • JeMPI_Apps/JeMPI_UI/cypress/ts.config.json
Files skipped from review as they are similar to previous changes (3)
  • JeMPI_Apps/JeMPI_UI/cypress/e2e/dashboard.cy.ts
  • JeMPI_Apps/JeMPI_UI/cypress/e2e/notifications.cy.ts
  • JeMPI_Apps/JeMPI_UI/src/components/notificationWorklist/NotificationWorklist.tsx
Additional comments not posted (12)
JeMPI_Apps/JeMPI_UI/cypress/e2e/browseRecords.cy.ts (7)

3-8: Good use of beforeEach hook.

The beforeEach hook ensures that each test starts with a clean state by visiting the specified URL.


10-12: Good use of a helper function.

The openRecordDetails function improves reusability and readability by abstracting the action of opening record details.


14-18: Good test for page header visibility.

The test ensures that the page header is displayed correctly.


20-51: Comprehensive tests for filter functionality.

The tests ensure that the filter accordion can be expanded, collapsed, and that specific filters are visible.


54-63: Effective tests for search results and navigation.

The tests ensure that search results are displayed correctly and that navigation to record details works as expected.


65-109: Comprehensive tests for record details page functionality.

The tests ensure that navigation, visibility of tables, and button functionalities work as expected.


112-124: Good test for API call interception.

The test ensures that search results are displayed correctly when API calls are intercepted.

JeMPI_Apps/JeMPI_UI/src/components/browseRecords/BrowseRecords.tsx (4)

51-51: Good addition of import statement.

The import statement for CustomTextField reflects the integration of a custom text field component.


Line range hint 66-70:
Good use of useState hooks for date filters.

The useState hooks manage the state for the start and end date filters.


233-245: Improved DateTimePicker components.

The DateTimePicker components now use the slots prop and integrate the CustomTextField component, improving flexibility and consistency.


259-260: Improved accessibility with id attribute.

Adding an id to the FormControlLabel for the interactions switch improves accessibility.

JeMPI_Apps/JeMPI_UI/cypress/fixtures/searchResponse.json (1)

1-963: Well-organized JSON structure.

The JSON file contains an array of goldenRecord objects, each with nested sourceId, uniqueGoldenRecordData, demographicData, and interactionsWithScore. The structure is consistent and well-organized.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c14e8a2 and f77c89c.

Files selected for processing (3)
  • JeMPI_Apps/JeMPI_UI/src/test/settings/BlockingContent.test.tsx (1 hunks)
  • JeMPI_Apps/JeMPI_UI/src/test/settings/Probabilistic.test.tsx (1 hunks)
  • JeMPI_Apps/JeMPI_UI/src/test/settings/SourceView.test.tsx (1 hunks)
Files skipped from review due to trivial changes (3)
  • JeMPI_Apps/JeMPI_UI/src/test/settings/BlockingContent.test.tsx
  • JeMPI_Apps/JeMPI_UI/src/test/settings/Probabilistic.test.tsx
  • JeMPI_Apps/JeMPI_UI/src/test/settings/SourceView.test.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants