Skip to content

[ILM] Split edit policy test helpers into separate files#100807

Merged
yuliacech merged 5 commits intoelastic:masterfrom
yuliacech:ilm_tests_refactor
Jun 7, 2021
Merged

[ILM] Split edit policy test helpers into separate files#100807
yuliacech merged 5 commits intoelastic:masterfrom
yuliacech:ilm_tests_refactor

Conversation

@yuliacech
Copy link
Contributor

@yuliacech yuliacech commented May 27, 2021

Summary

Partially adresses 98031

This PR splits a previously large file edit_policy.helpers.tsx into separate files in the actions folder. The goal is to make test helpers more maintainable, readable and discoverable.

List of changes:

  • Added a method initializing default server response to reduce boilerplate code in tests
  • Removed unused boolean parameter in toggleEuiSwitch method
  • Refactored a few data-test-subjs for consistency
  • Moved functions for creating policy actions to separate files from edit_policy.helpers.tsx
  • Reorganized structure of actions object in edit_policy.helpers.tsx:
    • togglePhase is now a top level function
    • grouped form validation helpers in errors object
    • grouped rollover helpers in rollover object
    • moved setWaitForSnapshotPolicy to delete phase

The next step for this refactoring effort would be creating individual setup helpers for test 'areas', for example: a setup function to test form validation would not need to initialize timeline helpers. Similar to what @cjcenizal did in #96111.

@yuliacech yuliacech added release_note:skip Skip the PR/issue when compiling release notes v7.14.0 v8.0.0 technical debt Improvement of the software architecture and operational architecture labels May 27, 2021
@yuliacech
Copy link
Contributor Author

@elasticmachine merge upstream

*
* @param switchTestSubject The test subject of the EuiSwitch (can be a nested path. e.g. "myForm.mySwitch").
*/
toggleEuiSwitch: (switchTestSubject: T, isChecked?: boolean) => void;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The boolean was not used in the implementation of the toggle method.


let button = find('disableDeletePhaseButton');
if (!button.length) {
button = find('enableDeletePhaseButton');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A button to disable the delete phase is only shown, when the delete phase is enabled.

@yuliacech yuliacech marked this pull request as ready for review May 28, 2021 10:17
@yuliacech yuliacech requested review from a team as code owners May 28, 2021 10:17
@yuliacech
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@jbudz jbudz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified that the only two references to the second arg in toggleEuiSwitch are dropped in this PR. Works for me.

hasColdPhase: () => exists('ilmTimelineColdPhase'),
hasFrozenPhase: () => exists('ilmTimelineFrozenPhase'),
hasDeletePhase: () => exists('ilmTimelineDeletePhase'),
hasPhase: (phase: Phase) => exists(`ilmTimelinePhase-${phase}`),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sooo much nicer 👍🏼

Copy link
Member

@sabarasaba sabarasaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @yuliacech, thanks for working on this! It looks really good! I ran everything locally, works flawlessly, and sooo much more readable now. Just one no- blocking comment that we can totally ignore for now:

test(`${phase}: ${name}`, async () => {
const { actions } = testBed;
await actions[phase as 'warm' | 'cold' | 'delete' | 'frozen'].enable(true);
await actions.togglePhase(phase as 'warm' | 'cold' | 'delete' | 'frozen');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was already here from before, but feels it should be defined just once somewhere else like in common/types/index.ts and then the rest of the places would just use that definition. I found a few other instances throughout the app that define this type over and over. Totally ignore this for now as this PR is already kind of beefy, but feels we should patch it up at some point! I can create an issue for this if you think it makes sense 🐦

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the review, @sabarasaba! That is a great catch, I'll open a separate PR for this. I started looking into this and noticed that we have some aria labels missing for frozen phase and it would have totally been caught with the correct interface.

@yuliacech
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
indexLifecycleManagement 248.8KB 248.8KB -2.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@yuliacech yuliacech merged commit f7e6bfd into elastic:master Jun 7, 2021
yuliacech added a commit to yuliacech/kibana that referenced this pull request Jun 7, 2021
)

* Refactored edit policy actions into separate files

* Fixed types errors

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
yuliacech added a commit that referenced this pull request Jun 7, 2021
…101514)

* Refactored edit policy actions into separate files

* Fixed types errors

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@yuliacech yuliacech added Feature:ILM Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// labels Jun 24, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-stack-management (Team:Stack Management)

@yuliacech yuliacech deleted the ilm_tests_refactor branch July 21, 2021 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:ILM release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// technical debt Improvement of the software architecture and operational architecture v7.14.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants