Skip to content

Commit

Permalink
[Security Solution] Fix flaky policy tests (elastic#139660)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlog authored and Mpdreamz committed Sep 6, 2022
1 parent 719bd83 commit 35cfb33
Showing 1 changed file with 3 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { PolicyTestResourceInfo } from '../../services/endpoint_policy';

export default function ({ getPageObjects, getService }: FtrProviderContext) {
const browser = getService('browser');
const retryService = getService('retry');
const pageObjects = getPageObjects([
'common',
'endpoint',
Expand All @@ -30,8 +29,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
let indexedData: IndexedHostsAndAlertsResponse;

before(async () => {
const endpointPackage = await policyTestResources.getEndpointPackage();
await endpointTestResources.setMetadataTransformFrequency('1s', endpointPackage.version);
indexedData = await endpointTestResources.loadEndpointData();
await browser.refresh();
});
Expand Down Expand Up @@ -127,8 +124,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
});
});

// FLAKY: https://github.com/elastic/kibana/issues/92567
describe.skip('and the save button is clicked', () => {
describe('and the save button is clicked', () => {
let policyInfo: PolicyTestResourceInfo;

beforeEach(async () => {
Expand Down Expand Up @@ -185,7 +181,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await pageObjects.policy.confirmAndSave();

await testSubjects.existOrFail('policyDetailsSuccessMessage');
await testSubjects.waitForHidden('toastCloseButton');
await testSubjects.waitForDeleted('toastCloseButton');

const agentFullPolicy = await policyTestResources.getFullAgentPolicy(
policyInfo.agentPolicy.id
Expand Down Expand Up @@ -224,7 +220,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await advancedPolicyField.clearValueWithKeyboard();

// Make sure the toast button closes so the save button on the sticky footer is visible
await testSubjects.waitForHidden('toastCloseButton');
await testSubjects.waitForDeleted('toastCloseButton');
await pageObjects.policy.confirmAndSave();

await testSubjects.existOrFail('policyDetailsSuccessMessage');
Expand Down Expand Up @@ -270,35 +266,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await pageObjects.policy.waitForCheckboxSelectionChange('policyWindowsEvent_dns', false);
});

// Failing: See https://github.com/elastic/kibana/issues/100236
it.skip('should preserve updates done from the Fleet form', async () => {
// Fleet has its own form inputs, like description. When those are updated, the changes
// are also dispatched to the embedded endpoint Policy form. Update to the Endpoint Policy
// form after that should preserve the changes done on the Fleet form
// NOTE: A few delays were added below due to sporadic failures of this test case (see #100236)
const sleep = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));

// Wait for the endpoint form to load and then update the policy description
await testSubjects.existOrFail('endpointIntegrationPolicyForm');
await sleep(); // Allow forms to sync
await pageObjects.ingestManagerCreatePackagePolicy.setPackagePolicyDescription(
'protect everything'
);
await sleep(); // Allow forms to sync

const winDnsEventingCheckbox = await testSubjects.find('policyWindowsEvent_dns');
await pageObjects.ingestManagerCreatePackagePolicy.scrollToCenterOfWindow(
winDnsEventingCheckbox
);
await pageObjects.endpointPageUtils.clickOnEuiCheckbox('policyWindowsEvent_dns');

await retryService.try(async () => {
expect(
await pageObjects.ingestManagerCreatePackagePolicy.getPackagePolicyDescriptionValue()
).to.be('protect everything');
});
});

it('should include updated endpoint data when saved', async () => {
await pageObjects.ingestManagerCreatePackagePolicy.scrollToCenterOfWindow(
await testSubjects.find('policyWindowsEvent_dns')
Expand Down

0 comments on commit 35cfb33

Please sign in to comment.