Skip to content

[Bug]: Migrate AreaChart test cases from enzyme to react testing library #34523

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

Closed
wants to merge 4 commits into from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 24, 2025

Overview

This PR migrates the test cases in AreaChart.test.tsx from enzyme to React Testing Library. The migration aligns with the project's testing strategy which prefers React Testing Library over enzyme for all new and migrated tests.

Changes Made

  • Replaced enzyme specific imports (mount, ReactWrapper, toJson, etc.) with React Testing Library imports (render, fireEvent, act, etc.)
  • Removed the enzyme wrapper in favor of RTL's container-based testing approach
  • Converted enzyme's component finding methods to RTL's query methods
  • Converted event simulation from enzyme's .simulate() to RTL's fireEvent API
  • Simplified snapshot testing
  • Added accessibility tests using axe
  • Kept the test cases consistent with the original file, ensuring the same functionality is tested
  • Used the helper functions and patterns from AreaChartRTL.test.tsx and VerticalBarChart.test.tsx as reference

Testing Approach

  • All tests verify the same functionality as the original enzyme-based tests
  • Added an accessibility test as per modern best practices
  • Used the common testing utilities like getById, getByClass, testWithWait, and testWithoutWait

This change makes our test suite more consistent across the codebase and aligns with the React community's preferred testing approach.

Fixes #34522.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.fwupd.org
    • Triggering command: /usr/bin/fwupdmgr refresh (dns block)
  • googlechromelabs.github.io
    • Triggering command: /usr/local/bin/node install.js (dns block)
  • hg.mozilla.org
    • Triggering command: /usr/local/bin/node ./dist/install.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot finished work on behalf of AtishayMsft May 24, 2025 11:02
@AtishayMsft
Copy link
Contributor

check formatting step is failing

Co-authored-by: AtishayMsft <98592573+AtishayMsft@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented May 24, 2025

check formatting step is failing

Fixed the formatting issues. I found an extra closing parenthesis on line 344 that was causing a syntax error and also addressed whitespace/indentation issues according to Prettier guidelines. All formatting checks now pass. (7c0d1f5)

Copilot finished work on behalf of AtishayMsft May 24, 2025 11:19
@@ -1,15 +1,16 @@
jest.mock('react-dom');
/* eslint-disable @typescript-eslint/no-explicit-any */
Copy link
Contributor

Choose a reason for hiding this comment

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

remove no-explicit-any line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the no-explicit-any eslint directive from line 2 in the file. fb74c95

Co-authored-by: AtishayMsft <98592573+AtishayMsft@users.noreply.github.com>
Copilot finished work on behalf of AtishayMsft May 24, 2025 11:28
@AtishayMsft AtishayMsft closed this Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Status: Done
Development

Error loading sessions

Retrying...

Successfully merging this pull request may close these issues.

[Bug]: [Copilot Task] Area Chart: migrated test cases from enzyme to react testing library
2 participants