1
+ let _fs = require ( 'fs' ) ;
2
+
3
+ let deleteFolderRecursive = function ( path ) {
4
+ if ( _fs . existsSync ( path ) ) {
5
+ _fs . readdirSync ( path ) . forEach ( function ( file , index ) {
6
+ let curPath = path + "/" + file ;
7
+ console . log ( "Deleting: " + curPath ) ;
8
+
9
+ if ( _fs . lstatSync ( curPath ) . isDirectory ( ) ) { // recurse
10
+ deleteFolderRecursive ( curPath ) ;
11
+ } else { // delete file
12
+ _fs . unlinkSync ( curPath ) ;
13
+ }
14
+ } ) ;
15
+ _fs . rmdirSync ( path ) ;
16
+ }
17
+ } ;
18
+
19
+ module . exports = {
20
+
21
+
22
+ 'Signup user' : function ( client ) {
23
+
24
+ client . url ( 'http://localhost:8124/atompm' ) . pause ( 300 ) ;
25
+
26
+ client . execute (
27
+ function ( ) {
28
+ UserManagement . validateCredentials ( 'userremove' , 'test' ) ;
29
+ } , [ ] , null
30
+ ) ;
31
+
32
+ client . pause ( 500 ) ;
33
+
34
+ let user_exists = false ;
35
+ client . getText ( 'div[id=div_login_error]' , function ( result ) {
36
+ user_exists = result . value . includes ( 'login failed' ) ;
37
+
38
+ } ) ;
39
+
40
+ if ( user_exists == false ) {
41
+ client . execute (
42
+ function ( ) {
43
+ UserManagement . signup ( 'userremove' , 'test' ) ;
44
+ } , [ ] , null
45
+ ) ;
46
+
47
+ }
48
+
49
+ client . pause ( 500 ) ;
50
+
51
+ client . execute (
52
+ function ( ) {
53
+ UserManagement . login ( 'userremove' ) ;
54
+ } , [ ] , null
55
+ ) ;
56
+
57
+ client . pause ( 500 ) ;
58
+ client . getTitle ( function ( title ) {
59
+ this . assert . ok ( title . includes ( "AToMPM - [Unnamed]" ) , "AToMPM is opened" ) ;
60
+ } ) ;
61
+
62
+ } ,
63
+
64
+ 'Load Missing Toolbar' : function ( client ) {
65
+
66
+ let filename = './toolbars/missing.metamodel' ;
67
+ client . execute (
68
+ function ( ) {
69
+ DataUtils . loadbm ( './toolbars/missing.metamodel' ) ;
70
+ } , [ ] , null
71
+ ) ;
72
+
73
+ client . waitForElementPresent ( "#dialog_btn" , 2000 , "Check for toolbar loading error: " + filename ) ;
74
+ client . element ( 'css selector' , '#dialog_btn' , function ( result ) {
75
+ if ( result . status != - 1 ) {
76
+ //Dialog has popped up, so check the text and click the button
77
+ client . assert . containsText ( "#div_dialog_0" , "File not found" ) ;
78
+ client . click ( "#dialog_btn" ) ;
79
+
80
+ client . verify . ok ( true , "Toolbar: " + filename + " failed to load!" ) ; //don't stop testing
81
+ }
82
+ } ) ;
83
+
84
+ } ,
85
+
86
+ 'Load Missing Model' : function ( client ) {
87
+
88
+ let filename = './test/missing.model' ;
89
+ client . execute (
90
+ function ( ) {
91
+ DataUtils . loadm ( './test/missing.model' ) ;
92
+ } , [ ] , null
93
+ ) ;
94
+
95
+ client . waitForElementPresent ( "#dialog_btn" , 2000 , "Check for model loading error: " + filename ) ;
96
+ client . element ( 'css selector' , '#dialog_btn' , function ( result ) {
97
+ if ( result . status != - 1 ) {
98
+ //Dialog has popped up, so check the text and click the button
99
+ client . assert . containsText ( "#div_dialog_0" , "File cannot be read" ) ;
100
+ client . click ( "#dialog_btn" ) ;
101
+
102
+ client . verify . ok ( true , "Model: " + filename + " failed to load!" ) ; //don't stop testing
103
+ }
104
+ } ) ;
105
+
106
+ } ,
107
+
108
+ 'Delete and Click Toolbar' : function ( client ) {
109
+ client . pause ( 500 ) ;
110
+ deleteFolderRecursive ( "./users/userremove" ) ;
111
+
112
+ client . pause ( 1000 ) ;
113
+
114
+ let load_button = "#\\2f Toolbars\\2f MainMenu\\2f MainMenu\\2e buttons\\2e model\\2f loadModel" ;
115
+ client . waitForElementPresent ( load_button , 1000 , "Looking for load button" )
116
+ . click ( load_button )
117
+ . waitForElementPresent ( "#dialog_btn" , 1000 , "Load menu opens" ) ;
118
+
119
+
120
+ client . waitForElementPresent ( "#dialog_btn" , 2000 , "Check for file list loading error" ) ;
121
+ client . element ( 'css selector' , '#dialog_btn' , function ( result ) {
122
+ if ( result . status != - 1 ) {
123
+ //Dialog has popped up, so check the text and click the button
124
+ client . assert . containsText ( "#div_dialog_0" , "Cannot load file list" ) ;
125
+ client . click ( "#dialog_btn" ) ;
126
+
127
+ client . verify . ok ( true , "File list failed to load!" ) ; //don't stop testing
128
+ }
129
+ } ) ;
130
+ } ,
131
+
132
+ after : function ( client ) {
133
+ client . end ( ) ;
134
+ } ,
135
+ } ;
0 commit comments