Fix homepage app sample data dashboard test failures in cloud (#47737)

* Improve launchSampleData of HomePageProvider for cloud testing

* Migrate to typescript
This commit is contained in:
Matthias Wilhelm 2019-10-10 16:34:33 +02:00 committed by GitHub
parent 3632bd62f4
commit 696214c59a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,47 +17,42 @@
* under the License.
*/
export function HomePageProvider({ getService }) {
import { FtrProviderContext } from '../ftr_provider_context';
export function HomePageProvider({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const find = getService('find');
class HomePage {
async clickSynopsis(title) {
async clickSynopsis(title: string) {
await testSubjects.click(`homeSynopsisLink${title}`);
}
async doesSynopsisExist(title) {
async doesSynopsisExist(title: string) {
return await testSubjects.exists(`homeSynopsisLink${title}`);
}
async doesSampleDataSetExist(id) {
async doesSampleDataSetExist(id: string) {
return await testSubjects.exists(`sampleDataSetCard${id}`);
}
async doesSampleDataSetSuccessfulInstallToastExist() {
return await testSubjects.exists('sampleDataSetInstallToast');
}
async doesSampleDataSetSuccessfulUninstallToastExist() {
return await testSubjects.exists('sampleDataSetUninstallToast');
}
async isSampleDataSetInstalled(id) {
async isSampleDataSetInstalled(id: string) {
return await testSubjects.exists(`removeSampleDataSet${id}`);
}
async addSampleDataSet(id) {
async addSampleDataSet(id: string) {
await testSubjects.click(`addSampleDataSet${id}`);
await this._waitForSampleDataLoadingAction(id);
}
async removeSampleDataSet(id) {
async removeSampleDataSet(id: string) {
await testSubjects.click(`removeSampleDataSet${id}`);
await this._waitForSampleDataLoadingAction(id);
}
// loading action is either uninstall and install
async _waitForSampleDataLoadingAction(id) {
async _waitForSampleDataLoadingAction(id: string) {
const sampleDataCard = await testSubjects.find(`sampleDataSetCard${id}`);
await retry.try(async () => {
// waitForDeletedByCssSelector needs to be inside retry because it will timeout at least once
@ -66,22 +61,27 @@ export function HomePageProvider({ getService }) {
});
}
async launchSampleDataSet(id) {
await testSubjects.click(`launchSampleDataSet${id}`);
async launchSampleDataSet(id: string) {
if (await find.existsByCssSelector(`#sampleDataLinks${id}`)) {
// omits cloud test failures
await find.clickByCssSelectorWhenNotDisabled(`#sampleDataLinks${id}`);
await find.clickByCssSelector('.euiContextMenuItem:nth-of-type(1)');
} else {
await testSubjects.click(`launchSampleDataSet${id}`);
}
}
async loadSavedObjects() {
await retry.try(async () => {
await testSubjects.click('loadSavedObjects');
const successMsgExists = await testSubjects.exists('loadSavedObjects_success', {
timeout: 5000
timeout: 5000,
});
if (!successMsgExists) {
throw new Error('Failed to load saved objects');
}
});
}
}
return new HomePage();