[8.16] [Fleet] [Cloud Security] Add Testing Library ESLint for handling waitFor (#198735)#199068
Closed
opauloh wants to merge 1 commit intoelastic:8.16from
Closed
[8.16] [Fleet] [Cloud Security] Add Testing Library ESLint for handling waitFor (#198735)#199068opauloh wants to merge 1 commit intoelastic:8.16from
opauloh wants to merge 1 commit intoelastic:8.16from
Conversation
…For (elastic#198735) ## Summary This PR aims to fix Flaky tests related to agentless detected by elastic#189038 and elastic#192126 by adding proper handling of the `waitFor` methods. It was also detected with elastic/security-team#10979 that some other methods were not proper handled by `waitFor`, leading to the assertions inside those unhandled `waitFor` being skipped by Jest. This PR also introduces ESLint to enforce proper handling of waitFor methods in tests files for Fleet and Cloud Security plugins. Additional note: These changes should also unblock the failing tests on the [React18 use waitFor with assertion callbacks in place of waitForNextUpdate](elastic#195087) PR **Fleet changes** - ESLint rule added to enforce handling `waitFor` on React Testing Library. - `useSetupTechnology` hook tests reviewed and updated to handle the waitFor. Fixed issue identified when reviewing the tests. - step_define_package_policy.test.tsx: Added package policy vars to the mock to proper handle the use cases - step_select_hosts.test.tsx: Handled waitFor, identified outdated test - step_edit_hosts.test.tsx: Handled waitFor, identified outdated test With the introduction of the ESLint rule other tests were triggering ESLint errors, I attempted to fix them while retaining the same intention, let me know if more changes are needed. **Cloud Security changes** - ESLint rule added to enforce handling `waitFor` on React Testing Library. - Updated cloud security posture version to include agentless global tags on End to End tests **@elastic/kibana-operations changes** - Added [eslint-plugin-testing-library](https://testing-library.com/docs/ecosystem-eslint-plugin-testing-library/) an ESLint plugin for Testing Library that helps users to follow best practices and anticipate common mistakes when writing tests. - The adoption and enablement of the rules are opt-in. (cherry picked from commit 5ab59fb) # Conflicts: # x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/hooks/setup_technology.test.ts # x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/hooks/setup_technology.ts
Contributor
|
Pinging @elastic/fleet (Team:Fleet) |
Contributor
💔 Build Failed
Failed CI StepsHistory |
Contributor
Author
|
cancelling this backport, as there was a couple of conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto8.16:Questions ?
Please refer to the Backport tool documentation