Skip to content

Commit

Permalink
[Security Solution] Unskip rules table Serverless Cypress tests (elas…
Browse files Browse the repository at this point in the history
…tic#168306)

**Addresses:** elastic#161540

## Summary

This PR unskips rules table Serverless Cypress tests

- `rules_table_auto_refresh.cy.ts`
- `rules_table_links.cy.ts`
- `rules_table_persistent_state.cy.ts`
- `rules_table_selection.cy.ts`
- `rules_table_sorting.cy.ts`

## Flaky test runner

https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3406
150 runs 🟢

(cherry picked from commit feb4222)
  • Loading branch information
maximpn committed Oct 9, 2023
1 parent 8e69872 commit 04c6220
Show file tree
Hide file tree
Showing 5 changed files with 381 additions and 406 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,137 +33,132 @@ import { getNewRule } from '../../../../objects/rule';

const RULES_TABLE_REFRESH_INTERVAL_MS = 60000;

// TODO: https://github.com/elastic/kibana/issues/161540
describe(
'Rules table: auto-refresh',
{ tags: ['@ess', '@serverless', '@brokenInServerless'] },
() => {
before(() => {
cleanKibana();
login();

setRulesTableAutoRefreshIntervalSetting({
enabled: true,
refreshInterval: RULES_TABLE_REFRESH_INTERVAL_MS,
});
createRule(getNewRule({ name: 'Test rule 1', rule_id: '1', enabled: false }));
describe('Rules table: auto-refresh', { tags: ['@ess', '@serverless'] }, () => {
before(() => {
cleanKibana();
login();

setRulesTableAutoRefreshIntervalSetting({
enabled: true,
refreshInterval: RULES_TABLE_REFRESH_INTERVAL_MS,
});
createRule(getNewRule({ name: 'Test rule 1', rule_id: '1', enabled: false }));
});

beforeEach(() => {
login();
});
beforeEach(() => {
login();
});

it('gets deactivated when any rule selected and activated after rules unselected', () => {
visitRulesManagementTable();
it('gets deactivated when any rule selected and activated after rules unselected', () => {
visitRulesManagementTable();

expectNumberOfRules(RULES_MANAGEMENT_TABLE, 1);
expectNumberOfRules(RULES_MANAGEMENT_TABLE, 1);

// check refresh settings if it's enabled before selecting
expectAutoRefreshIsEnabled();
// check refresh settings if it's enabled before selecting
expectAutoRefreshIsEnabled();

selectAllRules();
selectAllRules();

// auto refresh should be deactivated (which means disabled without an ability to enable it) after rules selected
expectAutoRefreshIsDeactivated();
// auto refresh should be deactivated (which means disabled without an ability to enable it) after rules selected
expectAutoRefreshIsDeactivated();

clearAllRuleSelection();
clearAllRuleSelection();

// after all rules unselected, auto refresh should be reset to its previous state
expectAutoRefreshIsEnabled();
});
// after all rules unselected, auto refresh should be reset to its previous state
expectAutoRefreshIsEnabled();
});

describe('when enabled', () => {
beforeEach(() => {
mockGlobalClock();
visitRulesManagementTable();
describe('when enabled', () => {
beforeEach(() => {
mockGlobalClock();
visitRulesManagementTable();

expectNumberOfRules(RULES_MANAGEMENT_TABLE, 1);
});
expectNumberOfRules(RULES_MANAGEMENT_TABLE, 1);
});

it('refreshes rules after refresh interval has passed', () => {
cy.get(RULES_TABLE_AUTOREFRESH_INDICATOR).should('not.exist');
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS);
cy.get(RULES_TABLE_AUTOREFRESH_INDICATOR).should('be.visible');
it('refreshes rules after refresh interval has passed', () => {
cy.get(RULES_TABLE_AUTOREFRESH_INDICATOR).should('not.exist');
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS);
cy.get(RULES_TABLE_AUTOREFRESH_INDICATOR).should('be.visible');

cy.contains(REFRESH_RULES_STATUS, 'Updated now');
});
cy.contains(REFRESH_RULES_STATUS, 'Updated now');
});

it('refreshes rules on window focus', () => {
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS / 2);
it('refreshes rules on window focus', () => {
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS / 2);

cy.window().trigger('blur');
cy.window().trigger('focus');
cy.window().trigger('blur');
cy.window().trigger('focus');

cy.contains(REFRESH_RULES_STATUS, 'Updated now');
});
cy.contains(REFRESH_RULES_STATUS, 'Updated now');
});
});

describe('when disabled', () => {
beforeEach(() => {
mockGlobalClock();
visitRulesManagementTable();
expectNumberOfRules(RULES_MANAGEMENT_TABLE, 1);
});
describe('when disabled', () => {
beforeEach(() => {
mockGlobalClock();
visitRulesManagementTable();
expectNumberOfRules(RULES_MANAGEMENT_TABLE, 1);
});

it('does NOT refresh rules after refresh interval has passed', () => {
disableAutoRefresh();
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS * 2); // Make sure enough time has passed to verify auto-refresh doesn't happen
it('does NOT refresh rules after refresh interval has passed', () => {
disableAutoRefresh();
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS * 2); // Make sure enough time has passed to verify auto-refresh doesn't happen

cy.contains(REFRESH_RULES_STATUS, 'Updated 2 minutes ago');
});
cy.contains(REFRESH_RULES_STATUS, 'Updated 2 minutes ago');
});

it('does NOT refresh rules on window focus', () => {
disableAutoRefresh();
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS * 2); // Make sure enough time has passed to verify auto-refresh doesn't happen
it('does NOT refresh rules on window focus', () => {
disableAutoRefresh();
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS * 2); // Make sure enough time has passed to verify auto-refresh doesn't happen

cy.window().trigger('blur');
cy.window().trigger('focus');
cy.window().trigger('blur');
cy.window().trigger('focus');

// We need to make sure window focus event doesn't cause refetching. Without some delay
// the following expectations always pass even. It happens since 'focus' event gets handled
// in an async way so the status text is updated with some delay.
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000);
// We need to make sure window focus event doesn't cause refetching. Without some delay
// the following expectations always pass even. It happens since 'focus' event gets handled
// in an async way so the status text is updated with some delay.
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000);

// By using a custom timeout make sure it doesn't wait too long due to global timeout configuration
// so the expected text appears after a refresh and the test passes while it shouldn't.
cy.contains(REFRESH_RULES_STATUS, 'Updated 2 minutes ago', { timeout: 10000 });
});
// By using a custom timeout make sure it doesn't wait too long due to global timeout configuration
// so the expected text appears after a refresh and the test passes while it shouldn't.
cy.contains(REFRESH_RULES_STATUS, 'Updated 2 minutes ago', { timeout: 10000 });
});

it('does NOT get enabled after rules were unselected', () => {
disableAutoRefresh();
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS * 2); // Make sure enough time has passed to verify auto-refresh doesn't happen
it('does NOT get enabled after rules were unselected', () => {
disableAutoRefresh();
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS * 2); // Make sure enough time has passed to verify auto-refresh doesn't happen

selectAllRules();
selectAllRules();

expectAutoRefreshIsDeactivated();
expectAutoRefreshIsDeactivated();

clearAllRuleSelection();
clearAllRuleSelection();

// after all rules unselected, auto refresh should still be disabled
expectAutoRefreshIsDisabled();
});
// after all rules unselected, auto refresh should still be disabled
expectAutoRefreshIsDisabled();
});
});

