44 *-----------------------------------------------------------------------------------------------*/
55
66import { expect } from 'chai' ;
7- import { ActivityBar , InputBox , SideBarView , TreeItem , ViewSection , VSBrowser , WelcomeContentButton , Workbench } from 'vscode-extension-tester' ;
8- import { itemExists , notificationExists , terminalHasText , waitForInputProgress , waitForInputUpdate } from '../common/conditions' ;
9- import { VIEWS , MENUS , BUTTONS , INPUTS , COMPONENTS , NOTIFICATIONS } from '../common/constants' ;
7+ import { ActivityBar , EditorView , InputBox , SideBarView , TerminalView , TreeItem , ViewSection , VSBrowser , WelcomeContentButton , Workbench } from 'vscode-extension-tester' ;
8+ import { itemExists , notificationExists , terminalHasText , waitForInputUpdate } from '../common/conditions' ;
9+ import { BUTTONS , COMPONENTS , INPUTS , MENUS , NOTIFICATIONS , VIEWS } from '../common/constants' ;
1010
1111export function createComponentTest ( contextFolder : string ) {
12- describe ( 'Component creation' , ( ) => {
13- const cluster = process . env . CLUSTER_URL || 'https://api.ocp2.adapters-crs.ccitredhat.com :6443' ;
14- const clusterName = ( / h t t p s ? : \/ \/ ( . * ) / . exec ( cluster ) ) [ 1 ] ;
12+ describe ( 'Component creation' , function ( ) {
13+ const cluster = process . env . CLUSTER_URL || 'https://api.crc.testing :6443' ;
14+ const clusterName = cluster ;
1515 const user = process . env . CLUSTER_USER || 'developer' ;
1616 const password = process . env . CLUSTER_PASSWORD || 'developer' ;
1717 let view : SideBarView ;
1818 let explorer : ViewSection ;
1919 let components : ViewSection ;
20+ let editorView : EditorView ;
2021
2122 const projectName = `project${ Math . floor ( Math . random ( ) * 100 ) } `
22- const appName = `app${ Math . floor ( Math . random ( ) * 100 ) } ` ;
2323 const compName = `comp${ Math . floor ( Math . random ( ) * 100 ) } ` ;
2424
25- before ( async ( ) => {
25+ before ( async function ( ) {
2626 view = await ( await new ActivityBar ( ) . getViewControl ( VIEWS . openshift ) ) . openView ( ) ;
2727 explorer = await view . getContent ( ) . getSection ( VIEWS . appExplorer ) ;
2828 components = await view . getContent ( ) . getSection ( VIEWS . components ) ;
2929 } ) ;
3030
31- beforeEach ( async ( ) => {
31+ beforeEach ( async function ( ) {
3232 const center = await new Workbench ( ) . openNotificationsCenter ( ) ;
3333 await center . clearAllNotifications ( ) ;
3434 } ) ;
3535
36+ afterEach ( async function ( ) {
37+ editorView = new EditorView ( ) ;
38+ await editorView . closeAllEditors ( ) ;
39+ } ) ;
40+
3641 after ( async function ( ) {
3742 this . timeout ( 60000 ) ;
3843 const projectItem = await explorer . findItem ( projectName ) ;
@@ -46,7 +51,7 @@ export function createComponentTest(contextFolder: string) {
4651 } ) ;
4752
4853 it ( 'Login with credentials' , async function ( ) {
49- this . timeout ( 30000 ) ;
54+ this . timeout ( 30_000 ) ;
5055 await explorer . expand ( ) ;
5156 const content = await explorer . findWelcomeContent ( ) ;
5257 // eslint-disable-next-line no-console, @typescript-eslint/restrict-template-expressions
@@ -118,54 +123,61 @@ export function createComponentTest(contextFolder: string) {
118123 } ) ;
119124
120125 it ( 'Create a new component from scratch' , async function ( ) {
121- this . timeout ( 60000 ) ;
122- const newComponent = ( await ( await components . findWelcomeContent ( ) ) . getButtons ( ) ) [ 0 ] ;
126+ this . timeout ( 120_000 ) ;
127+ const newComponent = ( await ( await components . findWelcomeContent ( ) ) . getButtons ( ) ) [ 1 ] ;
123128 await newComponent . click ( ) ;
124129
125- // provide application name
130+ // wait for input quick pick to appear
126131 const input = await InputBox . create ( ) ;
127- const appMessage = await input . getMessage ( ) ;
128- await input . setText ( appName ) ;
129- await input . confirm ( ) ;
130132
131133 // select to add new context folder
132- await waitForInputUpdate ( input , appMessage ) ;
133134 await input . selectQuickPick ( INPUTS . newFolderQuickPick ) ;
134135
135136 // select the context folder
136137 await input . setText ( contextFolder ) ;
137138 await input . confirm ( ) ;
138139
139- // provide component name
140- await waitForInputUpdate ( input , '' ) ;
141- await input . setText ( compName ) ;
142- await input . confirm ( ) ;
143-
144140 // select nodejs devfile template
145- await waitForInputProgress ( input , true ) ;
146- await waitForInputProgress ( input , false , 20000 ) ;
147141 await new Promise ( res => setTimeout ( res , 500 ) ) ;
148142 await input . setText ( COMPONENTS . nodejsDevfile ) ;
149143 await input . confirm ( ) ;
150144
151145 // select yes for starter project
152146 await new Promise ( res => setTimeout ( res , 500 ) ) ;
153147 await input . selectQuickPick ( INPUTS . yes ) ;
148+
149+ // provide component name
150+ await new Promise ( res => setTimeout ( res , 500 ) ) ;
151+ await input . setText ( compName ) ;
152+ await input . confirm ( ) ;
153+
154154 await new Promise ( res => setTimeout ( res , 5000 ) ) ;
155155 const project = await itemExists ( projectName , explorer ) as TreeItem ;
156156 await project . expand ( ) ;
157157
158- const app = await itemExists ( appName , explorer ) as TreeItem ;
159- await app . expand ( ) ;
160- await itemExists ( COMPONENTS . devfileComponent ( compName ) , explorer ) ;
158+ await itemExists ( compName , components , 30_000 ) ;
161159 } ) ;
162160
163- it ( 'Push the component' , async function ( ) {
164- this . timeout ( 150000 ) ;
165- const component = await itemExists ( COMPONENTS . devfileComponent ( compName ) , explorer ) ;
161+ it ( 'Start the component in dev mode' , async function ( ) {
162+ this . timeout ( 180000 ) ;
163+ const component = await itemExists ( compName , components , 30_000 ) ;
164+
166165 const menu = await component . openContextMenu ( ) ;
167- await menu . select ( MENUS . push ) ;
168- await terminalHasText ( COMPONENTS . pushSuccess , 120000 ) ;
166+ await menu . select ( MENUS . startDev ) ;
167+ await terminalHasText ( COMPONENTS . devStarted , 60_000 ) ;
168+
169+ const term = new TerminalView ( ) ;
170+ await term . killTerminal ( ) ;
171+
172+ // wait for component to stop running.
173+ // the component name changes to
174+ // `component-name (stopping)`
175+ // while `odo dev` is stopping
176+ // then it returns to
177+ // `component-name`
178+ // when `odo dev` has stopped
179+ await itemExists ( compName , components , 60_000 ) ;
169180 } ) ;
181+
170182 } ) ;
171- }
183+ }
0 commit comments