-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Close Index Component Integration Test For Index Management #114020
Added Close Index Component Integration Test For Index Management #114020
Conversation
@elasticmachine merge upstream |
…inks/kibana into Add_CIT_For_Close_Index_Operation
Pinging @elastic/kibana-stack-management (Team:Stack Management) |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @cuff-links! Changes LGTM, just had a suggestions for simplifying the button selector and maybe abstracting the clicking logic into a new action:
const closeIndexButton = contextMenu | ||
.find('button[data-test-subj="indexTableContextMenuButton"]') | ||
.at(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could simplify this a little bit by just using a selector like:
const closeIndexButton = contextMenu | |
.find('button[data-test-subj="indexTableContextMenuButton"]') | |
.at(0); | |
const closeIndexButton = find('indexContextMenu.indexTableContextMenuButton').at(0); |
Also, what do you think about abstracting this into another action that allows us to click a context menu option like:
enum ContextMenuOptions {
ToggleIndex = 0,
RefreshIndex = 2,
ClearIndexCache = 3,
FlushIndex = 4,
}
const clickContextMenuOption = async (option: ContextMenuOption) => {
const { find } = testBed;
await act(async () => {
find('indexContextMenu.indexTableContextMenuButton').at(option).simulate('click');
});
};
And then in the test we could just do:
await clickContextMenuOption(ContextMenuOptions.ToggleIndex);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work adding those tests, @cuff-links! I think the best way to solve for selecting the correct button is to add specific data-test-subj
values in this file. For example for "close index" button:
items.push({
"data-test-subj": 'closeIndexButton',
name: i18n.translate('xpack.idxMgmt.indexActionsMenu.closeIndexLabel', {
defaultMessage: 'Close {selectedIndexCount, plural, one {index} other {indices} }',
values: { selectedIndexCount },
}),
onClick: () => {
if (hasSystemIndex) {
this.closePopover();
this.setState({ renderConfirmModal: this.renderConfirmCloseModal });
return;
}
this.closePopoverAndExecute(closeIndices);
},
});
That would make other tests easier to work with too. WDYT?
I tried applying that data test subject but it did not get added to the element. The only time that the data test subject got added was if you change line 244. But that breaks several of the tests. I think perhaps handling it the way @sabarasaba mentioned may work well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest LGTM @cuff-links! I left just one small nit 🚀
const contextMenu = find('indexContextMenu'); | ||
contextMenu | ||
.find('button[data-test-subj="indexTableContextMenuButton"]') | ||
.at(option) | ||
.simulate('click'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think we can still simplify this like:
const contextMenu = find('indexContextMenu'); | |
contextMenu | |
.find('button[data-test-subj="indexTableContextMenuButton"]') | |
.at(option) | |
.simulate('click'); | |
find('indexContextMenu.indexTableContextMenuButton').at(option).simulate('click'); |
Hi @cuff-links, thanks for considering my suggestions! |
Hi @cuff-links, I was thinking about your comment that some tests get broken with the value of |
…lose_Index_Operation
…he new data test subjects.
Unrelated test failure. Gonna have jenkins retest. |
jenkins test this |
@yuliacech Updated with your PR's changes. Think we are good to go. |
…lose_Index_Operation
…lose_Index_Operation
💔 Build Failed
Failed CI StepsTest FailuresKibana Pipeline / jest / Jest Tests.x-pack/plugins/index_management/__jest__/client_integration/home. index actions from detail panel should be able to flush indexStandard Out
Stack Trace
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating this, @cuff-links! code changes LGTM 👍
… a refresh done after the close index call.
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
The following labels were identified as gaps in your version labels and will be added automatically:
If any of these should not be on your pull request, please manually remove them. |
…astic#114020) * Added close index test. * Fixed linting issues. * Fixed linting issues. * Abstracted out the index action option selection method and cleaned up test. * Merged Yulia's changes into this PR and updated the test to consume the new data test subjects. * Adjusted assertion to check for second to last request since there is a refresh done after the close index call. * Fixed linting issue. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
💔 Backport failed
Successful backport PRs will be merged automatically after passing CI. To backport manually run: |
…14020) (#121043) * Added close index test. * Fixed linting issues. * Fixed linting issues. * Abstracted out the index action option selection method and cleaned up test. * Merged Yulia's changes into this PR and updated the test to consume the new data test subjects. * Adjusted assertion to check for second to last request since there is a refresh done after the close index call. * Fixed linting issue. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: John Dorlus <silne.dorlus@elastic.co>
…astic#114020) * Added close index test. * Fixed linting issues. * Fixed linting issues. * Abstracted out the index action option selection method and cleaned up test. * Merged Yulia's changes into this PR and updated the test to consume the new data test subjects. * Adjusted assertion to check for second to last request since there is a refresh done after the close index call. * Fixed linting issue. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…14020) (#121722) * Added close index test. * Fixed linting issues. * Fixed linting issues. * Abstracted out the index action option selection method and cleaned up test. * Merged Yulia's changes into this PR and updated the test to consume the new data test subjects. * Adjusted assertion to check for second to last request since there is a refresh done after the close index call. * Fixed linting issue. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…astic#114020) * Added close index test. * Fixed linting issues. * Fixed linting issues. * Abstracted out the index action option selection method and cleaned up test. * Merged Yulia's changes into this PR and updated the test to consume the new data test subjects. * Adjusted assertion to check for second to last request since there is a refresh done after the close index call. * Fixed linting issue. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
This PR adds a component integration test that checks that we are able to click the close index button and check the last request to ensure that it was made to the close index API.