From dad6c7e8e3e29f596cad6b2a998da434d90c6ce2 Mon Sep 17 00:00:00 2001 From: kevinlog Date: Thu, 26 Dec 2019 15:25:21 -0500 Subject: [PATCH 01/11] add react router to endpoint app --- .../public/applications/endpoint/index.tsx | 32 +++++++++++++++---- .../feature_controls/endpoint_spaces.ts | 15 ++++++++- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx index 1af27f039aca7e..80a2d5428070d2 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx @@ -8,24 +8,44 @@ import * as React from 'react'; import ReactDOM from 'react-dom'; import { CoreStart, AppMountParameters } from 'kibana/public'; import { I18nProvider, FormattedMessage } from '@kbn/i18n/react'; +import { History, createBrowserHistory, createHashHistory } from 'history'; +import { Route, Router, Switch } from 'react-router-dom'; /** * This module will be loaded asynchronously to reduce the bundle size of your plugin's main bundle. */ -export function renderApp(coreStart: CoreStart, { element }: AppMountParameters) { +export function renderApp(coreStart: CoreStart, { appBasePath, element }: AppMountParameters) { coreStart.http.get('/api/endpoint/hello-world'); - ReactDOM.render(, element); + const history = createHashHistory() + //const history = createBrowserHistory({ basename: appBasePath }) + ReactDOM.render(, element); return () => { ReactDOM.unmountComponentAtNode(element); }; } -const AppRoot = React.memo(() => ( +interface RouterProps { + history: History; +} + +const AppRoot: React.FC = React.memo(({history}) => ( -

- -

+ + + ( +

+ +

+ )} /> + ( +

+ +

+ )} /> + } /> +
+
)); diff --git a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts index 6b3b423e293c20..72b994bc318ec0 100644 --- a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts +++ b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts @@ -12,7 +12,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const appsMenu = getService('appsMenu'); - describe('spaces', () => { + describe.only('spaces', () => { describe('space with no features disabled', () => { before(async () => { await spacesService.create({ @@ -42,6 +42,19 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); await testSubjects.existOrFail('welcomeTitle'); }); + + it(`endpoint management shows 'Manage Endpoints'`, async () => { + await pageObjects.common.navigateToActualUrl( + 'endpoint', + '/management', + { + basePath: '/s/custom_space', + ensureCurrentUrl: false, + shouldLoginIfPrompted: false, + } + ); + await testSubjects.existOrFail('management'); + }); }); describe('space with endpoint disabled', () => { From 3a43db785d72d7a0e470955fb5ee5491288a0795 Mon Sep 17 00:00:00 2001 From: kevinlog Date: Thu, 26 Dec 2019 15:30:22 -0500 Subject: [PATCH 02/11] linting --- .../public/applications/endpoint/index.tsx | 35 ++++++++++++------- .../feature_controls/endpoint_spaces.ts | 16 ++++----- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx index 80a2d5428070d2..51a2074e4da822 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx @@ -17,9 +17,9 @@ import { Route, Router, Switch } from 'react-router-dom'; export function renderApp(coreStart: CoreStart, { appBasePath, element }: AppMountParameters) { coreStart.http.get('/api/endpoint/hello-world'); - const history = createHashHistory() - //const history = createBrowserHistory({ basename: appBasePath }) - ReactDOM.render(, element); + const history = createHashHistory(); + // const history = createBrowserHistory({ basename: appBasePath }) + ReactDOM.render(, element); return () => { ReactDOM.unmountComponentAtNode(element); @@ -30,22 +30,33 @@ interface RouterProps { history: History; } -const AppRoot: React.FC = React.memo(({history}) => ( +const AppRoot: React.FC = React.memo(({ history }) => ( - - - ( + + + (

- )} /> - ( + )} + /> + (

- )} /> - } /> -
+ )} + /> + ( + + )} + /> +
)); diff --git a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts index 72b994bc318ec0..7b7eefea781a17 100644 --- a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts +++ b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts @@ -12,7 +12,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const appsMenu = getService('appsMenu'); - describe.only('spaces', () => { + describe('spaces', () => { describe('space with no features disabled', () => { before(async () => { await spacesService.create({ @@ -44,15 +44,11 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); it(`endpoint management shows 'Manage Endpoints'`, async () => { - await pageObjects.common.navigateToActualUrl( - 'endpoint', - '/management', - { - basePath: '/s/custom_space', - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - } - ); + await pageObjects.common.navigateToActualUrl('endpoint', '/management', { + basePath: '/s/custom_space', + ensureCurrentUrl: false, + shouldLoginIfPrompted: false, + }); await testSubjects.existOrFail('management'); }); }); From e76c7e003b310b801ab547c58b29ed041a687e53 Mon Sep 17 00:00:00 2001 From: kevinlog Date: Thu, 26 Dec 2019 15:32:35 -0500 Subject: [PATCH 03/11] linting --- .../public/applications/endpoint/index.tsx | 40 +++++++------------ 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx index 51a2074e4da822..65474887f3e272 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx @@ -8,18 +8,17 @@ import * as React from 'react'; import ReactDOM from 'react-dom'; import { CoreStart, AppMountParameters } from 'kibana/public'; import { I18nProvider, FormattedMessage } from '@kbn/i18n/react'; -import { History, createBrowserHistory, createHashHistory } from 'history'; +import { History, createHashHistory } from 'history'; import { Route, Router, Switch } from 'react-router-dom'; /** * This module will be loaded asynchronously to reduce the bundle size of your plugin's main bundle. */ -export function renderApp(coreStart: CoreStart, { appBasePath, element }: AppMountParameters) { +export function renderApp(coreStart: CoreStart, { element }: AppMountParameters) { coreStart.http.get('/api/endpoint/hello-world'); - const history = createHashHistory(); - // const history = createBrowserHistory({ basename: appBasePath }) - ReactDOM.render(, element); + const history = createHashHistory() + ReactDOM.render(, element); return () => { ReactDOM.unmountComponentAtNode(element); @@ -30,33 +29,22 @@ interface RouterProps { history: History; } -const AppRoot: React.FC = React.memo(({ history }) => ( +const AppRoot: React.FC = React.memo(({history}) => ( - - - ( + + + (

- )} - /> - ( -

+ )} /> + ( +

- )} - /> - ( - - )} - /> - + )} /> + } /> + )); From 9561018ce3bfeac7c2404644f4bd510367967eb9 Mon Sep 17 00:00:00 2001 From: kevinlog Date: Thu, 26 Dec 2019 16:32:09 -0500 Subject: [PATCH 04/11] linting --- .../public/applications/endpoint/index.tsx | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx index 65474887f3e272..47fba63d2038f3 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx @@ -17,8 +17,8 @@ import { Route, Router, Switch } from 'react-router-dom'; export function renderApp(coreStart: CoreStart, { element }: AppMountParameters) { coreStart.http.get('/api/endpoint/hello-world'); - const history = createHashHistory() - ReactDOM.render(, element); + const history = createHashHistory(); + ReactDOM.render(, element); return () => { ReactDOM.unmountComponentAtNode(element); @@ -29,22 +29,33 @@ interface RouterProps { history: History; } -const AppRoot: React.FC = React.memo(({history}) => ( +const AppRoot: React.FC = React.memo(({ history }) => ( - - - ( + + + (

- )} /> - ( + )} + /> + (

- )} /> - } /> -
+ )} + /> + ( + + )} + /> +
)); From 1349fd0fcaeabde4fb273143b644849d57a52d7e Mon Sep 17 00:00:00 2001 From: kevinlog Date: Fri, 27 Dec 2019 08:10:07 -0500 Subject: [PATCH 05/11] correct tests --- .../endpoint/public/applications/endpoint/index.tsx | 7 +++++-- .../apps/endpoint/feature_controls/endpoint_spaces.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx index 47fba63d2038f3..17c00c26c3e6c8 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx @@ -45,8 +45,11 @@ const AppRoot: React.FC = React.memo(({ history }) => ( ( -

- +

+

)} /> diff --git a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts index 7b7eefea781a17..b9d1169f8958f2 100644 --- a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts +++ b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts @@ -49,7 +49,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { ensureCurrentUrl: false, shouldLoginIfPrompted: false, }); - await testSubjects.existOrFail('management'); + await testSubjects.existOrFail('endpointManagement'); }); }); From 7317dd010a15bd5a3ed1d7038b56ca297e91ba65 Mon Sep 17 00:00:00 2001 From: kevinlog Date: Fri, 27 Dec 2019 13:22:10 -0500 Subject: [PATCH 06/11] change history from hash to browser, add new test util --- test/functional/page_objects/common_page.ts | 76 +++++++++++++++---- .../public/applications/endpoint/index.tsx | 6 +- .../feature_controls/endpoint_spaces.ts | 2 +- 3 files changed, 65 insertions(+), 19 deletions(-) diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index 9629b8ccf28e12..3c2c991ed18657 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -115,6 +115,33 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo return currentUrl; } + private async navigate({ + appConfig = {}, + ensureCurrentUrl = true, + shouldLoginIfPrompted = true, + shouldAcceptAlert = true, + useActualUrl = false, + } = {}) { + const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig); + + await retry.try(async () => { + if (useActualUrl) { + log.debug(`navigateToActualUrl ${appUrl}`); + await browser.get(appUrl); + } else { + await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert); + } + + const currentUrl = shouldLoginIfPrompted + ? await this.loginIfPrompted(appUrl) + : await browser.getCurrentUrl(); + + if (ensureCurrentUrl && !currentUrl.includes(appUrl)) { + throw new Error(`expected ${currentUrl}.includes(${appUrl})`); + } + }); + } + /** * Navigates browser using the pathname from the appConfig and subUrl as the hash * @param appName As defined in the apps config, e.g. 'home' @@ -137,23 +164,42 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo hash: useActualUrl ? subUrl : `/${appName}/${subUrl}`, }; - const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig); - - await retry.try(async () => { - if (useActualUrl) { - log.debug(`navigateToActualUrl ${appUrl}`); - await browser.get(appUrl); - } else { - await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert); - } + await this.navigate({ + appConfig, + ensureCurrentUrl, + shouldLoginIfPrompted, + shouldAcceptAlert, + useActualUrl, + }); + } - const currentUrl = shouldLoginIfPrompted - ? await this.loginIfPrompted(appUrl) - : await browser.getCurrentUrl(); + /** + * Navigates browser using the pathname from the appConfig and subUrl as the extended path + * @param appName As defined in the apps config, e.g. 'home' + * @param subUrl The route after the appUrl, e.g. 'tutorial_directory/sampleData' + * @param args additional arguments + */ + public async navigateToRealUrl( + appName: string, + subUrl?: string, + { + basePath = '', + ensureCurrentUrl = true, + shouldLoginIfPrompted = true, + shouldAcceptAlert = true, + useActualUrl = true, + } = {} + ) { + const appConfig = { + pathname: `${basePath}${config.get(['apps', appName]).pathname}${subUrl}`, + }; - if (ensureCurrentUrl && !currentUrl.includes(appUrl)) { - throw new Error(`expected ${currentUrl}.includes(${appUrl})`); - } + await this.navigate({ + appConfig, + ensureCurrentUrl, + shouldLoginIfPrompted, + shouldAcceptAlert, + useActualUrl, }); } diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx index 17c00c26c3e6c8..e225997b16a2de 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx @@ -8,16 +8,16 @@ import * as React from 'react'; import ReactDOM from 'react-dom'; import { CoreStart, AppMountParameters } from 'kibana/public'; import { I18nProvider, FormattedMessage } from '@kbn/i18n/react'; -import { History, createHashHistory } from 'history'; +import { History, createBrowserHistory } from 'history'; import { Route, Router, Switch } from 'react-router-dom'; /** * This module will be loaded asynchronously to reduce the bundle size of your plugin's main bundle. */ -export function renderApp(coreStart: CoreStart, { element }: AppMountParameters) { +export function renderApp(coreStart: CoreStart, { appBasePath, element }: AppMountParameters) { coreStart.http.get('/api/endpoint/hello-world'); - const history = createHashHistory(); + const history = createBrowserHistory({ basename: appBasePath }); ReactDOM.render(, element); return () => { diff --git a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts index b9d1169f8958f2..360846e79f1a47 100644 --- a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts +++ b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts @@ -44,7 +44,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); it(`endpoint management shows 'Manage Endpoints'`, async () => { - await pageObjects.common.navigateToActualUrl('endpoint', '/management', { + await pageObjects.common.navigateToRealUrl('endpoint', '/management', { basePath: '/s/custom_space', ensureCurrentUrl: false, shouldLoginIfPrompted: false, From eff2be6ac7d03b325d3fa88b2c4de19501cd377b Mon Sep 17 00:00:00 2001 From: kevinlog Date: Fri, 27 Dec 2019 13:29:03 -0500 Subject: [PATCH 07/11] remove default values in helper functions --- test/functional/page_objects/common_page.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index 3c2c991ed18657..30c9a7a365033e 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -116,11 +116,11 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo } private async navigate({ - appConfig = {}, - ensureCurrentUrl = true, - shouldLoginIfPrompted = true, - shouldAcceptAlert = true, - useActualUrl = false, + appConfig, + ensureCurrentUrl, + shouldLoginIfPrompted, + shouldAcceptAlert, + useActualUrl, } = {}) { const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig); From 1d5221eedf5e72787532bfaf6eacdb9471b0bf5c Mon Sep 17 00:00:00 2001 From: kevinlog Date: Fri, 27 Dec 2019 14:29:44 -0500 Subject: [PATCH 08/11] fix type check, use FunctionComponent as oppsed to FC --- test/functional/page_objects/common_page.ts | 23 +++++++++++++------ .../public/applications/endpoint/index.tsx | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index 30c9a7a365033e..cb37f2b6066eda 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -39,6 +39,14 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo const defaultTryTimeout = config.get('timeouts.try'); const defaultFindTimeout = config.get('timeouts.find'); + interface NavigateProps { + appConfig: {}; + ensureCurrentUrl: boolean; + shouldLoginIfPrompted: boolean; + shouldAcceptAlert: boolean; + useActualUrl: boolean; + } + class CommonPage { /** * Navigates the browser window to provided URL @@ -115,13 +123,14 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo return currentUrl; } - private async navigate({ - appConfig, - ensureCurrentUrl, - shouldLoginIfPrompted, - shouldAcceptAlert, - useActualUrl, - } = {}) { + private async navigate(navigateProps: NavigateProps) { + const { + appConfig, + ensureCurrentUrl, + shouldLoginIfPrompted, + shouldAcceptAlert, + useActualUrl, + } = navigateProps; const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig); await retry.try(async () => { diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx index e225997b16a2de..7cd6469c3e5bd8 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx @@ -29,7 +29,7 @@ interface RouterProps { history: History; } -const AppRoot: React.FC = React.memo(({ history }) => ( +const AppRoot: React.FunctionComponent = React.memo(({ history }) => ( From 83ca1845ea055f03e7a80e208f312ef5e34baf3d Mon Sep 17 00:00:00 2001 From: kevinlog Date: Thu, 2 Jan 2020 13:04:29 -0500 Subject: [PATCH 09/11] use BrowserRouter component --- .../public/applications/endpoint/index.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx index 7cd6469c3e5bd8..865fc20d9e4385 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx @@ -8,8 +8,7 @@ import * as React from 'react'; import ReactDOM from 'react-dom'; import { CoreStart, AppMountParameters } from 'kibana/public'; import { I18nProvider, FormattedMessage } from '@kbn/i18n/react'; -import { History, createBrowserHistory } from 'history'; -import { Route, Router, Switch } from 'react-router-dom'; +import { Route, BrowserRouter, Switch } from 'react-router-dom'; /** * This module will be loaded asynchronously to reduce the bundle size of your plugin's main bundle. @@ -17,8 +16,7 @@ import { Route, Router, Switch } from 'react-router-dom'; export function renderApp(coreStart: CoreStart, { appBasePath, element }: AppMountParameters) { coreStart.http.get('/api/endpoint/hello-world'); - const history = createBrowserHistory({ basename: appBasePath }); - ReactDOM.render(, element); + ReactDOM.render(, element); return () => { ReactDOM.unmountComponentAtNode(element); @@ -26,12 +24,12 @@ export function renderApp(coreStart: CoreStart, { appBasePath, element }: AppMou } interface RouterProps { - history: History; + basename: string; } -const AppRoot: React.FunctionComponent = React.memo(({ history }) => ( +const AppRoot: React.FunctionComponent = React.memo(({basename}) => ( - + = React.memo(({ history }) = )} /> - + )); From 899b9cfa0aa0e9836a897b636d85f17fd6904fb9 Mon Sep 17 00:00:00 2001 From: kevinlog Date: Thu, 2 Jan 2020 13:05:04 -0500 Subject: [PATCH 10/11] use BrowserRouter component lin --- x-pack/plugins/endpoint/public/applications/endpoint/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx index 865fc20d9e4385..82c95b37ee7b0f 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/index.tsx @@ -27,7 +27,7 @@ interface RouterProps { basename: string; } -const AppRoot: React.FunctionComponent = React.memo(({basename}) => ( +const AppRoot: React.FunctionComponent = React.memo(({ basename }) => ( From 88aeb484af46bba109480e882a72fbb63634271a Mon Sep 17 00:00:00 2001 From: kevinlog Date: Thu, 2 Jan 2020 13:20:26 -0500 Subject: [PATCH 11/11] add comments to test framework, change function name to include browserHistory --- test/functional/page_objects/common_page.ts | 6 ++++-- .../apps/endpoint/feature_controls/endpoint_spaces.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/functional/page_objects/common_page.ts b/test/functional/page_objects/common_page.ts index cb37f2b6066eda..75a15cc16db2eb 100644 --- a/test/functional/page_objects/common_page.ts +++ b/test/functional/page_objects/common_page.ts @@ -183,12 +183,13 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo } /** - * Navigates browser using the pathname from the appConfig and subUrl as the extended path + * Navigates browser using the pathname from the appConfig and subUrl as the extended path. + * This was added to be able to test an application that uses browser history over hash history. * @param appName As defined in the apps config, e.g. 'home' * @param subUrl The route after the appUrl, e.g. 'tutorial_directory/sampleData' * @param args additional arguments */ - public async navigateToRealUrl( + public async navigateToUrlWithBrowserHistory( appName: string, subUrl?: string, { @@ -200,6 +201,7 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo } = {} ) { const appConfig = { + // subUrl following the basePath, assumes no hashes. Ex: 'app/endpoint/management' pathname: `${basePath}${config.get(['apps', appName]).pathname}${subUrl}`, }; diff --git a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts index 360846e79f1a47..1d1fb566eb075f 100644 --- a/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts +++ b/x-pack/test/functional/apps/endpoint/feature_controls/endpoint_spaces.ts @@ -44,7 +44,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); it(`endpoint management shows 'Manage Endpoints'`, async () => { - await pageObjects.common.navigateToRealUrl('endpoint', '/management', { + await pageObjects.common.navigateToUrlWithBrowserHistory('endpoint', '/management', { basePath: '/s/custom_space', ensureCurrentUrl: false, shouldLoginIfPrompted: false,