diff --git a/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx b/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx index abef8afcc398..4abc37a455d0 100644 --- a/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx +++ b/src/plugins/console/public/application/containers/editor/legacy/console_editor/editor.tsx @@ -97,6 +97,7 @@ function EditorUI({ initialTextValue }: EditorProps) { if (textareaElement) { textareaElement.setAttribute('id', inputId); + textareaElement.setAttribute('data-test-subj', 'console-textarea'); } const readQueryParams = () => { @@ -204,7 +205,7 @@ function EditorUI({ initialTextValue }: EditorProps) { }, [sendCurrentRequestToES, openDocumentation]); return ( -
+
    { - const editor = await find.byCssSelector('.conApp'); + const editor = await PageObjects.console.getEditor(); await browser.setWindowSize(1300, 1100); const initialSize = await editor.getSize(); await browser.setWindowSize(1000, 1100); const afterSize = await editor.getSize(); 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.promptAutocomplete(); + retry.waitFor('autocomplete to be visible', () => PageObjects.console.hasAutocompleter()); + }); }); } diff --git a/test/functional/page_objects/console_page.ts b/test/functional/page_objects/console_page.ts index f67a2722da36..5b0fcd0d331b 100644 --- a/test/functional/page_objects/console_page.ts +++ b/test/functional/page_objects/console_page.ts @@ -17,12 +17,14 @@ * under the License. */ +import { Key } from 'selenium-webdriver'; import { FtrProviderContext } from '../ftr_provider_context'; import { WebElementWrapper } from '../services/lib/web_element_wrapper'; export function ConsolePageProvider({ getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); + const find = getService('find'); class ConsolePage { public async getVisibleTextFromAceEditor(editor: WebElementWrapper) { @@ -79,6 +81,38 @@ export function ConsolePageProvider({ getService }: FtrProviderContext) { public async getRequestFontSize() { return await this.getFontSize(await this.getRequestEditor()); } + + public async getEditor() { + return testSubjects.find('console-application'); + } + + public async dismissTutorial() { + try { + const closeButton = await testSubjects.find('help-close-button'); + await closeButton.click(); + } catch (e) { + // Ignore because it is probably not there. + } + } + + public async promptAutocomplete() { + // This focusses the cursor on the bottom of the text area + const editor = await this.getEditor(); + const content = await editor.findByCssSelector('.ace_content'); + await content.click(); + const textArea = await testSubjects.find('console-textarea'); + // There should be autocomplete for this on all license levels + await textArea.pressKeys('\nGET s'); + await textArea.pressKeys([Key.CONTROL, Key.SPACE]); + } + + public async hasAutocompleter(): Promise { + try { + return Boolean(await find.byCssSelector('.ace_autocomplete')); + } catch (e) { + return false; + } + } } return new ConsolePage();