Skip to content

Commit bab214e

Browse files
albertoblazopauloh
andauthored
Migrate SessionsViewer test from Enzyme to RTL (elastic#222962)
## Summary Replace Enzyme with React Testing Library in the only test that our team owns and still relied on Enzyme. ### Motivation On June 4th, it was officially announced that **Enzyme is deprecated in Kibana**. As @Dosant put it in the email: > Move all tests to RTL before we adopt React 19 (realistically a year+ from now). Otherwise, we would need to run Enzyme tests on an older version of React, making them even less reliable. ### How to verify we have no more Enzyme tests After checking the `CODEOWNERS` file, these are the folders our team owns: <details><summary>Files</summary> - x-pack/platform/packages/shared/kbn-cloud-security-posture/common - x-pack/solutions/security/packages/distribution-bar - x-pack/solutions/security/packages/kbn-cloud-security-posture/graph - x-pack/solutions/security/packages/kbn-cloud-security-posture/public - x-pack/solutions/security/plugins/cloud_security_posture - x-pack/solutions/security/plugins/session_view - x-pack/test_serverless/functional/test_suites/security/index.mki_only.ts - x-pack/solutions/security/plugins/security_solution/public/asset_inventory - x-pack/packages/kbn-cloud-security-posture - x-pack/plugins/cloud_security_posture - x-pack/plugins/kubernetes_security - x-pack/solutions/security/plugins/security_solution/public/common/components/sessions_viewer - x-pack/solutions/security/plugins/security_solution/public/cloud_security_posture - x-pack/solutions/security/plugins/security_solution/public/kubernetes - x-pack/solutions/security/plugins/security_solution/server/lib/asset_inventory - x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/universal_right - x-pack/solutions/security/plugins/security_solution/public/flyout/csp_details - x-pack/platform/plugins/shared/fleet/public/components/cloud_security_posture - x-pack/platform/plugins/shared/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/components/cloud_security_posture - x-pack/platform/plugins/shared/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/hooks/setup_technology.* - x-pack/platform/plugins/shared/fleet/public/applications/integrations/sections/epm/screens/detail/components/cloud_posture_third_party_support_callout.* - x-pack/test/functional/es_archives/kubernetes_security - x-pack/test/kubernetes_security - x-pack/test/functional/es_archives/session_view - x-pack/test/session_view - x-pack/test/api_integration/apis/cloud_security_posture/ - x-pack/test/cloud_security_posture_functional/ - x-pack/test/cloud_security_posture_api/ - x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.* - x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/ - x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/ - x-pack/test/security_solution_cypress/cypress/e2e/cloud_security_posture/misconfiguration_contextual_flyout.cy.ts - x-pack/test/security_solution_cypress/cypress/e2e/cloud_security_posture/vulnerabilities_contextual_flyout.cy.ts - x-pack/test/security_solution_cypress/cypress/e2e/asset_inventory </details> To verify we have no more tests relying on Enzyme, simply search in your editor for the term "enzyme" and paste the following line in _files to include_: ``` x-pack/platform/packages/shared/kbn-cloud-security-posture/common,x-pack/solutions/security/packages/distribution-bar,x-pack/solutions/security/packages/kbn-cloud-security-posture/graph,x-pack/solutions/security/packages/kbn-cloud-security-posture/public,x-pack/solutions/security/plugins/cloud_security_posture,x-pack/solutions/security/plugins/session_view,x-pack/test_serverless/functional/test_suites/security/index.mki_only.ts,x-pack/solutions/security/plugins/security_solution/public/asset_inventory,x-pack/packages/kbn-cloud-security-posture,x-pack/plugins/cloud_security_posture,x-pack/plugins/kubernetes_security,x-pack/solutions/security/plugins/security_solution/public/common/components/sessions_viewer,x-pack/solutions/security/plugins/security_solution/public/cloud_security_posture,x-pack/solutions/security/plugins/security_solution/public/kubernetes,x-pack/solutions/security/plugins/security_solution/server/lib/asset_inventory,x-pack/solutions/security/plugins/security_solution/public/flyout/entity_details/universal_right,x-pack/solutions/security/plugins/security_solution/public/flyout/csp_details,x-pack/platform/plugins/shared/fleet/public/components/cloud_security_posture,x-pack/platform/plugins/shared/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/components/cloud_security_posture,x-pack/platform/plugins/shared/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/single_page_layout/hooks/setup_technology.*,x-pack/platform/plugins/shared/fleet/public/applications/integrations/sections/epm/screens/detail/components/cloud_posture_third_party_support_callout.*,x-pack/test/functional/es_archives/kubernetes_security,x-pack/test/kubernetes_security,x-pack/test/functional/es_archives/session_view,x-pack/test/session_view,x-pack/test/api_integration/apis/cloud_security_posture/,x-pack/test/cloud_security_posture_functional/,x-pack/test/cloud_security_posture_api/,x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.*,x-pack/test_serverless/functional/test_suites/security/ftr/cloud_security_posture/,x-pack/test_serverless/api_integration/test_suites/security/cloud_security_posture/,x-pack/test/security_solution_cypress/cypress/e2e/cloud_security_posture/misconfiguration_contextual_flyout.cy.ts,x-pack/test/security_solution_cypress/cypress/e2e/cloud_security_posture/vulnerabilities_contextual_flyout.cy.ts,x-pack/test/security_solution_cypress/cypress/e2e/asset_inventory ``` So your editor should look like this: <img width="775" alt="Screenshot 2025-06-06 at 12 41 21" src="https://github.com/user-attachments/assets/231b93d7-c9c6-4bd6-a1bb-422f1f7161a2" /> ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [x] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks No risks at all. Co-authored-by: Paulo Silva <[email protected]>
1 parent 1d5129a commit bab214e

File tree

1 file changed

+2
-3
lines changed
  • x-pack/solutions/security/plugins/security_solution/public/common/components/sessions_viewer

1 file changed

+2
-3
lines changed

x-pack/solutions/security/plugins/security_solution/public/common/components/sessions_viewer/index.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type { EntityType } from '@kbn/timelines-plugin/common';
1313
import type { SessionsComponentsProps } from './types';
1414
import { TableId } from '@kbn/securitysolution-data-table';
1515
import { licenseService } from '../../hooks/use_license';
16-
import { mount } from 'enzyme';
1716
import type { EventsViewerProps } from '../events_viewer';
1817

1918
jest.mock('../../lib/kibana');
@@ -106,14 +105,14 @@ mockGetDefaultControlColumn.mockReturnValue([
106105

107106
describe('SessionsView', () => {
108107
it('renders the session view', async () => {
109-
const wrapper = mount(
108+
const { getByTestId } = render(
110109
<TestProviders>
111110
<SessionsView {...testProps} />
112111
</TestProviders>
113112
);
114113

115114
await waitFor(() => {
116-
expect(wrapper.find(`[data-test-subj="${TEST_ID}"]`).exists()).toBeTruthy();
115+
expect(getByTestId(TEST_ID)).toBeTruthy();
117116
});
118117
});
119118

0 commit comments

Comments
 (0)