Skip to content

Migrate high-complexity security plugin Enzyme tests to RTL#254900

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

Migrate high-complexity security plugin Enzyme tests to RTL#254900
elena-shostak wants to merge 4 commits intoelastic:mainfrom
elena-shostak:enzyme-to-rtl/high/security-plugin

Conversation

@elena-shostak
Copy link
Contributor

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

Summary

Migrate 7 high-complexity security plugin files from Enzyme to React Testing Library (RTL):

Test files (225 tests total):

  • login_form.test.tsx (21 tests)
  • user_profile.test.tsx (16 tests)
  • edit_role_page.test.tsx (28 tests)
  • privilege_space_table.test.tsx (90 tests)
  • privilege_summary_table.test.tsx (38 tests)
  • feature_table.test.tsx (32 tests)

Fixture helpers:

  • privilege_summary/__fixtures__/index.ts — converted from ReactWrapper to HTMLElement container
  • kibana_privilege_table/__fixtures__/index.ts — converted from ReactWrapper to HTMLElement container

Key migration patterns:

  • mountWithIntl/shallowWithIntlrender + I18nProvider
  • findTestSubject(wrapper, 'x')container.querySelector('[data-test-subj="x"]')
  • wrapper.find(Component).props() → DOM attribute queries (data-test-subj, data-euiicon-type, aria-pressed, etc.)
  • .simulate('click')fireEvent.click()
  • Enzyme ReactWrapper fixtures → HTMLElement container fixtures

Test plan

  • All 225 migrated tests pass
  • Other test files consuming the same fixtures still pass
  • No Enzyme imports remain in migrated files

Related: #223148

… Library

Migrate 7 files (5 test files + 2 fixture helpers) from Enzyme to RTL:
- login_form.test.tsx (21 tests)
- user_profile.test.tsx (16 tests)
- edit_role_page.test.tsx (28 tests)
- privilege_space_table.test.tsx (90 tests)
- privilege_summary_table.test.tsx (38 tests) + __fixtures__/index.ts
- feature_table.test.tsx (32 tests) + __fixtures__/index.ts

Key changes:
- Replace mountWithIntl/shallowWithIntl with render + I18nProvider
- Replace findTestSubject with querySelector/querySelectorAll
- Replace wrapper.find(Component).props() with DOM-based queries
- Replace simulate('click') with fireEvent.click
- Use data-test-subj attributes and DOM traversal for assertions

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!

@elena-shostak elena-shostak added Team:Security Platform Security: Auth, Users, Roles, Spaces, Audit Logging, etc t// release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Feb 25, 2026
elena-shostak and others added 2 commits February 25, 2026 13:33
…m.test.tsx

- Remove unused `waitFor` import from login_form.test.tsx
- 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 Succeeded

Metrics [docs]

Count of Enzyme imports

Enzyme is no longer supported, and we should switch to @testing-library/react instead.

id before after diff
security 14 10 -4
Unknown metric groups

References to deprecated APIs

id before after diff
@kbn/security-ui-components 3 0 -3
security 52 42 -10
total -13

Unreferenced deprecated APIs

id before after diff
@kbn/security-ui-components 3 0 -3
security 52 42 -10
total -13

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Security Platform Security: Auth, Users, Roles, Spaces, Audit Logging, etc t//

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants