Fixes pipe I did incorrectly (#104162)

## Summary

Fixes a Cypress pipe where I was not using the correct selector and methodology. I now use the check boxes for disable-all for the test.

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
Frank Hassanabad 2021-07-01 14:33:04 -06:00 committed by GitHub
parent 1545c6618e
commit 6e74040784
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -78,10 +78,22 @@ describe('Row renderers', () => {
});
it('Selected renderer can be disabled with one click', () => {
// Ensure these elements are visible before continuing since sometimes it takes a second for the modal to show up
// and it gives the click handlers a bit of time to be initialized as well to reduce chances of flake but you still
// have to use pipe() below as an additional measure.
cy.get(TIMELINE_ROW_RENDERERS_DISABLE_ALL_BTN).should('exist');
cy.get(TIMELINE_ROW_RENDERERS_DISABLE_ALL_BTN)
.pipe(($el) => $el.trigger('click'))
.should('not.be.visible');
cy.get(TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX).should('be.checked');
// Keep clicking on the disable all button until the first element of all the elements are no longer checked.
// In cases where the click handler is not present on the page just yet, this will cause the button to be clicked
// multiple times until it sees that the click took effect. You could go through the whole list but I just check
// for the first to be unchecked and then assume the click was successful
cy.root()
.pipe(($el) => {
$el.find(TIMELINE_ROW_RENDERERS_DISABLE_ALL_BTN).trigger('click');
return $el.find(TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX).first();
})
.should('not.be.checked');
cy.intercept('PATCH', '/api/timeline').as('updateTimeline');
cy.wait('@updateTimeline').its('response.statusCode').should('eq', 200);