/*********************************************************************
 * Copyright (c) 2020 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 { CLASSES } from '../../inversify.types' ; import { e2eContainer } from '../../inversify.config' ; import 'reflect-metadata' ; import { Logger } from '../../utils/Logger' ; import { PreferencesHandler } from '../../utils/PreferencesHandler' ; import { LanguageServerTests } from '../../testsLibrary/LanguageServerTests' ; import { CodeExecutionTests } from '../../testsLibrary/CodeExecutionTests' ; import { ProjectAndFileTests } from '../../testsLibrary/ProjectAndFileTests' ; import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests' ; import CheReporter from '../../driver/CheReporter' ; const workspaceHandlingTests = e2eContainer . get ( CLASSES . WorkspaceHandlingTests ) ; const projectAndFileTests = e2eContainer . get ( CLASSES . ProjectAndFileTests ) ; const commonLanguageServerTests = e2eContainer . get ( CLASSES . LanguageServerTests ) ; const codeExecutionTests = e2eContainer . get ( CLASSES . CodeExecutionTests ) ; const preferencesHandler = e2eContainer . get ( CLASSES . PreferencesHandler ) ; const workspaceStack = 'Go' ; const workspaceSampleName = 'example' ; const workspaceSubfolderName = 'outyet' ; const fileFolderPath = `${ workspaceSampleName }/${ workspaceSubfolderName }` ; const fileName = `main.go` ; const taskRunServer = '1.1 Run outyet' ; const taskStopServer = '1.2 Stop outyet' ; const taskTestOutyet = '1.3 Test outyet' ; const notificationText = 'Process 8080-tcp is now listening on port 8080. Open it ?' ; let workspaceName ; suite ( `${ workspaceStack } test` , async ( ) => { suite ( `Create ${ workspaceStack } workspace` , async ( ) => { test ( 'Workaround for issue #16113' , async ( ) => { Logger . warn ( `Manually setting a preference for golang devfile LS based on issue: https://github.com/eclipse/che/issues/16113` ) ; await preferencesHandler . setUseGoLanaguageServer ( ) ; } ) ; workspaceHandlingTests . createAndOpenWorkspace ( workspaceStack ) ; test ( 'Register running workspace' , async ( ) => { workspaceName = WorkspaceHandlingTests . getWorkspaceName ( ) ; CheReporter . registerRunningWorkspace ( workspaceName ) ; } ) ; projectAndFileTests . waitWorkspaceReadiness ( workspaceSampleName , workspaceSubfolderName , false ) ; } ) ; suite ( 'Test opening file' , async ( ) => { projectAndFileTests . openFile ( fileFolderPath , fileName ) ; } ) ; suite ( 'Test golang example' , async ( ) => { codeExecutionTests . runTask ( taskTestOutyet , 60000 ) ; codeExecutionTests . closeTerminal ( taskTestOutyet ) ; } ) ; suite ( 'Run golang example server' , async ( ) => { codeExecutionTests . runTaskWithNotification ( taskRunServer , notificationText , 40000 ) ; codeExecutionTests . runTask ( taskStopServer , 5000 ) ; } ) ; suite ( `'Language server validation'` , async ( ) => { commonLanguageServerTests . suggestionInvoking ( fileName , 42 , 10 , 'Parse' ) ; commonLanguageServerTests . autocomplete ( fileName , 42 , 10 , 'Parse' ) ; commonLanguageServerTests . errorHighlighting ( fileName , 'error;\n' , 42 ) ; } ) ; suite ( 'Stop and remove workspace' , async ( ) => { test ( `Stop and remowe workspace` , async ( ) => { await workspaceHandlingTests . stopAndRemoveWorkspace ( workspaceName ) ; } ) ; } ) ; } ) ;