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 86bznvd1v dashboard end to end testing #283

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

Conversation

NyashaMuusha
Copy link
Collaborator

@NyashaMuusha NyashaMuusha commented Jul 23, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a Cypress configuration for end-to-end and component testing.
    • Added end-to-end tests for the Dashboard Component to validate user experience and functionality.
    • Introduced custom commands in Cypress to streamline testing actions.
    • Created a foundational HTML structure for the Components App and setup files for enhanced testing capabilities.
  • Bug Fixes

    • Enhanced accessibility and testing capabilities of the Dashboard Component with a new attribute.
  • Chores

    • Updated package.json to include Cypress and related TypeScript type definitions for improved testing support.
    • Added TypeScript configurations to optimize the build process by excluding test files.

@rcrichton
Copy link
Member

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

Copy link
Contributor

coderabbitai bot commented Jul 23, 2024

Walkthrough

This update introduces a comprehensive testing setup for the JeMPI UI application using Cypress. It establishes configurations for both end-to-end and component testing, enhancing the testing framework with custom commands and HTML structures. New test files ensure the proper functionality of the Dashboard component, while TypeScript configurations optimize the build process. Overall, these changes improve the reliability and maintainability of the application through automated testing practices.

Changes

Files Change Summary
cypress.config.ts Introduced for configuring Cypress for E2E and component testing, setting up base URL and development server settings.
cypress/e2e/dashboard.cy.ts Added a suite of E2E tests for the Dashboard Component, covering tab visibility, navigation, and widget rendering with mock API responses.
cypress/support/commands.ts Introduced custom commands to enhance Cypress functionality, including login, drag, and an overwritten visit command.
cypress/support/component-index.html, cypress/support/component.ts Created foundational HTML for component tests and set up a custom mount command for rendering React components.
cypress/support/e2e.ts Established a centralized configuration file for E2E testing, importing necessary commands.
package.json Updated scripts to include Cypress, added Cypress and TypeScript type definitions, and incremented Jest type definitions.
src/components/dashboard/Dashboard.tsx Added data-cy='dashboard-tab' attribute to improve accessibility and testing capabilities.
tsconfig.build.json Introduced to manage TypeScript build configurations, excluding test-related files from the build process.
tsconfig.json Updated to include Cypress TypeScript files for compilation while excluding test files.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant CI as CI/CD System
    participant Cypress as Cypress Test Runner
    participant Dashboard as Dashboard Component

    Dev->>CI: Commit changes
    CI->>Cypress: Trigger tests
    Cypress->>Dashboard: Load Dashboard Component
    Dashboard->>Cypress: Validate tab visibility and navigation
    Dashboard->>Cypress: Render widgets
    Cypress->>Dev: Report test results
Loading

🐇 In the meadow where bunnies play,
New tests hop in to save the day!
With Cypress by our furry side,
Our app's now ready for a joyful ride!
🥕 Let's leap and bound, both night and day,
For code and tests shall lead the way! 🌼


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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e19bbdc and 91dad36.

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 (10)
  • 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/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/package.json (2 hunks)
  • JeMPI_Apps/JeMPI_UI/src/components/dashboard/Dashboard.tsx (1 hunks)
  • JeMPI_Apps/JeMPI_UI/tsconfig.build.json (1 hunks)
  • JeMPI_Apps/JeMPI_UI/tsconfig.json (1 hunks)
Files skipped from review due to trivial changes (4)
  • JeMPI_Apps/JeMPI_UI/cypress/support/component-index.html
  • JeMPI_Apps/JeMPI_UI/cypress/support/e2e.ts
  • JeMPI_Apps/JeMPI_UI/src/components/dashboard/Dashboard.tsx
  • JeMPI_Apps/JeMPI_UI/tsconfig.build.json
Additional comments not posted (24)
JeMPI_Apps/JeMPI_UI/cypress.config.ts (4)

1-1: Import statement is correct.

The import statement correctly brings in defineConfig from Cypress.


3-9: End-to-end configuration looks good.

The e2e configuration block correctly sets the base URL and includes a placeholder for node event listeners.


11-16: Component configuration is appropriate.

The component configuration block correctly sets up the development server using create-react-app and webpack.


3-17: Export statement is correct.

The defineConfig function is correctly used to export the Cypress configuration object.

JeMPI_Apps/JeMPI_UI/tsconfig.json (2)

29-29: Include section update is correct.

The include section correctly adds cypress/**/*.ts to ensure TypeScript recognizes and compiles these files.


30-33: Exclude section update is correct.

The exclude section correctly excludes **/*.test.ts and the cypress directory, optimizing the TypeScript compilation process.

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

1-14: Header comments are informative and helpful.

The header comments clearly explain the purpose of the file and provide a useful link to Cypress documentation.


16-20: Import statements are correct.

The import statements correctly bring in custom commands using ES2015 syntax and optionally CommonJS syntax.


22-34: Cypress namespace augmentation is appropriate.

The Cypress namespace is correctly augmented to include type definitions for the custom mount command.


36-36: Custom command addition is correct.

The custom mount command is correctly added to Cypress for mounting React components in tests.


38-39: Example usage comment is helpful.

The example usage comment provides a clear example of how to use the custom mount command.

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

1-37: Template file with no custom commands implemented.

This file is a template with comments and examples on how to create custom commands in Cypress. No actual custom commands are implemented.

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

1-4: Good setup for visiting the dashboard.

The beforeEach hook ensures that the dashboard is visited before each test case.


6-8: Test for displaying dashboard tabs looks good.

This test case verifies that the dashboard tabs are visible.


10-24: Comprehensive test for navigating through tabs.

This test case checks the visibility of tab panels when navigating through different tabs, ensuring that only the active tab's panel is visible.


26-33: Test for displaying widgets in the Confusion Matrix tab looks good.

This test case verifies that the widgets in the Confusion Matrix tab are visible.


35-39: Test for displaying M & U widget in M & U Values tab looks good.

This test case verifies that the M & U widget in the M & U Values tab is visible.


43-63: Test for rendering correctly with no data is well-implemented.

This test case mocks the API response to return no data and verifies that the dashboard renders correctly.


65-74: Test for displaying loading state correctly is well-implemented.

This test case mocks the API response to simulate a loading state and verifies that the dashboard handles it correctly.


76-84: Test for handling API errors is well-implemented.

This test case mocks the API response to return an error and verifies that the dashboard handles it correctly.

JeMPI_Apps/JeMPI_UI/package.json (4)

19-20: Addition of Cypress script is correct.

The cypress script allows developers to easily initiate Cypress tests.


65-65: Addition of @types/cypress dependency is correct.

The @types/cypress package provides TypeScript type definitions for Cypress, aiding in type-checking.


67-67: Update of @types/jest dependency is correct.

The minor version upgrade of @types/jest reflects potential bug fixes or improvements.


73-73: Addition of Cypress dependency is correct.

The cypress package is added as a dependency to ensure Cypress is available for testing purposes.

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