Backports the following commits to 6.x: - [Infra UI] functional browser test for infraops page (#24248)
This commit is contained in:
parent
f686fa699a
commit
71e4600973
|
@ -12,6 +12,7 @@ interface EmptyPageProps {
|
|||
title: string;
|
||||
actionLabel: string;
|
||||
actionUrl: string;
|
||||
'data-test-subj'?: string;
|
||||
}
|
||||
|
||||
export const EmptyPage: React.SFC<EmptyPageProps> = ({
|
||||
|
@ -19,6 +20,7 @@ export const EmptyPage: React.SFC<EmptyPageProps> = ({
|
|||
actionUrl,
|
||||
message,
|
||||
title,
|
||||
...rest
|
||||
}) => (
|
||||
<EuiEmptyPrompt
|
||||
title={<h2>{title}</h2>}
|
||||
|
@ -28,5 +30,6 @@ export const EmptyPage: React.SFC<EmptyPageProps> = ({
|
|||
{actionLabel}
|
||||
</EuiButton>
|
||||
}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -109,6 +109,7 @@ export class Waffle extends React.Component<Props, {}> {
|
|||
Check for new data
|
||||
</EuiButton>
|
||||
}
|
||||
data-test-subj="noMetricsDataPrompt"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -124,7 +125,10 @@ export class Waffle extends React.Component<Props, {}> {
|
|||
{({ measureRef, content: { width = 0, height = 0 } }) => {
|
||||
const groupsWithLayout = applyWaffleMapLayout(map, width, height);
|
||||
return (
|
||||
<WaffleMapOuterContiner innerRef={(el: any) => measureRef(el)}>
|
||||
<WaffleMapOuterContiner
|
||||
innerRef={(el: any) => measureRef(el)}
|
||||
data-test-subj="waffleMap"
|
||||
>
|
||||
<WaffleMapInnerContainer>
|
||||
{groupsWithLayout.map(this.renderGroup(bounds))}
|
||||
</WaffleMapInnerContainer>
|
||||
|
|
|
@ -38,7 +38,7 @@ export class WaffleTimeControls extends React.Component<WaffleTimeControlsProps>
|
|||
);
|
||||
|
||||
return (
|
||||
<EuiFormControlLayout append={liveStreamingButton}>
|
||||
<EuiFormControlLayout append={liveStreamingButton} data-test-subj="waffleDatePicker">
|
||||
<EuiDatePicker
|
||||
className="euiFieldText--inGroup"
|
||||
dateFormat="L LTS"
|
||||
|
|
|
@ -42,6 +42,7 @@ export class HomePage extends React.PureComponent {
|
|||
message="Let's add some!"
|
||||
actionLabel="Setup Instructions"
|
||||
actionUrl={`${basePath}/app/kibana#/home/tutorial_directory/metrics`}
|
||||
data-test-subj="noMetricsIndicesPrompt"
|
||||
/>
|
||||
)}
|
||||
</WithKibanaChrome>
|
||||
|
|
45
x-pack/test/functional/apps/infra/home_page.ts
Normal file
45
x-pack/test/functional/apps/infra/home_page.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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 { KibanaFunctionalTestDefaultProviders } from '../../../types/providers';
|
||||
|
||||
const DATE_WITH_DATA = new Date(1539806283000);
|
||||
const DATE_WITHOUT_DATA = new Date(1539122400000);
|
||||
|
||||
// tslint:disable-next-line:no-default-export
|
||||
export default ({ getPageObjects, getService }: KibanaFunctionalTestDefaultProviders) => {
|
||||
const esArchiver = getService('esArchiver');
|
||||
const pageObjects = getPageObjects(['common', 'infraHome']);
|
||||
|
||||
describe('Home page', () => {
|
||||
describe('without metrics present', () => {
|
||||
before(async () => await esArchiver.unload('infra'));
|
||||
|
||||
it('renders an empty data prompt', async () => {
|
||||
await pageObjects.common.navigateToApp('infraOps');
|
||||
await pageObjects.infraHome.getNoMetricsIndicesPrompt();
|
||||
});
|
||||
});
|
||||
|
||||
describe('with metrics present', () => {
|
||||
before(async () => {
|
||||
await esArchiver.load('infra');
|
||||
await pageObjects.common.navigateToApp('infraOps');
|
||||
});
|
||||
after(async () => await esArchiver.unload('infra'));
|
||||
|
||||
it('renders the waffle map for dates with data', async () => {
|
||||
await pageObjects.infraHome.goToTime(DATE_WITH_DATA);
|
||||
await pageObjects.infraHome.getWaffleMap();
|
||||
});
|
||||
|
||||
it('renders an empty data prompt for dates with no data', async () => {
|
||||
await pageObjects.infraHome.goToTime(DATE_WITHOUT_DATA);
|
||||
await pageObjects.infraHome.getNoMetricsDataPrompt();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
14
x-pack/test/functional/apps/infra/index.ts
Normal file
14
x-pack/test/functional/apps/infra/index.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* 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 { KibanaFunctionalTestDefaultProviders } from '../../../types/providers';
|
||||
|
||||
// tslint:disable-next-line:no-default-export
|
||||
export default ({ loadTestFile }: KibanaFunctionalTestDefaultProviders) => {
|
||||
describe('InfraOps app', () => {
|
||||
loadTestFile(require.resolve('./home_page'));
|
||||
});
|
||||
};
|
|
@ -17,6 +17,7 @@ import {
|
|||
WatcherPageProvider,
|
||||
ReportingPageProvider,
|
||||
SpaceSelectorPageProvider,
|
||||
InfraHomePageProvider,
|
||||
} from './page_objects';
|
||||
|
||||
import {
|
||||
|
@ -68,6 +69,7 @@ export default async function ({ readConfigFile }) {
|
|||
resolve(__dirname, './apps/spaces'),
|
||||
resolve(__dirname, './apps/logstash'),
|
||||
resolve(__dirname, './apps/grok_debugger'),
|
||||
resolve(__dirname, './apps/infra'),
|
||||
],
|
||||
|
||||
// define the name and providers for services that should be
|
||||
|
@ -116,6 +118,7 @@ export default async function ({ readConfigFile }) {
|
|||
watcher: WatcherPageProvider,
|
||||
reporting: ReportingPageProvider,
|
||||
spaceSelector: SpaceSelectorPageProvider,
|
||||
infraHome: InfraHomePageProvider,
|
||||
},
|
||||
|
||||
servers: kibanaFunctionalConfig.get('servers'),
|
||||
|
@ -166,6 +169,9 @@ export default async function ({ readConfigFile }) {
|
|||
},
|
||||
spaceSelector: {
|
||||
pathname: '/',
|
||||
},
|
||||
infraOps: {
|
||||
pathname: '/app/infra'
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -12,3 +12,4 @@ export { GrokDebuggerPageProvider } from './grok_debugger_page';
|
|||
export { WatcherPageProvider } from './watcher_page';
|
||||
export { ReportingPageProvider } from './reporting_page';
|
||||
export { SpaceSelectorPageProvider } from './space_selector_page';
|
||||
export { InfraHomePageProvider } from './infra_home_page';
|
||||
|
|
39
x-pack/test/functional/page_objects/infra_home_page.ts
Normal file
39
x-pack/test/functional/page_objects/infra_home_page.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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 testSubjSelector from '@kbn/test-subj-selector';
|
||||
import Keys from 'leadfoot/keys';
|
||||
import moment from 'moment';
|
||||
|
||||
import { KibanaFunctionalTestDefaultProviders } from '../../types/providers';
|
||||
|
||||
export function InfraHomePageProvider({ getService }: KibanaFunctionalTestDefaultProviders) {
|
||||
const testSubjects = getService('testSubjects');
|
||||
const find = getService('find');
|
||||
|
||||
return {
|
||||
async goToTime(time: number) {
|
||||
const datePickerInput = await find.byCssSelector(
|
||||
`${testSubjSelector('waffleDatePicker')} .euiDatePicker.euiFieldText`
|
||||
);
|
||||
|
||||
await datePickerInput.type(Array(30).fill(Keys.BACKSPACE));
|
||||
await datePickerInput.type([moment(time).format('L LTS'), Keys.RETURN]);
|
||||
},
|
||||
|
||||
async getWaffleMap() {
|
||||
return await testSubjects.find('waffleMap');
|
||||
},
|
||||
|
||||
async getNoMetricsIndicesPrompt() {
|
||||
return await testSubjects.find('noMetricsIndicesPrompt');
|
||||
},
|
||||
|
||||
async getNoMetricsDataPrompt() {
|
||||
return await testSubjects.find('noMetricsDataPrompt');
|
||||
},
|
||||
};
|
||||
}
|
12
x-pack/test/types/leadfoot.d.ts
vendored
Normal file
12
x-pack/test/types/leadfoot.d.ts
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare module 'leadfoot/keys' {
|
||||
type LeadfootKeys = 'BACKSPACE' | 'ENTER' | 'RETURN';
|
||||
|
||||
const keys: { [key in LeadfootKeys]: string };
|
||||
export default keys;
|
||||
}
|
21
x-pack/test/types/providers.ts
Normal file
21
x-pack/test/types/providers.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export interface EsArchiverOptions {
|
||||
skipExisting?: boolean;
|
||||
}
|
||||
|
||||
export interface EsArchiver {
|
||||
load(archiveName: string, options?: EsArchiverOptions): Promise<void>;
|
||||
unload(archiveName: string): Promise<void>;
|
||||
}
|
||||
|
||||
export interface KibanaFunctionalTestDefaultProviders {
|
||||
getService(serviceName: 'esArchiver'): EsArchiver;
|
||||
getService(serviceName: string): any;
|
||||
getPageObjects(pageObjectNames: string[]): any;
|
||||
loadTestFile(path: string): void;
|
||||
}
|
Loading…
Reference in a new issue