/*********************************************************************
 * 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 'reflect-metadata' ; import { LanguageServerTests } from '../../testsLibrary/LanguageServerTests' ; import { e2eContainer } from '../../inversify.config' ; 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 workspaceStack = 'NodeJS Express Web Application' ; const workspaceSampleName = 'nodejs-web-app' ; const workspaceRootFolderName = 'app' ; const fileFolderPath = `${ workspaceSampleName }/${ workspaceRootFolderName }` ; const fileName = `app.js` ; const taskDownloadDependencies = 'download dependencies' ; const taskRunWebApp = 'run the web app' ; const taskExpectedDialogText = 'Process nodejs is now listening on port 3000. Open it ?' ; let workspaceName ; suite ( `${ workspaceStack } test` , async ( ) => { suite ( `Create ${ workspaceStack }` , async ( ) => { workspaceHandlingTests . createAndOpenWorkspace ( workspaceStack ) ; test ( 'Register running workspace' , async ( ) => { workspaceName = WorkspaceHandlingTests . getWorkspaceName ( ) ; CheReporter . registerRunningWorkspace ( workspaceName ) ; } ) ; projectAndFileTests . waitWorkspaceReadiness ( workspaceSampleName , workspaceRootFolderName , false ) ; } ) ; suite ( 'Test opening file' , async ( ) => { projectAndFileTests . openFile ( fileFolderPath , fileName ) ; } ) ; suite ( 'Download dependencies' , async ( ) => { codeExecutionTests . runTask ( taskDownloadDependencies , 60000 ) ; codeExecutionTests . closeTerminal ( taskDownloadDependencies ) ; } ) ; suite ( 'Run nodejs application' , async ( ) => { codeExecutionTests . runTaskWithNotification ( taskRunWebApp , taskExpectedDialogText , 30000 ) ; } ) ; suite ( `'Language server validation'` , async ( ) => { commonLanguageServerTests . errorHighlighting ( fileName , 'error text;\n' , 17 ) ; commonLanguageServerTests . suggestionInvoking ( fileName , 15 , 20 , 'require' ) ; commonLanguageServerTests . autocomplete ( fileName , 15 , 20 , 'require' ) ; } ) ; suite ( 'Stop and remove workspace' , async ( ) => { test ( `Stop and remowe workspace` , async ( ) => { await workspaceHandlingTests . stopAndRemoveWorkspace ( workspaceName ) ; } ) ; } ) ; } ) ;