[Console] unskip flaky tests (#124783)

* Unskip flaky console tests

Co-authored-by: Muhammad Ibragimov <muhammad.ibragimov@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Muhammad Ibragimov 2022-02-25 10:03:53 +05:00 committed by GitHub
parent 4155f166f3
commit 45a003fa06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 45 deletions

View file

@ -0,0 +1,62 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const log = getService('log');
const PageObjects = getPageObjects(['common', 'console']);
describe('console autocomplete feature', function describeIndexTests() {
this.tags('includeFirefox');
before(async () => {
log.debug('navigateTo console');
await PageObjects.common.navigateToApp('console');
// Ensure that the text area can be interacted with
await PageObjects.console.dismissTutorial();
});
it('should provide basic auto-complete functionality', async () => {
await PageObjects.console.enterRequest();
await PageObjects.console.promptAutocomplete();
expect(PageObjects.console.isAutocompleteVisible()).to.be.eql(true);
});
describe('with a missing comma in query', () => {
const LINE_NUMBER = 4;
beforeEach(async () => {
await PageObjects.console.clearTextArea();
await PageObjects.console.enterRequest();
});
it('should add a comma after previous non empty line', async () => {
await PageObjects.console.enterText(`{\n\t"query": {\n\t\t"match": {}`);
await PageObjects.console.pressEnter();
await PageObjects.console.pressEnter();
await PageObjects.console.pressEnter();
await PageObjects.console.promptAutocomplete();
await PageObjects.console.pressEnter();
const text = await PageObjects.console.getVisibleTextAt(LINE_NUMBER);
const lastChar = text.charAt(text.length - 1);
expect(lastChar).to.be.eql(',');
});
it('should add a comma after the triple quoted strings', async () => {
await PageObjects.console.enterText(`{\n\t"query": {\n\t\t"term": """some data"""`);
await PageObjects.console.pressEnter();
await PageObjects.console.promptAutocomplete();
await PageObjects.console.pressEnter();
const text = await PageObjects.console.getVisibleTextAt(LINE_NUMBER);
const lastChar = text.charAt(text.length - 1);
expect(lastChar).to.be.eql(',');
});
});
});
}

View file

@ -27,8 +27,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'console']);
const toasts = getService('toasts');
// FLAKY: https://github.com/elastic/kibana/issues/124104
describe.skip('console app', function describeIndexTests() {
describe('console app', function describeIndexTests() {
this.tags('includeFirefox');
before(async () => {
log.debug('navigateTo console');
@ -82,37 +81,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(initialSize.width).to.be.greaterThan(afterSize.width);
});
it('should provide basic auto-complete functionality', async () => {
// Ensure that the text area can be interacted with
await PageObjects.console.dismissTutorial();
expect(await PageObjects.console.hasAutocompleter()).to.be(false);
await PageObjects.console.enterRequest();
await PageObjects.console.promptAutocomplete();
await retry.waitFor('autocomplete to be visible', () =>
PageObjects.console.hasAutocompleter()
);
});
it('should add comma after previous non empty line on autocomplete', async () => {
const LINE_NUMBER = 4;
await PageObjects.console.dismissTutorial();
await PageObjects.console.clearTextArea();
await PageObjects.console.enterRequest();
await PageObjects.console.enterText(`{\n\t"query": {\n\t\t"match": {}`);
await PageObjects.console.pressEnter();
await PageObjects.console.pressEnter();
await PageObjects.console.pressEnter();
await PageObjects.console.promptAutocomplete();
await PageObjects.console.pressEnter();
const textOfPreviousNonEmptyLine = await PageObjects.console.getVisibleTextAt(LINE_NUMBER);
log.debug(textOfPreviousNonEmptyLine);
const lastChar = textOfPreviousNonEmptyLine.charAt(textOfPreviousNonEmptyLine.length - 1);
expect(lastChar).to.be.equal(',');
});
describe('with a data URI in the load_from query', () => {
it('loads the data from the URI', async () => {
await PageObjects.common.navigateToApp('console', {

View file

@ -9,8 +9,7 @@
export default function ({ getService, loadTestFile }) {
const browser = getService('browser');
// FLAKY: https://github.com/elastic/kibana/issues/123556
describe.skip('console app', function () {
describe('console app', function () {
this.tags('ciGroup1');
before(async function () {
@ -18,5 +17,6 @@ export default function ({ getService, loadTestFile }) {
});
loadTestFile(require.resolve('./_console'));
loadTestFile(require.resolve('./_autocomplete'));
});
}

View file

@ -87,14 +87,15 @@ export class ConsolePageObject extends FtrService {
const textArea = await this.testSubjects.find('console-textarea');
// There should be autocomplete for this on all license levels
await textArea.pressKeys([Key.CONTROL, Key.SPACE]);
await this.retry.waitFor('autocomplete to be visible', () => this.isAutocompleteVisible());
}
public async hasAutocompleter(): Promise<boolean> {
try {
return Boolean(await this.find.byCssSelector('.ace_autocomplete'));
} catch (e) {
return false;
}
public async isAutocompleteVisible() {
const element = await this.find.byCssSelector('.ace_autocomplete');
if (!element) return false;
const attribute = await element.getAttribute('style');
return !attribute.includes('display: none;');
}
public async enterRequest(request: string = '\nGET _search') {
@ -104,8 +105,8 @@ export class ConsolePageObject extends FtrService {
}
public async enterText(text: string) {
const textArea = await this.getEditorTextArea();
await textArea.pressKeys(text);
const textArea = await this.testSubjects.find('console-textarea');
await textArea.type(text);
}
private async getEditorTextArea() {
@ -138,9 +139,16 @@ export class ConsolePageObject extends FtrService {
}
public async clearTextArea() {
const textArea = await this.getEditorTextArea();
await this.retry.try(async () => {
await this.retry.waitForWithTimeout('text area is cleared', 20000, async () => {
const textArea = await this.testSubjects.find('console-textarea');
await textArea.clickMouseButton();
await textArea.clearValueWithKeyboard();
const editor = await this.getEditor();
const lines = await editor.findAllByClassName('ace_line_group');
// there should be only one empty line after clearing the textarea
const text = await lines[lines.length - 1].getVisibleText();
return lines.length === 1 && text.trim() === '';
});
}
}