-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Infra UI] functional browser test for infraops page (#24248)
- Loading branch information
1 parent
914bf52
commit 744edd9
Showing
11 changed files
with
148 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |