@@ -89,7 +89,7 @@ describe("ngIf scenario", () => {
89
89
90
90
try {
91
91
await driverWrapper . findElementByText ( "Label" , SearchOptions . exact ) ;
92
- } catch ( e ) {
92
+ } catch ( e ) {
93
93
done ( ) ;
94
94
}
95
95
} ) ( ) ;
@@ -152,7 +152,7 @@ describe("ngIf scenario", () => {
152
152
153
153
try {
154
154
await driverWrapper . findElementByText ( "Else" , SearchOptions . exact ) ;
155
- } catch ( e ) {
155
+ } catch ( e ) {
156
156
done ( ) ;
157
157
}
158
158
} ) ( ) ;
@@ -215,7 +215,7 @@ describe("ngIf scenario", () => {
215
215
216
216
try {
217
217
await driverWrapper . findElementByText ( "Else" , SearchOptions . exact ) ;
218
- } catch ( e ) {
218
+ } catch ( e ) {
219
219
done ( ) ;
220
220
}
221
221
} ) ( ) ;
@@ -269,7 +269,7 @@ describe("ngIf scenario", () => {
269
269
. then ( _ => { throw new Error ( "Then template found!" ) ; } )
270
270
. catch ( ( ) => done ( ) ) ;
271
271
} ) ;
272
-
272
+
273
273
it ( "should swap the content when condition is changed" , done => {
274
274
( async ( ) => {
275
275
toggleButton = await toggleButton . refetch ( ) ;
@@ -278,10 +278,136 @@ describe("ngIf scenario", () => {
278
278
279
279
try {
280
280
await driverWrapper . findElementByText ( "Else" , SearchOptions . exact ) ;
281
- } catch ( e ) {
281
+ } catch ( e ) {
282
282
done ( ) ;
283
283
}
284
284
} ) ( ) ;
285
285
} ) ;
286
286
} ) ;
287
+
288
+ describe ( "subsequent ifs" , async ( ) => {
289
+ let firstButton : ExtendedUIElement ;
290
+ let secondButton : ExtendedUIElement ;
291
+ let firstLabel : ExtendedUIElement ;
292
+ let secondLabel : ExtendedUIElement ;
293
+
294
+ before ( async ( ) => {
295
+ driver = await createDriver ( ) ;
296
+ driverWrapper = new DriverWrapper ( driver ) ;
297
+ } ) ;
298
+
299
+ after ( async ( ) => {
300
+ await driver . quit ( ) ;
301
+ console . log ( "Driver quits!" ) ;
302
+ } ) ;
303
+
304
+ it ( "should navigate to page" , async ( ) => {
305
+ const navigationButton =
306
+ await driverWrapper . findElementByText ( "NgIf Subsequent Ifs" , SearchOptions . exact ) ;
307
+ await navigationButton . click ( ) ;
308
+ } ) ;
309
+
310
+ it ( "should find elements" , async ( ) => {
311
+ firstButton = await driverWrapper . findElementByText ( "Toggle first" , SearchOptions . exact ) ;
312
+ secondButton = await driverWrapper . findElementByText ( "Toggle second" , SearchOptions . exact ) ;
313
+
314
+ firstLabel = await driverWrapper . findElementByText ( "== 1 ==" , SearchOptions . exact ) ;
315
+ secondLabel = await driverWrapper . findElementByText ( "== 2 ==" , SearchOptions . exact ) ;
316
+
317
+ assert . isDefined ( firstButton ) ;
318
+ assert . isDefined ( secondButton ) ;
319
+ assert . isDefined ( firstLabel ) ;
320
+ assert . isDefined ( secondLabel ) ;
321
+ } ) ;
322
+
323
+ it ( "should toggle on first view" , async ( ) => {
324
+ await firstButton . click ( ) ;
325
+
326
+ let conditional = await driverWrapper . findElementByText ( "first" , SearchOptions . exact ) ;
327
+
328
+ await isAbove ( firstLabel , conditional ) ;
329
+ await isAbove ( conditional , secondLabel ) ;
330
+ } ) ;
331
+
332
+ it ( "should toggle off first view" , done => {
333
+ ( async ( ) => {
334
+ await firstButton . click ( ) ;
335
+
336
+ driverWrapper . findElementByText ( "first" , SearchOptions . exact , 500 )
337
+ . then ( _ => { throw new Error ( "first label found!" ) ; } )
338
+ . catch ( ( ) => done ( ) ) ;
339
+ } ) ( ) ;
340
+ } ) ;
341
+
342
+ it ( "should toggle on second view" , async ( ) => {
343
+ await secondButton . click ( ) ;
344
+
345
+ let conditional = await driverWrapper . findElementByText ( "second" , SearchOptions . exact ) ;
346
+ await isAbove ( firstLabel , conditional ) ;
347
+ await isAbove ( conditional , secondLabel ) ;
348
+ } ) ;
349
+
350
+ it ( "should toggle off second view" , done => {
351
+ ( async ( ) => {
352
+ await secondButton . click ( ) ;
353
+
354
+ driverWrapper . findElementByText ( "first" , SearchOptions . exact , 500 )
355
+ . then ( _ => { throw new Error ( "first label found!" ) ; } )
356
+ . catch ( ( ) => done ( ) ) ;
357
+ } ) ( ) ;
358
+ } ) ;
359
+
360
+ it ( "should toggle on both views" , async ( ) => {
361
+ await firstButton . click ( ) ;
362
+ await secondButton . click ( ) ;
363
+
364
+ let conditional1 = await driverWrapper . findElementByText ( "first" , SearchOptions . exact ) ;
365
+ let conditional2 = await driverWrapper . findElementByText ( "second" , SearchOptions . exact ) ;
366
+ await isAbove ( firstLabel , conditional1 ) ;
367
+ await isAbove ( conditional1 , conditional2 ) ;
368
+ await isAbove ( conditional2 , secondLabel ) ;
369
+ } ) ;
370
+
371
+ it ( "should toggle off both views" , done => {
372
+ ( async ( ) => {
373
+ await firstButton . click ( ) ;
374
+ await secondButton . click ( ) ;
375
+
376
+ driverWrapper . findElementByText ( "first" , SearchOptions . exact , 500 )
377
+ . then ( _ => { throw new Error ( "first label found!" ) ; } )
378
+ . catch ( ( ) => {
379
+ driverWrapper . findElementByText ( "second" , SearchOptions . exact , 500 )
380
+ . then ( _ => { throw new Error ( "second label found!" ) ; } )
381
+ . catch ( ( ) => done ( ) ) ;
382
+ } ) ;
383
+ } ) ( ) ;
384
+ } ) ;
385
+
386
+ it ( "should toggle on both views in reverse" , async ( ) => {
387
+ await secondButton . click ( ) ;
388
+ await firstButton . click ( ) ;
389
+
390
+ let conditional1 = await driverWrapper . findElementByText ( "first" , SearchOptions . exact ) ;
391
+ let conditional2 = await driverWrapper . findElementByText ( "second" , SearchOptions . exact ) ;
392
+ await isAbove ( firstLabel , conditional1 ) ;
393
+ await isAbove ( conditional1 , conditional2 ) ;
394
+ await isAbove ( conditional2 , secondLabel ) ;
395
+ } ) ;
396
+
397
+ it ( "should toggle off both views in reverse" , done => {
398
+ ( async ( ) => {
399
+ await secondButton . click ( ) ;
400
+ await firstButton . click ( ) ;
401
+
402
+ driverWrapper . findElementByText ( "first" , SearchOptions . exact , 500 )
403
+ . then ( _ => { throw new Error ( "first label found!" ) ; } )
404
+ . catch ( ( ) => {
405
+ driverWrapper . findElementByText ( "second" , SearchOptions . exact , 500 )
406
+ . then ( _ => { throw new Error ( "second label found!" ) ; } )
407
+ . catch ( ( ) => done ( ) ) ;
408
+ } ) ;
409
+ } ) ( ) ;
410
+ } ) ;
411
+ } ) ;
412
+
287
413
} ) ;
0 commit comments