diff --git a/tests/e2e/pageobjects/ide/Ide.ts b/tests/e2e/pageobjects/ide/Ide.ts index ad8c8afea1..fb7aaf35b7 100644 --- a/tests/e2e/pageobjects/ide/Ide.ts +++ b/tests/e2e/pageobjects/ide/Ide.ts @@ -50,14 +50,14 @@ export class Ide { this.driverHelper.wait(2000); await this.driverHelper.waitAndSwitchToFrame(By.css(Ide.IDE_IFRAME_CSS), timeout); return; - } - + } + if (err instanceof error.TimeoutError) { - Logger.error(`Switching to IDE frame failed after ${timeout} timeout.`) + Logger.error(`Switching to IDE frame failed after ${timeout} timeout.`); throw err; - } - - Logger.error(`Switching to IDE frame failed.`) + } + + Logger.error(`Switching to IDE frame failed.`); throw err; } } @@ -83,7 +83,7 @@ export class Ide { Logger.error(`Ide.waitTaskExitCodeNotificationBoolean wait for notification timed out after ${timeout}.`); throw err; } - Logger.error(`Waiting for task notification failed.`) + Logger.error(`Waiting for task notification failed.`); throw err; } Logger.info(`Ide.waitTaskExitCodeNotification checking for correct exit core:${exitCode}`); @@ -172,14 +172,14 @@ export class Ide { if (err instanceof error.NoSuchWindowError) { await this.driverHelper.waitVisibility(idePartLocator, timeout); return; - } - + } + if (err instanceof error.TimeoutError) { - Logger.error(`Waiting for ${idePartLocator} timeouted after ${timeout} timeout.`) + Logger.error(`Waiting for ${idePartLocator} timeouted after ${timeout} timeout.`); throw err; } - - Logger.error(`Waiting for ${idePartLocator} failed.`) + + Logger.error(`Waiting for ${idePartLocator} failed.`); throw err; } } diff --git a/tests/e2e/pageobjects/ide/Terminal.ts b/tests/e2e/pageobjects/ide/Terminal.ts index 7fdb5abcd9..67ae0c355e 100644 --- a/tests/e2e/pageobjects/ide/Terminal.ts +++ b/tests/e2e/pageobjects/ide/Terminal.ts @@ -98,6 +98,14 @@ export class Terminal { return await this.driverHelper.waitAndGetText(By.xpath(Terminal.TERMINAL_ROWS_XPATH_LOCATOR_PREFFIX + `[${terminalIndex}]`), timeout); } + async getTextFromProblemsTab(timeout: number = TimeoutConstants.TS_SELENIUM_TERMINAL_DEFAULT_TIMEOUT): Promise { + Logger.debug(`Terminal.getTextFromProblemsTab`); + + const problemsTabBodyLocator: By = By.xpath(`//div[@id='problems']`); + + return await this.driverHelper.waitAndGetText(problemsTabBodyLocator, timeout); + } + async selectTabByPrefixAndWaitText(terminalTab: string, expectedText: string, timeout: number = TimeoutConstants.TS_SELENIUM_TERMINAL_DEFAULT_TIMEOUT) { Logger.debug(`Terminal.selectTabByPrefixAndWaitText tab: ${terminalTab} text: ${expectedText}`); @@ -134,6 +142,28 @@ export class Terminal { }, timeout); } + async waitTextInProblemsTab(expectedText: string, timeout: number) { + Logger.debug(`Terminal.waitTextInProblemsTab`); + + await this.selectTerminalTab('Problems', timeout); + await this.driverHelper.waitUntilTrue(async () => { + // separates each method iteration to the readable blocks in the terminal log + Logger.debug('----------------------------------------------'); + + const terminalText: string = await this.getTextFromProblemsTab(timeout); + + if (terminalText.includes(expectedText)) { + Logger.debug('Expected text is present in the terminal output'); + return true; + } + + Logger.debug('Expected text is not present in the terminal output'); + await this.driverHelper.wait(1000); + return false; + + }, timeout); + } + public async waitIconSuccess(taskName: string, timeout: number) { const terminalTabLocator: By = By.css(`${this.getTerminalTabCssLocator(taskName)} div.p-TabBar-tabIcon`); await this.driverHelper.waitVisibility(terminalTabLocator, TimeoutConstants.TS_SELENIUM_TERMINAL_DEFAULT_TIMEOUT); diff --git a/tests/e2e/tests/plugins/VscodeValePlugin.spec.ts b/tests/e2e/tests/plugins/VscodeValePlugin.spec.ts new file mode 100644 index 0000000000..e5abbba3b6 --- /dev/null +++ b/tests/e2e/tests/plugins/VscodeValePlugin.spec.ts @@ -0,0 +1,83 @@ +/********************************************************************* + * Copyright (c) 2019 Red Hat, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ + +import { Key } from 'selenium-webdriver'; +import { e2eContainer } from '../../inversify.config'; +import { Dashboard } from '../../pageobjects/dashboard/Dashboard'; +import { CLASSES } from '../../inversify.types'; +import { Ide } from '../../pageobjects/ide/Ide'; +import { ProjectTree } from '../../pageobjects/ide/ProjectTree'; +import { Editor } from '../../pageobjects/ide/Editor'; +import { DriverHelper } from '../../utils/DriverHelper'; +import { TestConstants } from '../../TestConstants'; +import { TimeoutConstants } from '../../TimeoutConstants'; +import { WorkspaceNameHandler } from '../../utils/WorkspaceNameHandler'; +import { Terminal } from '../../pageobjects/ide/Terminal'; + +const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); + +const ide: Ide = e2eContainer.get(CLASSES.Ide); +const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree); +const editor: Editor = e2eContainer.get(CLASSES.Editor); +const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); +const terminal: Terminal = e2eContainer.get(CLASSES.Terminal); + +let workspaceName: string = ''; + +const devfileUrl: string = 'https://gist.githubusercontent.com/Ohrimenko1988/d88057c847fb75b03791d8a9926ebb07/raw/994cb6a923ccf08dfa0a12b007eed84088b6a5af/valePluginTest.yaml'; +const factoryUrl: string = `${TestConstants.TS_SELENIUM_BASE_URL}/f?url=${devfileUrl}`; +const projectName: string = 'che-docs'; +const pathToFile: string = `${projectName}/modules/administration-guide/partials`; +const docFileName: string = 'assembly_authenticating-users.adoc'; + +suite('The "VscodeValePlugin" userstory', async () => { + suite('Create workspace', async () => { + test('Create workspace using factory', async () => { + await driverHelper.navigateToUrl(factoryUrl); + }); + + test('Wait until created workspace is started', async () => { + await ide.waitAndSwitchToIdeFrame(); + await ide.waitIde(TimeoutConstants.TS_SELENIUM_START_WORKSPACE_TIMEOUT); + + workspaceName = await WorkspaceNameHandler.getNameFromUrl(); + }); + }); + + suite('Check workspace readiness to work', async () => { + test('Wait until project is imported', async () => { + await projectTree.openProjectTreeContainer(); + await projectTree.waitProjectImported(projectName, 'modules'); + }); + }); + + suite('Check the "vale" plugin', async () => { + test('Check warning in the editor appearance', async () => { + await projectTree.expandPathAndOpenFile(pathToFile, docFileName); + await editor.waitWarningInLine(16); + }); + + test('Open the "Problems" terminal tab', async () => { + await editor.type(docFileName, Key.chord(Key.CONTROL, Key.SHIFT, 'm'), 3); + await terminal.waitTab('Problems', 60_000); + }); + + test('Check the vale plugin output in the "Problems" tab', async () => { + await terminal.waitTextInProblemsTab('Keep sentences short and to the point', 60_000); + }); + + }); + + suite('Delete workspace', async () => { + test('Delete workspace', async () => { + await dashboard.stopAndRemoveWorkspaceByUI(workspaceName); + }); + }); +});