[Security Solution] [Detections] Fixes flakey exceptions read-only viewer cypress test (#162839)

## Summary

Ref: https://github.com/elastic/kibana/issues/162569

The test was trying to load the exceptions tab before the rule details
page loaded. Now we wait for the rule tab to load before continuing.
Something I was unaware of was that `cy.url()` will [automatically
retry](https://docs.cypress.io/api/commands/url#Assertions) until all
chained assertions have passed, which I think can be an easy way to fix
future flake issues where cypress tries to click on an element before
the new page loads.
This commit is contained in:
Devin W. Hurley 2023-08-11 23:35:20 -04:00 committed by GitHub
parent cafaa9295e
commit 7b3cc8f573
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,7 +13,7 @@ import { login, visitWithoutDateRange } from '../../../tasks/login';
import { goToExceptionsTab, goToAlertsTab } from '../../../tasks/rule_details';
import { goToRuleDetails } from '../../../tasks/alerts_detection_rules';
import { DETECTIONS_RULE_MANAGEMENT_URL } from '../../../urls/navigation';
import { deleteAlertsAndRules } from '../../../tasks/common';
import { cleanKibana, deleteAlertsAndRules } from '../../../tasks/common';
import {
NO_EXCEPTIONS_EXIST_PROMPT,
EXCEPTION_ITEM_VIEWER_CONTAINER,
@ -31,7 +31,7 @@ describe('Exceptions viewer read only', () => {
const exceptionList = getExceptionList();
before(() => {
cy.task('esArchiverResetKibana');
cleanKibana();
// create rule with exceptions
createExceptionList(exceptionList, exceptionList.list_id).then((response) => {
createRule(
@ -56,6 +56,7 @@ describe('Exceptions viewer read only', () => {
login(ROLES.reader);
visitWithoutDateRange(DETECTIONS_RULE_MANAGEMENT_URL, ROLES.reader);
goToRuleDetails();
cy.url().should('contain', 'app/security/rules/id');
goToExceptionsTab();
});