5
5
import * as fs from 'fs-extra' ;
6
6
import * as pth from 'path' ;
7
7
import { expect } from 'chai' ;
8
- import { ActivityBar , EditorView , InputBox , NotificationType , SideBarView , ViewSection , WelcomeContentButton , Workbench } from 'vscode-extension-tester' ;
8
+ import {
9
+ ActivityBar ,
10
+ EditorView ,
11
+ InputBox ,
12
+ NotificationType ,
13
+ SideBarView ,
14
+ ViewSection ,
15
+ WelcomeContentButton ,
16
+ Workbench ,
17
+ } from 'vscode-extension-tester' ;
9
18
import { VIEWS , BUTTONS } from '../common/constants' ;
10
- import { CreateComponentWebView , GitProjectPage , LocalCodeBasePage , SetNameAndFolderPage } from '../common/ui/webview/newComponentWebViewEditor' ;
11
- import { RegistryWebViewDevfileWindow , RegistryWebViewEditor } from '../common/ui/webview/registryWebViewEditor' ;
19
+ import {
20
+ CreateComponentWebView ,
21
+ GitProjectPage ,
22
+ LocalCodeBasePage ,
23
+ SetNameAndFolderPage ,
24
+ } from '../common/ui/webview/newComponentWebViewEditor' ;
25
+ import {
26
+ RegistryWebViewDevfileWindow ,
27
+ RegistryWebViewEditor ,
28
+ } from '../common/ui/webview/registryWebViewEditor' ;
12
29
import { afterEach } from 'mocha' ;
13
30
import { collapse } from '../common/overdrives' ;
14
31
15
32
//TODO: Add more checks for different elements
16
33
export function testCreateComponent ( path : string ) {
17
34
describe ( 'Create Component Wizard' , function ( ) {
18
-
19
35
let view : SideBarView ;
20
36
let section : ViewSection ;
21
- let button : WelcomeContentButton
22
- let componentName : string
37
+ let button : WelcomeContentButton ;
38
+ let componentName : string ;
23
39
let dlt = true ;
24
40
25
41
before ( async function context ( ) {
26
- this . timeout ( 10_000 )
42
+ this . timeout ( 10_000 ) ;
27
43
await new EditorView ( ) . closeAllEditors ( ) ;
28
44
fs . ensureDirSync ( path , 0o6777 ) ;
29
45
view = await ( await new ActivityBar ( ) . getViewControl ( VIEWS . openshift ) ) . openView ( ) ;
30
- for ( const item of [ VIEWS . appExplorer , VIEWS . compRegistries , VIEWS . serverlessFunctions , VIEWS . debugSessions ] ) {
31
- await collapse ( await view . getContent ( ) . getSection ( item ) )
46
+ for ( const item of [
47
+ VIEWS . appExplorer ,
48
+ VIEWS . compRegistries ,
49
+ VIEWS . serverlessFunctions ,
50
+ VIEWS . debugSessions ,
51
+ ] ) {
52
+ await collapse ( await view . getContent ( ) . getSection ( item ) ) ;
32
53
}
33
54
await loadCreateComponentButton ( ) ;
34
55
} ) ;
35
56
36
57
it ( 'Shows default actions when no component exists' , function test ( ) {
37
- if ( ! button ) {
38
- expect . fail ( 'No Create Component button found' )
58
+ if ( ! button ) {
59
+ expect . fail ( 'No Create Component button found' ) ;
39
60
}
40
61
} ) ;
41
62
@@ -51,20 +72,22 @@ export function testCreateComponent(path: string) {
51
72
await gitPage . initializeEditor ( ) ;
52
73
await gitPage . insertGitLink ( 'https://github.com/odo-devfiles/nodejs-ex' ) ;
53
74
await gitPage . clickNextButton ( ) ;
54
- await new Promise ( ( res ) => { setTimeout ( res , 1_500 ) } ) ;
75
+ await new Promise ( ( res ) => {
76
+ setTimeout ( res , 1_500 ) ;
77
+ } ) ;
55
78
await gitPage . clickContinueButton ( ) ;
56
79
57
- await createComponent ( createCompView )
80
+ await createComponent ( createCompView ) ;
58
81
59
82
componentName = 'node-js-runtime' ;
60
83
expect ( await section . findItem ( componentName ) ) . to . be . not . undefined ;
61
84
62
- dlt = false
85
+ dlt = false ;
63
86
} ) ;
64
87
65
88
it ( 'Create component from local folder' , async function test ( ) {
66
- this . timeout ( 25_000 )
67
- fs . rmSync ( pth . join ( path , componentName , 'devfile.yaml' ) , { force : true } ) ;
89
+ this . timeout ( 25_000 ) ;
90
+ fs . rmSync ( pth . join ( path , componentName , 'devfile.yaml' ) , { force : true } ) ;
68
91
await refreshView ( ) ;
69
92
await loadCreateComponentButton ( ) ;
70
93
await clickCreateComponent ( ) ;
@@ -74,20 +97,24 @@ export function testCreateComponent(path: string) {
74
97
75
98
const localCodeBasePage = new LocalCodeBasePage ( ) ;
76
99
await localCodeBasePage . initializeEditor ( ) ;
77
- await localCodeBasePage . insertComponentName ( componentName )
100
+ await localCodeBasePage . insertComponentName ( componentName ) ;
78
101
await localCodeBasePage . clickSelectFolderButton ( ) ;
79
102
80
103
const input = await InputBox . create ( ) ;
81
104
await input . setText ( pth . join ( path , componentName ) ) ;
82
105
await input . confirm ( ) ;
83
106
84
107
await localCodeBasePage . clickNextButton ( ) ;
85
- await new Promise ( ( res ) => { setTimeout ( res , 500 ) ; } ) ;
108
+ await new Promise ( ( res ) => {
109
+ setTimeout ( res , 500 ) ;
110
+ } ) ;
86
111
await localCodeBasePage . clickCreateComponent ( ) ;
87
- await new Promise ( ( res ) => { setTimeout ( res , 6_000 ) ; } ) ;
112
+ await new Promise ( ( res ) => {
113
+ setTimeout ( res , 6_000 ) ;
114
+ } ) ;
88
115
89
116
expect ( await section . findItem ( componentName ) ) . to . be . not . undefined ;
90
- dlt = true
117
+ dlt = true ;
91
118
} ) ;
92
119
93
120
it ( 'Create component from template project' , async function test ( ) {
@@ -104,35 +131,36 @@ export function testCreateComponent(path: string) {
104
131
const devfileView = new RegistryWebViewEditor ( createCompView . editorName ) ;
105
132
await devfileView . initializeEditor ( ) ;
106
133
await devfileView . selectRegistryStack ( 'Node.js Runtime' ) ;
107
- await new Promise ( ( res ) => { setTimeout ( res , 500 ) ; } ) ;
134
+ await new Promise ( ( res ) => {
135
+ setTimeout ( res , 500 ) ;
136
+ } ) ;
108
137
109
138
//Initialize stack window and click Use Devfile
110
139
const devFileWindow = new RegistryWebViewDevfileWindow ( createCompView . editorName ) ;
111
140
await devFileWindow . initializeEditor ( ) ;
112
141
await devFileWindow . useDevfile ( ) ;
113
142
114
143
//Initialize next page, fill out path and select create component
115
- await createComponent ( createCompView )
144
+ await createComponent ( createCompView ) ;
116
145
117
146
//check if component is in component view
118
147
componentName = 'nodejs-starter' ;
119
148
expect ( await section . findItem ( componentName ) ) . to . be . not . undefined ;
120
-
121
149
} ) ;
122
150
123
151
//Delete the component using file system
124
152
afterEach ( async function context ( ) {
125
- this . timeout ( 30_000 )
126
- if ( componentName && dlt ) {
127
- fs . rmSync ( pth . join ( path , componentName ) , { recursive : true , force : true } ) ;
153
+ this . timeout ( 30_000 ) ;
154
+ if ( componentName && dlt ) {
155
+ fs . rmSync ( pth . join ( path , componentName ) , { recursive : true , force : true } ) ;
128
156
componentName = undefined ;
129
157
await refreshView ( ) ;
130
158
await loadCreateComponentButton ( ) ;
131
159
}
132
160
await new EditorView ( ) . closeAllEditors ( ) ;
133
161
const notificationCenter = await new Workbench ( ) . openNotificationsCenter ( ) ;
134
162
const notifications = await notificationCenter . getNotifications ( NotificationType . Any ) ;
135
- if ( notifications . length > 0 ) {
163
+ if ( notifications . length > 0 ) {
136
164
await notificationCenter . close ( ) ;
137
165
}
138
166
} ) ;
@@ -143,11 +171,14 @@ export function testCreateComponent(path: string) {
143
171
await prompt . confirm ( ) ;
144
172
await prompt . setText ( 'node-js-runtime' ) ;
145
173
await prompt . confirm ( ) ;
174
+ await new Promise ( ( res ) => {
175
+ setTimeout ( res , 2_500 ) ;
176
+ } ) ;
146
177
prompt = await new Workbench ( ) . openCommandPrompt ( ) ;
147
178
await prompt . setText ( '>Workspaces: Remove Folder From Workspace...' ) ;
148
179
await prompt . confirm ( ) ;
149
180
await prompt . setText ( 'nodejs-starter' ) ;
150
- await prompt . confirm ( )
181
+ await prompt . confirm ( ) ;
151
182
} ) ;
152
183
153
184
async function createComponent ( createCompView : CreateComponentWebView ) : Promise < void > {
@@ -156,7 +187,9 @@ export function testCreateComponent(path: string) {
156
187
await page . clearProjectFolderPath ( ) ;
157
188
await page . insertProjectFolderPath ( path ) ;
158
189
await page . clickCreateComponentButton ( ) ;
159
- await new Promise ( ( res => { setTimeout ( res , 6_000 ) } ) )
190
+ await new Promise ( ( res ) => {
191
+ setTimeout ( res , 6_000 ) ;
192
+ } ) ;
160
193
}
161
194
162
195
async function initializeEditor ( ) : Promise < CreateComponentWebView > {
@@ -170,19 +203,23 @@ export function testCreateComponent(path: string) {
170
203
await section . expand ( ) ;
171
204
const refresh = await section . getAction ( 'Refresh Components View' ) ;
172
205
await refresh . click ( ) ;
173
- await new Promise ( ( res => { setTimeout ( res , 1_000 ) } ) ) ;
206
+ await new Promise ( ( res ) => {
207
+ setTimeout ( res , 1_000 ) ;
208
+ } ) ;
174
209
}
175
210
176
211
async function clickCreateComponent ( ) {
177
212
await button . click ( ) ;
178
- await new Promise ( ( res ) => { setTimeout ( res , 3_000 ) ; } ) ;
213
+ await new Promise ( ( res ) => {
214
+ setTimeout ( res , 3_000 ) ;
215
+ } ) ;
179
216
}
180
217
181
218
async function loadCreateComponentButton ( ) {
182
219
section = await view . getContent ( ) . getSection ( VIEWS . components ) ;
183
220
const buttons = await ( await section . findWelcomeContent ( ) ) . getButtons ( ) ;
184
- for ( const btn of buttons ) {
185
- if ( await btn . getTitle ( ) === BUTTONS . newComponent ) {
221
+ for ( const btn of buttons ) {
222
+ if ( ( await btn . getTitle ( ) ) === BUTTONS . newComponent ) {
186
223
button = btn ;
187
224
}
188
225
}
0 commit comments