Skip to content

Commit

Permalink
Fix homepage app sample data dashboard test failures in cloud (#47737) (
Browse files Browse the repository at this point in the history
#47835)

* Improve launchSampleData of HomePageProvider for cloud testing

* Migrate to typescript
  • Loading branch information
kertal authored Oct 10, 2019
1 parent 78e95b5 commit eb13fa3
Showing 1 changed file with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down

0 comments on commit eb13fa3

Please sign in to comment.