@@ -41,6 +41,7 @@ function setInput(browser, input, type=true) {
41
41
} , [ input ] ) ;
42
42
browser . pause ( 100 ) ;
43
43
}
44
+ expectInput ( browser , input ) ;
44
45
}
45
46
46
47
/** @function
@@ -49,6 +50,11 @@ function setInput(browser, input, type=true) {
49
50
* @param {Browser } browser - Nightwatch client
50
51
*/
51
52
function bake ( browser ) {
53
+ browser
54
+ // Ensure we're not currently busy
55
+ . waitForElementNotVisible ( "#output-loader" , 5000 )
56
+ . expect . element ( "#bake span" ) . text . to . equal ( "BAKE!" ) ;
57
+
52
58
browser
53
59
. click ( "#bake" )
54
60
. waitForElementNotVisible ( "#stale-indicator" , 5000 )
@@ -162,7 +168,6 @@ function loadRecipe(browser, opName, input, args) {
162
168
throw new Error ( "Invalid operation type. Must be string or array of strings. Received: " + typeof ( opName ) ) ;
163
169
}
164
170
165
- clear ( browser ) ;
166
171
setInput ( browser , input , false ) ;
167
172
browser
168
173
. urlHash ( "recipe=" + recipeConfig )
@@ -174,8 +179,18 @@ function loadRecipe(browser, opName, input, args) {
174
179
*
175
180
* @param {Browser } browser - Nightwatch client
176
181
* @param {string|RegExp } expected - The expected output value
182
+ * @param {boolean } [waitNotNull=false] - Wait for the output to not be empty before testing the value
177
183
*/
178
- function expectOutput ( browser , expected ) {
184
+ function expectOutput ( browser , expected , waitNotNull = false ) {
185
+ if ( waitNotNull && expected !== "" ) {
186
+ browser . waitUntil ( async function ( ) {
187
+ const output = await this . execute ( function ( ) {
188
+ return window . app . manager . output . outputEditorView . state . doc . toString ( ) ;
189
+ } ) ;
190
+ return output . length ;
191
+ } , 1000 ) ;
192
+ }
193
+
179
194
browser . execute ( expected => {
180
195
return window . app . manager . output . outputEditorView . state . doc . toString ( ) ;
181
196
} , [ expected ] , function ( { value} ) {
@@ -187,6 +202,24 @@ function expectOutput(browser, expected) {
187
202
} ) ;
188
203
}
189
204
205
+ /** @function
206
+ * Tests whether the input matches a given value
207
+ *
208
+ * @param {Browser } browser - Nightwatch client
209
+ * @param {string|RegExp } expected - The expected input value
210
+ */
211
+ function expectInput ( browser , expected ) {
212
+ browser . execute ( expected => {
213
+ return window . app . manager . input . inputEditorView . state . doc . toString ( ) ;
214
+ } , [ expected ] , function ( { value} ) {
215
+ if ( expected instanceof RegExp ) {
216
+ browser . expect ( value ) . match ( expected ) ;
217
+ } else {
218
+ browser . expect ( value ) . to . be . equal ( expected ) ;
219
+ }
220
+ } ) ;
221
+ }
222
+
190
223
/** @function
191
224
* Uploads a file using the #open-file input
192
225
*
@@ -246,6 +279,7 @@ module.exports = {
246
279
paste : paste ,
247
280
loadRecipe : loadRecipe ,
248
281
expectOutput : expectOutput ,
282
+ expectInput : expectInput ,
249
283
uploadFile : uploadFile ,
250
284
uploadFolder : uploadFolder
251
285
} ;
0 commit comments