/*********************************************************************
 * 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 { CLASSES } from '../../inversify.types' ; import { Ide } from '../../pageobjects/ide/Ide' ; import { ProjectTree } from '../../pageobjects/ide/ProjectTree' ; import { Editor } from '../../pageobjects/ide/Editor' ; import { TestConstants } from '../../TestConstants' ; import { TimeoutConstants } from '../../TimeoutConstants' ; import { WorkspaceNameHandler } from '../../utils/WorkspaceNameHandler' ; import { Terminal } from '../../pageobjects/ide/Terminal' ; import { Logger } from '../../utils/Logger' ; import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests' ; import CheReporter from '../../driver/CheReporter' ; import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil' ; const ide = e2eContainer . get ( CLASSES . Ide ) ; const projectTree = e2eContainer . get ( CLASSES . ProjectTree ) ; const editor = e2eContainer . get ( CLASSES . Editor ) ; const browserTabsUtil = e2eContainer . get ( CLASSES . BrowserTabsUtil ) ; const terminal = e2eContainer . get ( CLASSES . Terminal ) ; const workspaceHandlingTests = e2eContainer . get ( CLASSES . WorkspaceHandlingTests ) ; const workspaceNameHandler = e2eContainer . get ( CLASSES . WorkspaceNameHandler ) ; const devfileUrl = 'https://raw.githubusercontent.com/eclipse/che/main/tests/e2e/files/devfiles/plugins/VscodeValePlugin.yaml' ; const factoryUrl = `${ TestConstants . TS_SELENIUM_BASE_URL }/f?url=${ devfileUrl }` ; const projectName = 'che-docs' ; const pathToFile = `${ projectName }/modules/administration-guide/partials` ; const docFileName = 'assembly_authenticating-users.adoc' ; let workspaceName = '' ; suite ( 'The "VscodeValePlugin" userstory' , async ( ) => { suite ( 'Create workspace' , async ( ) => { test ( 'Create workspace using factory' , async ( ) => { await browserTabsUtil . navigateTo ( factoryUrl ) ; } ) ; test ( 'Wait until created workspace is started' , async ( ) => { await ide . waitAndSwitchToIdeFrame ( ) ; workspaceName = await workspaceNameHandler . getNameFromUrl ( ) ; CheReporter . registerRunningWorkspace ( workspaceName ) ; await ide . waitIde ( TimeoutConstants . TS_SELENIUM_START_WORKSPACE_TIMEOUT ) ; await ide . waitNotificationAndClickOnButton ( 'Do you trust the authors of' , 'Yes, I trust' , 60000 ) ; } ) ; } ) ; 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 . waitInfoInLine ( 16 , docFileName ) ; } ) ; test ( 'Open the "Problems" terminal tab' , async ( ) => { await editor . type ( docFileName , Key . chord ( Key . CONTROL , Key . SHIFT , 'm' ) , 3 ) ; await terminal . waitTab ( 'Problems' , 60000 ) ; } ) ; test ( 'Check the vale plugin output in the "Problems" tab' , async ( ) => { await terminal . waitTextInProblemsTab ( 'Keep sentences short and to the point' , 60000 ) ; } ) ; } ) ; suite ( 'Stopping and deleting the workspace' , async ( ) => { test ( 'Stop and remove workspace' , async ( ) => { if ( TestConstants . TS_DELETE_PLUGINS_TEST_WORKSPACE === 'true' ) { await workspaceHandlingTests . stopAndRemoveWorkspace ( workspaceName ) ; return ; } Logger . info ( `As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"` ) ; } ) ; } ) ; } ) ;