diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx index 28fd784aed184..c89d59be620ab 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx @@ -298,6 +298,7 @@ export const PolicyList = React.memo(() => { iconType="plusInCircle" onClick={handleCreatePolicyClick} isDisabled={isFetchingPackageInfo} + data-test-subj="headerCreateNewPolicyButton" > { + 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'); @@ -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 () => {}); + }); }); } diff --git a/x-pack/test/security_solution_endpoint/page_objects/index.ts b/x-pack/test/security_solution_endpoint/page_objects/index.ts index 5b550bea5b55d..10d4eb6cb42c0 100644 --- a/x-pack/test/security_solution_endpoint/page_objects/index.ts +++ b/x-pack/test/security_solution_endpoint/page_objects/index.ts @@ -9,6 +9,7 @@ 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, @@ -16,4 +17,5 @@ export const pageObjects = { policy: EndpointPolicyPageProvider, endpointPageUtils: EndpointPageUtils, endpointAlerts: EndpointAlertsPageProvider, + ingestManager: IngestManager, }; diff --git a/x-pack/test/security_solution_endpoint/page_objects/ingest_manager.ts b/x-pack/test/security_solution_endpoint/page_objects/ingest_manager.ts new file mode 100644 index 0000000000000..a19fdad18e575 --- /dev/null +++ b/x-pack/test/security_solution_endpoint/page_objects/ingest_manager.ts @@ -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() {}, + }; +} diff --git a/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts b/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts index aa9c5361de846..92313d4662ecd 100644 --- a/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts +++ b/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts @@ -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'); + }, }; }