Skip to content

Migrate high-complexity Enzyme tests to RTL (spaces + security)#254896

Draft
elena-shostak wants to merge 4 commits intoelastic:mainfrom
elena-shostak:enzyme-to-rtl/high/spaces-security
Draft

Migrate high-complexity Enzyme tests to RTL (spaces + security)#254896
elena-shostak wants to merge 4 commits intoelastic:mainfrom
elena-shostak:enzyme-to-rtl/high/spaces-security

Conversation

@elena-shostak
Copy link
Contributor

@elena-shostak elena-shostak commented Feb 25, 2026

Summary

Migrates 3 high-complexity Enzyme test files to React Testing Library (RTL):

  • share_to_space_flyout_internal.test.tsx (32 tests): Replaces Enzyme mountWithIntl/findTestSubject with RTL render/screen/fireEvent, adds pass-through mocks for EUI and internal components to inspect props, uses deferred promise pattern for async loading state tests.
  • feature_table.test.tsx (32 tests): Replaces Enzyme with RTL, converts all assertions to DOM queries and RTL APIs, uses DOM-based selectors for EuiIconTip type detection and EuiAccordion arrow checks.
  • __fixtures__/index.ts: Rewrites getDisplayedFeaturePrivileges from Enzyme ReactWrapper to accept HTMLElement with RTL-compatible DOM querying, handles EuiAccordion id placement, EuiButtonGroup data-test-subj patterns, and EuiCheckbox input-level test subject attributes.

Total: 64 tests migrated, all passing.

Test plan

  • yarn test:jest x-pack/platform/plugins/shared/spaces/public/share_saved_objects_to_space/components/share_to_space_flyout_internal.test.tsx — 32/32 pass
  • yarn test:jest x-pack/platform/packages/private/security/ui_components/src/kibana_privilege_table/feature_table.test.tsx — 32/32 pass

Related: #223148

- share_to_space_flyout_internal.test.tsx (32 tests): replace Enzyme
  mountWithIntl/findTestSubject with RTL render/screen/fireEvent,
  add pass-through mocks for EUI components and internal components
  to inspect props, use deferred promise pattern for async loading states
- feature_table.test.tsx (32 tests): replace Enzyme with RTL,
  convert all assertions to DOM queries and RTL APIs, use DOM-based
  selectors for EuiIconTip type detection and EuiAccordion arrow checks
- __fixtures__/index.ts: rewrite getDisplayedFeaturePrivileges from
  Enzyme ReactWrapper to HTMLElement with RTL-compatible DOM querying,
  handle EuiAccordion id placement, EuiButtonGroup data-test-subj
  patterns, and EuiCheckbox input-level test subject attributes

Co-authored-by: Cursor <cursoragent@cursor.com>
@elasticmachine
Copy link
Contributor

elasticmachine commented Feb 25, 2026

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!
  • Click to trigger kibana-storybooks-from-pr for this PR!

kibanamachine and others added 3 commits February 25, 2026 12:03
…ilege_space_form migration

- Replace toBeInTheDocument() with toBeNull()/not.toBeNull() in
  feature_table.test.tsx (not available in this package's type env)
- Fix EuiSelectable mock type from jest.MockedFunction to jest.Mock
  (EuiSelectable is a class component, not a function)
- Migrate privilege_space_form.test.tsx from Enzyme to RTL to match
  the updated fixture signature (HTMLElement instead of ReactWrapper)

Co-authored-by: Cursor <cursoragent@cursor.com>
@elasticmachine
Copy link
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

History

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.

3 participants