Skip to content

Commit

Permalink
changes the way we are asserting the text
Browse files Browse the repository at this point in the history
  • Loading branch information
MadameSheema committed Apr 3, 2020
1 parent 9ed3ec6 commit 7e305eb
Showing 1 changed file with 39 additions and 41 deletions.
80 changes: 39 additions & 41 deletions x-pack/legacy/plugins/siem/cypress/integration/detections.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,55 +36,55 @@ describe('Detections', () => {
});

it('Closes and opens signals', () => {
const SIGNALS_TIMEOUT = 60000;

waitForSignalsPanelToBeLoaded();
waitForSignalsToBeLoaded();

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', { timeout: SIGNALS_TIMEOUT })
.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', { timeout: SIGNALS_TIMEOUT })
.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 @@ -95,32 +95,30 @@ describe('Detections', () => {
waitForSignals();

const expectedNumberOfClosedSignalsAfterOpened = 2;
cy.get(NUMBER_OF_SIGNALS)
.invoke('text', { timeout: SIGNALS_TIMEOUT })
.should('eql', expectedNumberOfClosedSignalsAfterOpened.toString());
cy.get(SHOWING_SIGNALS)
.invoke('text')
.should(
'eql',
`Showing ${expectedNumberOfClosedSignalsAfterOpened.toString()} signals`
);
cy.get(SIGNALS, { timeout: SIGNALS_TIMEOUT }).should(
'have.length',
expectedNumberOfClosedSignalsAfterOpened
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(SHOWING_SIGNALS).should(
'have.text',
`Showing ${expectedNumberOfOpenedSignals.toString()} signals`
);

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

Expand Down

0 comments on commit 7e305eb

Please sign in to comment.