@@ -25,19 +25,33 @@ export class Extensions {
2525 const searchBoxSelector = `${ this . extensionsViewletSelector } .search-box` ;
2626
2727 await this . spectron . client . clearElement ( searchBoxSelector ) ;
28- await this . spectron . client . click ( searchBoxSelector , false ) ;
28+ try {
29+ await this . spectron . client . click ( searchBoxSelector , false ) ;
30+ } catch ( e ) {
31+ return Promise . reject ( 'Failed to click on search box in extensions viewlet.' ) ;
32+ }
2933 await this . spectron . client . keys ( name ) ;
34+
3035 return this . spectron . client . keys ( [ 'NULL' , 'Enter' , 'NULL' ] ) ;
3136 }
3237
3338 public async installExtension ( name : string ) : Promise < any > {
3439 const extensionListSelector = `${ this . extensionsViewletSelector } .monaco-list-rows` ;
3540 this . viewletExtensionIndex = await this . getExtensionIndex ( name , extensionListSelector ) ;
36- return this . spectron . client . click ( `${ extensionListSelector } >:nth-child(${ this . viewletExtensionIndex } ) .extension .extension-action.install` ) ;
41+
42+ try {
43+ return this . spectron . client . click ( `${ extensionListSelector } >:nth-child(${ this . viewletExtensionIndex } ) .extension .extension-action.install` ) ;
44+ } catch ( e ) {
45+ return Promise . reject ( 'Failed to click on install button for selected extension.' ) ;
46+ }
3747 }
3848
3949 public getExtensionReloadText ( ) : Promise < any > {
40- return this . spectron . waitFor ( this . spectron . client . getText , `${ this . extensionsViewletSelector } .monaco-list-rows>:nth-child(${ this . viewletExtensionIndex } ) .extension .extension-action.reload` ) ;
50+ try {
51+ return this . spectron . waitFor ( this . spectron . client . getText , `${ this . extensionsViewletSelector } .monaco-list-rows>:nth-child(${ this . viewletExtensionIndex } ) .extension .extension-action.reload` ) ;
52+ } catch ( e ) {
53+ return Promise . reject ( 'Reload was not prompted for an installed extension.' ) ;
54+ }
4155 }
4256
4357 public async selectMinimalIconsTheme ( ) : Promise < any > {
@@ -49,23 +63,27 @@ export class Extensions {
4963 }
5064
5165 public async verifyFolderIconAppearance ( ) : Promise < any > {
52- return this . spectron . waitFor ( this . spectron . client . getHTML , 'style[class="contributedIconTheme"]' ) ;
66+ try {
67+ return this . spectron . waitFor ( this . spectron . client . getHTML , 'style[class="contributedIconTheme"]' ) ;
68+ } catch ( e ) {
69+ return Promise . reject ( 'Failed to validate extension contribution.' ) ;
70+ }
5371 }
5472
5573 private getExtensionIndex ( name : string , extensionListSelector : string ) : Promise < number > {
5674 return new Promise ( async ( res , rej ) => {
5775 const html = await this . spectron . waitFor ( this . spectron . client . getHTML , extensionListSelector ) ;
5876 let extensionIndex : number = 0 ;
5977 let extension : boolean ;
60- var domelems : string [ ] = [ ] ;
61- var parser = new htmlparser . Parser ( {
78+ let tags : string [ ] = [ ] ;
79+ let parser = new htmlparser . Parser ( {
6280 onopentag : function ( name , attribs ) {
6381 if ( name === 'div' && attribs . class === 'extension' ) {
6482 extensionIndex ++ ;
6583 extension = true ;
6684 }
6785 if ( extension ) {
68- domelems . push ( name ) ;
86+ tags . push ( name ) ;
6987 }
7088 } ,
7189 ontext : function ( text ) {
@@ -75,17 +93,17 @@ export class Extensions {
7593 } ,
7694 onclosetag : function ( name ) {
7795 if ( extension ) {
78- domelems . pop ( ) ;
96+ tags . pop ( ) ;
7997 }
80- if ( extension && domelems . length === 0 ) {
98+ if ( extension && tags . length === 0 ) {
8199 extension = false ;
82100 }
83101 } ,
84102 onend : function ( ) {
85103 if ( extensionIndex === 0 ) {
86- rej ( `${ name } extension was not found.` ) ;
104+ return rej ( `${ name } extension was not found.` ) ;
87105 }
88- res ( extensionIndex ) ;
106+ return res ( extensionIndex ) ;
89107 }
90108 } ) ;
91109 parser . write ( html ) ;
0 commit comments