@@ -30,12 +30,12 @@ import { join } from "path";
30
30
import {
31
31
BottomBarPanel , Condition , CustomTreeSection , EditorView , error , InputBox , ITimeouts ,
32
32
Key , OutputView , SideBarView , TreeItem , until , VSBrowser ,
33
- WebDriver , ModalDialog ,
33
+ WebDriver , ModalDialog , NotificationType ,
34
34
WebElement , Workbench , Button , Notification ,
35
35
} from "vscode-extension-tester" ;
36
36
import * as constants from "./constants" ;
37
37
import { keyboard , Key as nutKey } from "@nut-tree/nut-js" ;
38
- import * as Until from "./until" ;
38
+ import * as waitUntil from "./until" ;
39
39
import * as locator from "./locators" ;
40
40
import * as interfaces from "./interfaces" ;
41
41
export let driver : WebDriver ;
@@ -299,7 +299,7 @@ export class Misc {
299
299
} ;
300
300
301
301
const treeDBSection = await Misc . getSection ( constants . dbTreeSection ) ;
302
- await driver . wait ( Until . isNotLoading ( constants . dbTreeSection ) , constants . wait5seconds ) ;
302
+ await driver . wait ( waitUntil . isNotLoading ( constants . dbTreeSection ) , constants . wait5seconds ) ;
303
303
await treeDBSection . click ( ) ;
304
304
const moreActions = await treeDBSection . findElement ( locator . section . moreActions ) ;
305
305
await moreActions . click ( ) ;
@@ -437,12 +437,17 @@ export class Misc {
437
437
438
438
public static prepareExtensionLogsForExport = async ( testSuite : string ) : Promise < void > => {
439
439
const logPathFolder = await Misc . getExtentionOutputLogsFolder ( ) ;
440
- // rename the file
441
- await fs . rename ( join ( logPathFolder , constants . feLogFile ) ,
442
- join ( logPathFolder , `${ testSuite } _output_tab.log` ) ) ;
443
- // copy to workspace
444
- await fs . copyFile ( join ( logPathFolder , `${ testSuite } _output_tab.log` ) ,
445
- join ( constants . workspace , `${ testSuite } _output_tab.log` ) ) ;
440
+ try {
441
+ // rename the file
442
+ await fs . rename ( join ( logPathFolder , constants . feLogFile ) ,
443
+ join ( logPathFolder , `${ testSuite } _output_tab.log` ) ) ;
444
+ // copy to workspace
445
+ await fs . copyFile ( join ( logPathFolder , `${ testSuite } _output_tab.log` ) ,
446
+ join ( constants . workspace , `${ testSuite } _output_tab.log` ) ) ;
447
+ } catch ( e ) {
448
+ // continue
449
+ }
450
+
446
451
} ;
447
452
448
453
public static killRouterFromTerminal = ( ) : void => {
@@ -607,13 +612,22 @@ export class Misc {
607
612
} , constants . wait5seconds , "Could not switch back to top frame" ) ;
608
613
} ;
609
614
610
- public static getNotification = async ( text : string , dismiss = true ) : Promise < Notification > => {
615
+ public static getNotification = async ( text : string , dismiss = true ,
616
+ expectFailure = false ) : Promise < Notification > => {
611
617
let notif : Notification ;
618
+
619
+ await driver . wait ( waitUntil . notificationsExist ( ) , constants . wait5seconds ) ;
620
+
612
621
await driver . wait ( async ( ) => {
613
622
try {
614
623
const ntfs = await new Workbench ( ) . getNotifications ( ) ;
615
624
if ( ntfs . length > 0 ) {
616
625
for ( const ntf of ntfs ) {
626
+ if ( expectFailure === false ) {
627
+ if ( await ntf . getType ( ) === NotificationType . Error ) {
628
+ throw new Error ( "An error has occurred" ) ;
629
+ }
630
+ }
617
631
if ( ( await ntf . getMessage ( ) ) . includes ( text ) ) {
618
632
notif = ntf ;
619
633
if ( dismiss ) {
@@ -629,7 +643,7 @@ export class Misc {
629
643
throw e ;
630
644
}
631
645
}
632
- } , constants . wait10seconds , `Could not find '${ text } ' notification` ) ;
646
+ } , constants . wait2seconds , `Could not find '${ text } ' notification` ) ;
633
647
634
648
return notif ;
635
649
} ;
@@ -705,6 +719,17 @@ export class Misc {
705
719
} , timeout , `Could not find text '${ textToSearch [ 0 ] } ' on the terminal` ) ;
706
720
} ;
707
721
722
+ public static getRouterPort = async ( ) : Promise < string > => {
723
+ const routerConfigFilePath = Misc . getRouterConfigFile ( ) ;
724
+ const fileContent = ( await fs . readFile ( routerConfigFilePath ) ) . toString ( ) ;
725
+ const lines = fileContent . split ( "\n" ) ;
726
+ for ( let i = 0 ; i <= lines . length - 1 ; i ++ ) {
727
+ if ( lines [ i ] === "[http_server]" ) {
728
+ return lines [ i + 1 ] . match ( / p o r t = ( \d + ) / ) [ 1 ] ;
729
+ }
730
+ }
731
+ } ;
732
+
708
733
public static terminalHasErrors = async ( ) : Promise < boolean > => {
709
734
const out = await Misc . getTerminalOutput ( ) ;
710
735
@@ -764,7 +789,7 @@ export class Misc {
764
789
await inputBox . confirm ( ) ;
765
790
}
766
791
767
- if ( Until . credentialHelperOk ) {
792
+ if ( waitUntil . credentialHelperOk ) {
768
793
await driver . wait ( async ( ) => {
769
794
inputBox = await InputBox . create ( ) ;
770
795
if ( ( await inputBox . isPassword ( ) ) === false ) {
@@ -1070,15 +1095,15 @@ export class Misc {
1070
1095
}
1071
1096
1072
1097
const sectionTree = await Misc . getSection ( section ) ;
1073
- await driver . wait ( Until . isNotLoading ( section ) , constants . wait20seconds ) ;
1098
+ await driver . wait ( waitUntil . isNotLoading ( section ) , constants . wait20seconds ) ;
1074
1099
let reload = false ;
1075
1100
1076
1101
await driver . wait ( async ( ) => {
1077
1102
try {
1078
1103
if ( reload ) {
1079
1104
if ( section === constants . dbTreeSection || section === constants . ociTreeSection ) {
1080
1105
await Misc . clickSectionToolbarButton ( sectionTree , reloadLabel ) ;
1081
- await driver . wait ( Until . isNotLoading ( section ) , constants . wait20seconds ) ;
1106
+ await driver . wait ( waitUntil . isNotLoading ( section ) , constants . wait20seconds ) ;
1082
1107
}
1083
1108
}
1084
1109
if ( itemName instanceof RegExp ) {
@@ -1126,15 +1151,15 @@ export class Misc {
1126
1151
public static existsTreeElement = async ( section : string , itemName : string | RegExp ) : Promise < boolean > => {
1127
1152
let reloadLabel : string ;
1128
1153
const sectionTree = await Misc . getSection ( section ) ;
1129
- await driver . wait ( Until . isNotLoading ( section ) , constants . wait10seconds ) ;
1154
+ await driver . wait ( waitUntil . isNotLoading ( section ) , constants . wait10seconds ) ;
1130
1155
if ( section === constants . dbTreeSection || section === constants . ociTreeSection ) {
1131
1156
if ( section === constants . dbTreeSection ) {
1132
1157
reloadLabel = "Reload the connection list" ;
1133
1158
} else if ( section === constants . ociTreeSection ) {
1134
1159
reloadLabel = "Reload the OCI Profile list" ;
1135
1160
}
1136
1161
await Misc . clickSectionToolbarButton ( sectionTree , reloadLabel ) ;
1137
- await driver . wait ( Until . isNotLoading ( section ) , constants . wait20seconds ) ;
1162
+ await driver . wait ( waitUntil . isNotLoading ( section ) , constants . wait20seconds ) ;
1138
1163
}
1139
1164
1140
1165
if ( itemName instanceof RegExp ) {
@@ -1425,7 +1450,7 @@ export class Misc {
1425
1450
const treeItem = await Misc . getTreeElement ( section , item ) ;
1426
1451
if ( ! ( await treeItem . isExpanded ( ) ) ) {
1427
1452
await treeItem . expand ( ) ;
1428
- await driver . wait ( Until . isNotLoading ( section ) , loadingTimeout ) ;
1453
+ await driver . wait ( waitUntil . isNotLoading ( section ) , loadingTimeout ) ;
1429
1454
}
1430
1455
}
1431
1456
} ;
0 commit comments