Skip to content

Commit

Permalink
Start work on Functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-tavares committed Jun 12, 2020
1 parent f59602e commit 7c2101d
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ export const PolicyList = React.memo(() => {
iconType="plusInCircle"
onClick={handleCreatePolicyClick}
isDisabled={isFetchingPackageInfo}
data-test-subj="headerCreateNewPolicyButton"
>
<FormattedMessage
id="xpack.securitySolution.endpoint.policyList.createNewButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import { FtrProviderContext } from '../../ftr_provider_context';
import { PolicyTestResourceInfo } from '../../services/endpoint_policy';

export default function ({ getPageObjects, getService }: FtrProviderContext) {
const pageObjects = getPageObjects(['common', 'endpoint', 'policy', 'endpointPageUtils']);
const pageObjects = getPageObjects([
'common',
'endpoint',
'policy',
'endpointPageUtils',
'ingestManager',
]);
const testSubjects = getService('testSubjects');
const policyTestResources = getService('policyTestResources');
const RELATIVE_DATE_FORMAT = /\d (?:seconds|minutes) ago/i;
Expand All @@ -26,6 +32,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const policyTitle = await testSubjects.getVisibleText('pageViewHeaderLeftTitle');
expect(policyTitle).to.equal('Policies');
});
it('shows header create policy button', async () => {
const createButtonTitle = await testSubjects.getVisibleText('headerCreateNewPolicyButton');
expect(createButtonTitle).to.equal('Create new policy');
});
it('shows policy count total', async () => {
const policyTotal = await testSubjects.getVisibleText('policyTotalCount');
expect(policyTotal).to.equal('0 Policies');
Expand Down Expand Up @@ -89,5 +99,19 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
);
});
});

describe('and user clicks on page header create button', () => {
beforeEach(async () => {
await pageObjects.policy.navigateToPolicyList();
});

it('should redirect to ingest management integrations add datasource', async () => {
const headerCreateButton = await pageObjects.policy.findHeaderCreateNewButton();
await headerCreateButton.click();
await pageObjects.ingestManager.ensureDatasourceCratePageOrFail();
});
it('should redirect user back to Policy List if Cancel button is clicked', async () => {});
it('should redirect user back to Policy List after a successful save', async () => {});
});
});
}
2 changes: 2 additions & 0 deletions x-pack/test/security_solution_endpoint/page_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { EndpointPageProvider } from './endpoint_page';
import { EndpointAlertsPageProvider } from './endpoint_alerts_page';
import { EndpointPolicyPageProvider } from './policy_page';
import { EndpointPageUtils } from './page_utils';
import { IngestManager } from './ingest_manager';

export const pageObjects = {
...xpackFunctionalPageObjects,
endpoint: EndpointPageProvider,
policy: EndpointPolicyPageProvider,
endpointPageUtils: EndpointPageUtils,
endpointAlerts: EndpointAlertsPageProvider,
ingestManager: IngestManager,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { FtrProviderContext } from '../ftr_provider_context';

export function IngestManager({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');

return {
/**
* Validates that the page shown is the Datasource Craete Page
*/
async ensureDatasourceCratePageOrFail() {
await testSubjects.existOrFail('createDataSource_header');
},

async findDatasourceCreateCancelButton() {},

async findDatasourceCreateBackLink() {},

async findDatasourceCreateSaveButton() {},
};
}
11 changes: 11 additions & 0 deletions x-pack/test/security_solution_endpoint/page_objects/policy_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,16 @@ export function EndpointPolicyPageProvider({ getService, getPageObjects }: FtrPr
await testSubjects.existOrFail('policyDetailsConfirmModal');
await pageObjects.common.clickConfirmOnModal();
},

/**
* Finds and returns the Create New policy Policy button displayed on the List page
*/
async findHeaderCreateNewButton() {
// The Create button is initially disabled because we need to first make a call to Ingest
// to retrieve the package version, so that the redirect works as expected. So, we wait
// for that to occur here a well.
await testSubjects.waitForEnabled('headerCreateNewPolicyButton');
return await testSubjects.find('headerCreateNewPolicyButton');
},
};
}

0 comments on commit 7c2101d

Please sign in to comment.