Skip to content

Commit

Permalink
fixes flakiness (elastic#62406)
Browse files Browse the repository at this point in the history
* fixes flakiness

* updates 'number of signals' selector

* changes the way we are asserting the text
  • Loading branch information
MadameSheema committed Apr 3, 2020
1 parent f467b99 commit 115b1c8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
77 changes: 40 additions & 37 deletions x-pack/legacy/plugins/siem/cypress/integration/detections.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,47 +42,49 @@ describe('Detections', () => {
cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.then(numberOfSignals => {
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${numberOfSignals} signals`);
cy.get(SHOWING_SIGNALS).should('have.text', `Showing ${numberOfSignals} signals`);

const numberOfSignalsToBeClosed = 3;
selectNumberOfSignals(numberOfSignalsToBeClosed);

cy.get(SELECTED_SIGNALS)
.invoke('text')
.should('eql', `Selected ${numberOfSignalsToBeClosed} signals`);
cy.get(SELECTED_SIGNALS).should(
'have.text',
`Selected ${numberOfSignalsToBeClosed} signals`
);

closeSignals();
waitForSignals();
cy.reload();
waitForSignals();

const expectedNumberOfSignalsAfterClosing = +numberOfSignals - numberOfSignalsToBeClosed;
cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eq', expectedNumberOfSignalsAfterClosing.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfSignalsAfterClosing.toString()} signals`);
cy.get(NUMBER_OF_SIGNALS).should(
'have.text',
expectedNumberOfSignalsAfterClosing.toString()
);

cy.get(SHOWING_SIGNALS).should(
'have.text',
`Showing ${expectedNumberOfSignalsAfterClosing.toString()} signals`
);

goToClosedSignals();
waitForSignals();

cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eql', numberOfSignalsToBeClosed.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${numberOfSignalsToBeClosed.toString()} signals`);
cy.get(NUMBER_OF_SIGNALS).should('have.text', numberOfSignalsToBeClosed.toString());
cy.get(SHOWING_SIGNALS).should(
'have.text',
`Showing ${numberOfSignalsToBeClosed.toString()} signals`
);
cy.get(SIGNALS).should('have.length', numberOfSignalsToBeClosed);

const numberOfSignalsToBeOpened = 1;
selectNumberOfSignals(numberOfSignalsToBeOpened);

cy.get(SELECTED_SIGNALS)
.invoke('text')
.should('eql', `Selected ${numberOfSignalsToBeOpened} signal`);
cy.get(SELECTED_SIGNALS).should(
'have.text',
`Selected ${numberOfSignalsToBeOpened} signal`
);

openSignals();
waitForSignals();
Expand All @@ -93,29 +95,30 @@ describe('Detections', () => {
waitForSignals();

const expectedNumberOfClosedSignalsAfterOpened = 2;
cy.get(NUMBER_OF_SIGNALS)
.invoke('text')
.should('eql', expectedNumberOfClosedSignalsAfterOpened.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should(
'eql',
`Showing ${expectedNumberOfClosedSignalsAfterOpened.toString()} signals`
);
cy.get(NUMBER_OF_SIGNALS).should(
'have.text',
expectedNumberOfClosedSignalsAfterOpened.toString()
);
cy.get(SHOWING_SIGNALS).should(
'have.text',
`Showing ${expectedNumberOfClosedSignalsAfterOpened.toString()} signals`
);
cy.get(SIGNALS).should('have.length', expectedNumberOfClosedSignalsAfterOpened);

goToOpenedSignals();
waitForSignals();

const expectedNumberOfOpenedSignals =
+numberOfSignals - expectedNumberOfClosedSignalsAfterOpened;
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should('eql', `Showing ${expectedNumberOfOpenedSignals.toString()} signals`);

cy.get('[data-test-subj="server-side-event-count"]')
.invoke('text')
.should('eql', expectedNumberOfOpenedSignals.toString());
cy.get(SHOWING_SIGNALS).should(
'have.text',
`Showing ${expectedNumberOfOpenedSignals.toString()} signals`
);

cy.get('[data-test-subj="server-side-event-count"]').should(
'have.text',
expectedNumberOfOpenedSignals.toString()
);
});
});

Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/siem/cypress/screens/detections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const LOADING_SIGNALS_PANEL = '[data-test-subj="loading-signals-panel"]';

export const MANAGE_SIGNAL_DETECTION_RULES_BTN = '[data-test-subj="manage-signal-detection-rules"]';

export const NUMBER_OF_SIGNALS = '[data-test-subj="server-side-event-count"]';
export const NUMBER_OF_SIGNALS = '[data-test-subj="server-side-event-count"] .euiBadge__text';

export const OPEN_CLOSE_SIGNAL_BTN = '[data-test-subj="update-signal-status-button"]';

Expand Down

0 comments on commit 115b1c8

Please sign in to comment.