Migrate high-complexity security plugin Enzyme tests to RTL#254900
Draft
elena-shostak wants to merge 4 commits intoelastic:mainfrom
Draft
Migrate high-complexity security plugin Enzyme tests to RTL#254900elena-shostak wants to merge 4 commits intoelastic:mainfrom
elena-shostak wants to merge 4 commits intoelastic:mainfrom
Conversation
… 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>
Contributor
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
…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>
Contributor
💚 Build Succeeded
Metrics [docs]Count of Enzyme imports
Unknown metric groupsReferences to deprecated APIs
Unreferenced deprecated APIs
History
|
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.
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 fromReactWrappertoHTMLElementcontainerkibana_privilege_table/__fixtures__/index.ts— converted fromReactWrappertoHTMLElementcontainerKey migration patterns:
mountWithIntl/shallowWithIntl→render+I18nProviderfindTestSubject(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()ReactWrapperfixtures →HTMLElementcontainer fixturesTest plan
Related: #223148