devabhishekpal opened a new pull request, #6983: URL: https://github.com/apache/ozone/pull/6983
## What changes were proposed in this pull request? HDDS-9790. Add tests for Overview page Please describe your PR in detail: -Currently we don't have any tests for Recon UI. This increases manual effort for validating UI fixes/changes. - This PR will add the initial setup required for adding tests using ReactTestingLibrary and Jest, along with some unit test cases for the Recon Overview page and the AutoReloadPanel component for Recon. - After we get good coverage of tests for basic scenarios, these can be run as a part of the CI checks to reduce manual effort in verifying changes, as well as providing an initial filter to catch bugs/errors early on. - It uses RTL library to provide test functionality and **Vitest** as a test runner. - Along with that it will use msw to intercept API calls to endpoints and return mock responses to ensure a single static source of truth for testing. ## Reference for quick overview on the frameworks: ### ReactTestingLibrary React Testing Library is a lightweight testing library built on top of the DOM Testing Library for React components. It focuses on the functionality of the component in contrast to the actual implementation of the component. This ensures that no matter how we implement our components and no matter the changes, we can ensure a consistent functionality. It can work with any test runner, but we are using Jest as the preferred runner in this case. ### Vitest Vitest is a testing framework which also acts as a runner for our tests, allowing us to implement various testing methods and provide a way to interact with the virtual DOM to verify and assert conditions. It also has many built in features like mocking functions, generating coverage etc. allowing us to focus on the testing, rather than the implementation. ### MSW Mock Service Worker is a API mocking library that allows us to intercept API calls, and provide mocks for the same. It is independent of the client, framework and environment - this means we can run it anywhere independently. ### How are we setting up our tests? The main configuration for our tests start with configuring Vitest, this will be added under the vite.config.ts file's `test` section. Under this test section we are calling the vitest.setup.ts file to run initially to import missing Window functions as jsdom doesn't provide them as a part of the virtual DOM and also we are importing the jest-dom vitest types which allows us to use jest assertions like `toBeVisible()`, `toHaveTextContent()` etc in our tests. ### Reference Documentations for reading: Vitest: https://v1.vitest.dev/ React Testing Library: https://testing-library.com/docs/react-testing-library/intro/ MSW: https://mswjs.io/docs/getting-started ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-9790 ## How was this patch tested? This patch was tested manually <img width="650" alt="Screenshot 2024-07-24 at 12 47 28" src="https://github.com/user-attachments/assets/392a9ddf-9e58-4fd4-a380-03f218c4c0db"> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
