Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Failing Test] Fixes Spaces Data Before All Failure #147519

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 40 additions & 15 deletions test/functional/page_objects/home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class HomePageObject extends FtrService {
private readonly retry = this.ctx.getService('retry');
private readonly find = this.ctx.getService('find');
private readonly common = this.ctx.getPageObject('common');
public readonly log = this.ctx.getService('log');

async clickSynopsis(title: string) {
await this.testSubjects.click(`homeSynopsisLink${title}`);
Expand All @@ -27,17 +28,27 @@ export class HomePageObject extends FtrService {
}

async openSampleDataAccordion() {
const accordion = await this.testSubjects.find('showSampleDataAccordion');
const className = await accordion.getAttribute('class');

if (!className.includes('euiAccordion-isOpen')) {
await this.testSubjects.click('showSampleDataButton');
const accordionButton = await this.testSubjects.find('showSampleDataButton');
let expandedAttribute = await accordionButton.getAttribute('aria-expanded');
let expanded = expandedAttribute.toLocaleLowerCase().includes('true');
this.log.debug(`Sample data accordion expanded: ${expanded}`);

if (!expanded) {
await this.retry.waitFor('sample data according to be expanded', async () => {
this.log.debug(`Opening sample data accordion`);
await accordionButton.click();
expandedAttribute = await accordionButton.getAttribute('aria-expanded');
expanded = expandedAttribute.toLocaleLowerCase().includes('true');
return expanded;
});
this.log.debug(`Sample data accordion expanded: ${expanded}`);
}
}

async isSampleDataSetInstalled(id: string) {
const sampleDataCard = await this.testSubjects.find(`sampleDataSetCard${id}`);
const deleteButton = await sampleDataCard.findAllByTestSubject(`removeSampleDataSet${id}`);
this.log.debug(`Sample data installed: ${deleteButton.length > 0}`);
return deleteButton.length > 0;
}

Expand Down Expand Up @@ -66,8 +77,14 @@ export class HomePageObject extends FtrService {
await this.openSampleDataAccordion();
const isInstalled = await this.isSampleDataSetInstalled(id);
if (!isInstalled) {
await this.retry.waitFor('wait until sample data is installed', async () => {
this.log.debug(`Attempting to add sample data: ${id}`);
await this.retry.waitFor('sample data to be installed', async () => {
// Echoing the adjustments made to 'removeSampleDataSet', as we are seeing flaky test cases here as well
// https://github.com/elastic/kibana/issues/52714
await this.testSubjects.waitForEnabled(`addSampleDataSet${id}`);
await this.common.sleep(1010);
await this.testSubjects.click(`addSampleDataSet${id}`);
await this.common.sleep(1010);
await this._waitForSampleDataLoadingAction(id);
return await this.isSampleDataSetInstalled(id);
});
Expand All @@ -76,15 +93,22 @@ export class HomePageObject extends FtrService {

async removeSampleDataSet(id: string) {
await this.openSampleDataAccordion();
// looks like overkill but we're hitting flaky cases where we click but it doesn't remove
await this.testSubjects.waitForEnabled(`removeSampleDataSet${id}`);
// https://github.com/elastic/kibana/issues/65949
// Even after waiting for the "Remove" button to be enabled we still have failures
// where it appears the click just didn't work.
await this.common.sleep(1010);
await this.testSubjects.click(`removeSampleDataSet${id}`);
await this.common.sleep(1010);
await this._waitForSampleDataLoadingAction(id);
const isInstalled = await this.isSampleDataSetInstalled(id);
if (isInstalled) {
this.log.debug(`Attempting to remove sample data: ${id}`);
await this.retry.waitFor('sample data to be removed', async () => {
// looks like overkill but we're hitting flaky cases where we click but it doesn't remove
await this.testSubjects.waitForEnabled(`removeSampleDataSet${id}`);
// https://github.com/elastic/kibana/issues/65949
// Even after waiting for the "Remove" button to be enabled we still have failures
// where it appears the click just didn't work.
await this.common.sleep(1010);
await this.testSubjects.click(`removeSampleDataSet${id}`);
await this.common.sleep(1010);
await this._waitForSampleDataLoadingAction(id);
return !(await this.isSampleDataSetInstalled(id));
});
}
}

// loading action is either uninstall and install
Expand All @@ -93,6 +117,7 @@ export class HomePageObject extends FtrService {
await this.retry.try(async () => {
// waitForDeletedByCssSelector needs to be inside retry because it will timeout at least once
// before action is complete
this.log.debug(`Waiting for loading spinner to be deleted for sampleDataSetCard${id}`);
await sampleDataCard.waitForDeletedByCssSelector('.euiLoadingSpinner');
});
}
Expand Down