describe('when one rule is selected', () => {
it('does NOT refresh after refresh interval has passed', () => {
mockGlobalClock();
visitRulesManagementTable();
describe('when one rule is selected', () => {
it('does NOT refresh after refresh interval has passed', () => {
mockGlobalClock();
visitRulesManagementTable();

expectNumberOfRules(RULES_MANAGEMENT_TABLE, 1);
expectNumberOfRules(RULES_MANAGEMENT_TABLE, 1);

selectRulesByName(['Test rule 1']);
selectRulesByName(['Test rule 1']);

// mock 1 minute passing to make sure refresh is not conducted
cy.get(RULES_TABLE_AUTOREFRESH_INDICATOR).should('not.exist');
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS * 2); // Make sure enough time has passed
cy.get(RULES_TABLE_AUTOREFRESH_INDICATOR).should('not.exist');
// mock 1 minute passing to make sure refresh is not conducted
cy.get(RULES_TABLE_AUTOREFRESH_INDICATOR).should('not.exist');
cy.tick(RULES_TABLE_REFRESH_INTERVAL_MS * 2); // Make sure enough time has passed
cy.get(RULES_TABLE_AUTOREFRESH_INDICATOR).should('not.exist');

// ensure rule is still selected
getRuleRow('Test rule 1').find(EUI_CHECKBOX).should('be.checked');
// ensure rule is still selected
getRuleRow('Test rule 1').find(EUI_CHECKBOX).should('be.checked');

cy.get(REFRESH_RULES_STATUS).should('have.not.text', 'Updated now');
});
cy.get(REFRESH_RULES_STATUS).should('have.not.text', 'Updated now');
});
}
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import { login } from '../../../../tasks/login';
import { visit } from '../../../../tasks/navigation';
import { RULES_MANAGEMENT_URL } from '../../../../urls/rules_management';

// TODO: https://github.com/elastic/kibana/issues/161540
// Flaky in serverless tests
describe('Rules table: links', { tags: ['@ess', '@serverless', '@skipInServerless'] }, () => {
describe('Rules table: links', { tags: ['@ess', '@serverless'] }, () => {
before(() => {
cleanKibana();
});
Expand Down
Loading

0 comments on commit 04c6220

Please sign in to comment.