@@ -265,7 +265,7 @@ Cypress.Commands.add( 'test_advanced_settings', ($create_new_chart) => {
265
265
} ) ;
266
266
267
267
// create the first N charts available
268
- Cypress . Commands . add ( 'create_available_charts' , ( $num ) => {
268
+ Cypress . Commands . add ( 'create_available_charts' , ( $num , $lib = '' ) => {
269
269
var charts = [ ] ;
270
270
for ( var i = 1 ; i <= parseInt ( $num ) ; i ++ ) {
271
271
charts . push ( i ) ;
@@ -283,10 +283,22 @@ Cypress.Commands.add( 'create_available_charts', ($num) => {
283
283
. then ( function ( $iframe ) {
284
284
const $body = $iframe . contents ( ) . find ( 'body' ) ;
285
285
286
- // select the chart.
287
- cy . wrap ( $body ) . find ( '#type-picker .type-box:nth-child(' + chart + ') .type-radio' ) . check ( ) ;
288
- // create the chart.
289
- cy . wrap ( $body ) . find ( '#toolbar input[type="submit"]' ) . click ( ) ;
286
+ cy . wrap ( $body ) . then ( function ( $body ) {
287
+ // if we are targeting a particular library, remove charts that do not support it
288
+ // like Google may support 2nd, 3rd and 10th charts - so we will remove all but these.
289
+ if ( '' !== $lib ) {
290
+ $body . find ( '#type-picker .type-box:not(.type-lib-' + $lib + ')' ) . remove ( ) ;
291
+ }
292
+ // select the chart.
293
+ cy . wrap ( $body ) . find ( '#type-picker .type-box:nth-child(' + chart + ') .type-radio' ) . check ( ) ;
294
+
295
+ // if we are targeting a particular library, then select it in the toolbar
296
+ if ( '' !== $lib ) {
297
+ cy . wrap ( $body ) . find ( '.viz-select-library' ) . select ( $lib ) ;
298
+ }
299
+ // create the chart.
300
+ cy . wrap ( $body ) . find ( '#toolbar input[type="submit"]' ) . click ( ) ;
301
+ } ) ;
290
302
} ) ;
291
303
292
304
cy . wait ( Cypress . env ( 'wait' ) ) ;
@@ -299,7 +311,6 @@ Cypress.Commands.add( 'create_available_charts', ($num) => {
299
311
} ) ;
300
312
301
313
cy . wait ( Cypress . env ( 'wait' ) ) ;
302
-
303
314
// verify that the chart was created and the count increased by 1
304
315
cy . visit ( Cypress . env ( 'urls' ) . library ) . then ( ( ) => {
305
316
cy . get ( '#visualizer-library .visualizer-chart' ) . should ( 'have.length' , chart ) ;
0 commit comments