[Console] Fix flaky tests (#136498)

* [Console] Fix flaky tests for comments and folds]

* Fix flaky test

* Remove dismissTutorial

Co-authored-by: Muhammad Ibragimov <muhammad.ibragimov@elastic.co>
This commit is contained in:
Muhammad Ibragimov 2022-07-22 23:09:22 +05:00 committed by GitHub
parent 6911d5a7c4
commit 1cbf53e355
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 27 deletions

View file

@ -22,7 +22,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
log.debug('navigateTo console');
await PageObjects.common.navigateToApp('console');
// Ensure that the text area can be interacted with
await PageObjects.console.dismissTutorial();
await PageObjects.console.closeHelpIfExists();
await PageObjects.console.clearTextArea();
});

View file

@ -158,32 +158,40 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
describe('with folded/unfolded lines in request body', () => {
const enterRequestWithBody = async () => {
await PageObjects.console.enterRequest();
await PageObjects.console.pressEnter();
await PageObjects.console.enterText('{\n\t\t"_source": []');
const enterRequest = async () => {
await PageObjects.console.enterRequest('\nGET test/doc/1 \n{\n\t\t"_source": []');
await PageObjects.console.clickPlay();
};
it('should restore the state of folding/unfolding when navigating back to Console', async () => {
beforeEach(async () => {
await PageObjects.console.clearTextArea();
await enterRequestWithBody();
});
it('should restore the state of folding/unfolding when navigating back to Console', async () => {
await enterRequest();
await PageObjects.console.clickFoldWidget();
await PageObjects.common.navigateToApp('home');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.common.navigateToApp('console');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.console.dismissTutorial();
await PageObjects.console.closeHelpIfExists();
expect(await PageObjects.console.hasFolds()).to.be(true);
});
it('should restore the state of folding/unfolding when the page reloads', async () => {
await PageObjects.console.clearTextArea();
await enterRequestWithBody();
await enterRequest();
await PageObjects.console.clickFoldWidget();
await browser.refresh();
await PageObjects.header.waitUntilLoadingHasFinished();
expect(await PageObjects.console.hasFolds()).to.be(true);
});
it('should not have folds by default', async () => {
await enterRequest();
await browser.refresh();
await PageObjects.header.waitUntilLoadingHasFinished();
expect(await PageObjects.console.hasFolds()).to.be(false);
});
});
});
}

View file

@ -22,7 +22,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.home.addSampleDataSet('logs');
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.common.navigateToApp('console');
await PageObjects.console.dismissTutorial();
await PageObjects.console.closeHelpIfExists();
await PageObjects.console.clearTextArea();
});

View file

@ -123,15 +123,6 @@ export class ConsolePageObject extends FtrService {
return this.testSubjects.find('console-application');
}
public async dismissTutorial() {
try {
const closeButton = await this.testSubjects.find('help-close-button');
await closeButton.click();
} catch (e) {
// Ignore because it is probably not there.
}
}
// Prompt autocomplete window and provide a initial letter of properties to narrow down the results. E.g. 'b' = 'bool'
public async promptAutocomplete(letter = 'b') {
const textArea = await this.testSubjects.find('console-textarea');
@ -251,13 +242,7 @@ export class ConsolePageObject extends FtrService {
}
public async hasFolds() {
try {
const requestEditor = await this.getRequestEditor();
const folds = await requestEditor.findAllByCssSelector('.ace_fold');
return folds.length > 0;
} catch (e) {
return false;
}
return await this.find.existsByCssSelector('.ace_fold');
}
public async getResponseStatus() {
@ -265,4 +250,13 @@ export class ConsolePageObject extends FtrService {
const text = await statusBadge.getVisibleText();
return text.replace(/[^\d.]+/, '');
}
async closeHelpIfExists() {
await this.retry.try(async () => {
const helpPanelShown = await this.testSubjects.exists('help-close-button');
if (helpPanelShown) {
await this.collapseHelp();
}
});
}
}