[App Search] Role mappings migration part 2#94461
[App Search] Role mappings migration part 2#94461scottybollinger merged 12 commits intoelastic:masterfrom
Conversation
The original asRoleMapping was merely for a smoke test in the shared component. Refactored to work better in App Search component
cee-chen
left a comment
There was a problem hiding this comment.
Thanks a ton for this Scotty! Some minor comments and general questions for you - I'm definitely not super familiar with the in-depth role mappings functionality, so appreciate any answers/knawledge you can toss me
x-pack/plugins/enterprise_search/public/applications/app_search/app_logic.ts
Show resolved
Hide resolved
x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/__mocks__/roles.ts
Show resolved
Hide resolved
...rprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.ts
Show resolved
Hide resolved
...rprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.ts
Show resolved
Hide resolved
...rprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.ts
Show resolved
Hide resolved
...rprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.ts
Show resolved
Hide resolved
...rprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.ts
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Show resolved
Hide resolved
...rprise_search/public/applications/app_search/components/role_mappings/role_mappings_logic.ts
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
[EDIT] Just now realizing this PR is from you @scottybollinger . I reviewed this like I review any other App Search Logic file. If it seems too onerous, that is fine. I can make updates in a follow up PR or something. I realize you might not use the same patterns or standards on the WS half of things. So consider this optional.
I reviewed the test file only, a few general comments that they can all boil down to...
- Consider making assertions in tests directly on
.valuesand spreadingDEFAULT_VALUES. - Consider using
mountwhen setting up initial data, and consider doing it more often to get better, more understandable tests. - Consider using better descriptions on tests. It can be a valuable living documentation source.
My comments identify a few specific instances where that would help, but I think there are probably others as well.
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Outdated
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Outdated
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Outdated
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Outdated
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Outdated
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Outdated
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Outdated
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Show resolved
Hide resolved
Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com>
Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com>
scottybollinger
left a comment
There was a problem hiding this comment.
@JasonStoltz thanks for the edit above. I would actually like to make the changes you suggested, as I agree with them and they will help make our tests better in Workplace Search.
Refactoring the tests showed me that some parts of the state weren’t being reset.
I some how got the test coverage at 100% with my wrong way of doing tests before (scary). When I fixed it I noticed that noting I could do would trigger the fallback of just returning the `[ANY_AUTH_PROVIDER]` array. After talking with Constance, we could not come up with a way to trigger it either, given the conditions. She had suggested removing the first return statement but that caused an empty array being returned sometimes. Ultimately, I was able to get it working and covered with these changes.
The places where `role: 'superuser’` was deleted in the listeners was a side effect of using `setRoleMappingData` and not `mount`
|
@elasticmachine merge upstream |
|
@JasonStoltz this should be ready for another look. I have updated the full-feature code on this branch if you want to do any QA |
...ugins/enterprise_search/public/applications/app_search/components/role_mappings/constants.ts
Outdated
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Outdated
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Outdated
Show resolved
Hide resolved
...e_search/public/applications/app_search/components/role_mappings/role_mappings_logic.test.ts
Outdated
Show resolved
Hide resolved
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
* Add engines mock and fix mock role mapping The original asRoleMapping was merely for a smoke test in the shared component. Refactored to work better in App Search component * Add RoleMappingsLogic * Fix test description Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com> * Fix test description Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com> * Add flash messages when creating, updating or deleting * Add path and resetState calls Refactoring the tests showed me that some parts of the state weren’t being reset. * Refactor handleAuthProviderChange logic I some how got the test coverage at 100% with my wrong way of doing tests before (scary). When I fixed it I noticed that noting I could do would trigger the fallback of just returning the `[ANY_AUTH_PROVIDER]` array. After talking with Constance, we could not come up with a way to trigger it either, given the conditions. She had suggested removing the first return statement but that caused an empty array being returned sometimes. Ultimately, I was able to get it working and covered with these changes. * Refactor tests per PR feedback The places where `role: 'superuser’` was deleted in the listeners was a side effect of using `setRoleMappingData` and not `mount` * Add back deleted assertion * Copy nit Co-authored-by: Constance <constancecchen@users.noreply.github.com> Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Constance <constancecchen@users.noreply.github.com>
* Add engines mock and fix mock role mapping The original asRoleMapping was merely for a smoke test in the shared component. Refactored to work better in App Search component * Add RoleMappingsLogic * Fix test description Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com> * Fix test description Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com> * Add flash messages when creating, updating or deleting * Add path and resetState calls Refactoring the tests showed me that some parts of the state weren’t being reset. * Refactor handleAuthProviderChange logic I some how got the test coverage at 100% with my wrong way of doing tests before (scary). When I fixed it I noticed that noting I could do would trigger the fallback of just returning the `[ANY_AUTH_PROVIDER]` array. After talking with Constance, we could not come up with a way to trigger it either, given the conditions. She had suggested removing the first return statement but that caused an empty array being returned sometimes. Ultimately, I was able to get it working and covered with these changes. * Refactor tests per PR feedback The places where `role: 'superuser’` was deleted in the listeners was a side effect of using `setRoleMappingData` and not `mount` * Add back deleted assertion * Copy nit Co-authored-by: Constance <constancecchen@users.noreply.github.com> Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Constance <constancecchen@users.noreply.github.com> Co-authored-by: Scotty Bollinger <scotty.bollinger@elastic.co> Co-authored-by: Jason Stoltzfus <jastoltz24@gmail.com> Co-authored-by: Constance <constancecchen@users.noreply.github.com>
…-action * 'master' of github.com:elastic/kibana: (44 commits) Migrate the optimizer mixin to core (#94272) Replace EuiCodeBlock with JsonCodeEditor in DiscoverGrid (#92442) [ML] Anomaly Detection: Migrate validation messages links to use docLinks. (#94568) [Lists][Exceptions] - Adding basic linting, i18n and storybook support (#94772) [Fleet] Add test/fix for invalid/missing ids in bulk agent reassign (#94632) [Security Solution] [Cases] Move create page components and dependencies to Cases (#94444) [ML] Data Frame Analytics accessibility tests: fix flaky outlier creation test (#94735) [Security Solutions] Remove commented out old linter rules (#94753) [App Search] Role mappings migration part 2 (#94461) [CI] Update Backport action inputs to match updated ones (#94721) [chore] Remove the infra team from CODEOWNERS (#94740) [Connectors UI] Make UI use new connector APIs (#94180) [ML] Use indices options in anomaly detection job wizards (#91830) Remove `string` as a valid registry var type value (#94174) [Alerts] Replaces legacy es client with the ElasticsearchClient for alerts and triggers_actions_ui plugins. (#93364) [Reporting-CSV Export] Re-write CSV Export using SearchSource (#88303) chore(NA): upgrade bazel rules nodejs to v3.2.2 (#94726) [APM] Settings: Update layout and update/add descriptions (#94398) skip flaky suite (#94666) [XY axis] Integrates legend color picker with the eui palette (#90589) ... # Conflicts: # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/cold_phase/cold_phase.tsx # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/searchable_snapshot_field/searchable_snapshot_field.tsx # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/constants.ts # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form/configuration_context.tsx # x-pack/plugins/index_lifecycle_management/public/shared_imports.ts
Summary
This is the part 2 of the Role Mappings to Kibana migration. This PR ports the logic file over. The full code can be found here, if QA is to be done.
Checklist