1414import java .util .HashMap ;
1515import java .util .List ;
1616import java .util .Map ;
17+ import java .util .Optional ;
1718
1819import static org .labkey .test .components .html .Input .Input ;
1920
@@ -44,6 +45,44 @@ public String getName()
4445 return elementCache ().nameInput .get ();
4546 }
4647
48+ public QueryChartDialog setTitle (String value ) {
49+ elementCache ().titleInput .set (value );
50+ elementCache ().title .click (); // blur the element
51+ return this ;
52+ }
53+
54+ public QueryChartDialog setSubtitle (String value )
55+ {
56+ elementCache ().subtitleInput .set (value );
57+ elementCache ().title .click (); // blur the element
58+ return this ;
59+ }
60+
61+ public QueryChartDialog setHeight (String value )
62+ {
63+ elementCache ().heightInput .set (value );
64+ elementCache ().title .click (); // blur the element
65+ return this ;
66+ }
67+
68+ public QueryChartDialog setWidth (String value )
69+ {
70+ elementCache ().widthInput .set (value );
71+ elementCache ().title .click (); // blur the element
72+ return this ;
73+ }
74+
75+ public QueryChartDialog setUseFullWidth (boolean checked )
76+ {
77+ elementCache ().fullWidthCheckbox .set (checked );
78+ return this ;
79+ }
80+
81+ public boolean getUseFullWidth ()
82+ {
83+ return elementCache ().sharedCheckbox .get ();
84+ }
85+
4786 public QueryChartDialog setShared (boolean checked )
4887 {
4988 elementCache ().sharedCheckbox .set (checked );
@@ -131,6 +170,12 @@ public boolean isAxisScaleTypeSelected(String label, String value)
131170 return selected ;
132171 }
133172
173+ public boolean isAxisScaleTypeAvailable (String label )
174+ {
175+ clickFieldOptions (label );
176+ return elementCache ().radioGroupWithLabel ("Scale" ).isPresent ();
177+ }
178+
134179 /**
135180 * Set the axis range to 'automatic' or 'manual' for the given axis
136181 * @param label the axis label
@@ -259,6 +304,22 @@ public boolean isYAxisErrorBarOptionEnabled(String value)
259304 return enabled ;
260305 }
261306
307+ public QueryChartDialog setXAxisLabel (String value )
308+ {
309+ clickFieldOptions ("X Axis" );
310+ elementCache ().xLabelInput .set (value );
311+ Locator .tagWithText ("label" , "Name *" ).findElement (this ).click (); // close the popover
312+ return this ;
313+ }
314+
315+ public QueryChartDialog setYAxisLabel (String value )
316+ {
317+ clickFieldOptions ("Y Axis" );
318+ elementCache ().yLabelInput .set (value );
319+ Locator .tagWithText ("label" , "Name *" ).findElement (this ).click (); // close the popover
320+ return this ;
321+ }
322+
262323 /*
263324 groupBy is an option for bar charts only
264325 */
@@ -401,10 +462,10 @@ public QueryChartDialog setChartType(CHART_TYPE chartType)
401462 if (getSelectedChartType ().equals (chartType ))
402463 return this ;
403464
404- var el = elementCache ().chartBuilderType . withAttribute ( "data-name" , chartType . getChartType ())
405- . waitForElement ( this , 1500 );
406- getWrapper (). shortWait (). until ( ExpectedConditions . elementToBeClickable ( el ));
407- el . click ( );
465+ var chartTypeDropdown = elementCache ().reactSelectByLabel ( "Chart Type" );
466+ // ChartTypeDropdown component uses a custom option renderer
467+ chartTypeDropdown . setOptionLocator (( String type ) -> Locator . byClass ( "chart-builder-type-option" ). withAttribute ( "data-chart-type" , type ));
468+ chartTypeDropdown . select ( chartType . getChartType () );
408469 WebDriverWrapper .waitFor (()-> getSelectedChartType ().equals (chartType ),
409470 "The requested chart type did not become selected" , 2000 );
410471
@@ -413,10 +474,11 @@ public QueryChartDialog setChartType(CHART_TYPE chartType)
413474
414475 public CHART_TYPE getSelectedChartType ()
415476 {
416- var selectedEl = elementCache ().chartBuilderType .withAttributeContaining ("class" , "selected" )
417- .waitForElement (this , 1500 );
418- String dataName = selectedEl .getAttribute ("data-name" );
419- return CHART_TYPE .fromChartType (dataName );
477+ var chartTypeDropdown = elementCache ().reactSelectByLabel ("Chart Type" );
478+ // The ChartTypeDropdown component has a custom value renderer, so we need to find that manually because
479+ // chartTypeDropdown.getValue will throw an exception
480+ WebElement selectedOption = Locator .byClass ("chart-builder-type-option--value" ).findElement (chartTypeDropdown );
481+ return CHART_TYPE .fromChartType (selectedOption .getAttribute ("data-chart-type" ));
420482 }
421483
422484 public boolean isPreviewPresent ()
@@ -529,11 +591,16 @@ protected ElementCache elementCache()
529591
530592 protected class ElementCache extends ModalDialog .ElementCache
531593 {
532- final Input nameInput = Input (Locator .input ("name" ), getDriver ()).findWhenNeeded (this );
533- final Checkbox sharedCheckbox = Checkbox .Checkbox (Locator .input ("shared" )).findWhenNeeded (this );
534- final Checkbox inheritableCheckbox = Checkbox .Checkbox (Locator .input ("inheritable" )).findWhenNeeded (this );
535-
536- Locator .XPathLocator chartBuilderType = Locator .tagWithClass ("div" , "chart-builder-type" );
594+ Locator .XPathLocator settingsPanelLoc = Locator .byClass ("chart-settings" );
595+ final WebElement settingsPanel = settingsPanelLoc .findWhenNeeded (this );
596+ final Input nameInput = Input (Locator .input ("name" ), getDriver ()).findWhenNeeded (settingsPanel );
597+ final Input titleInput = Input (Locator .input ("main-label" ), getDriver ()).findWhenNeeded (settingsPanel );
598+ final Input subtitleInput = Input (Locator .input ("subtitle-label" ), getDriver ()).findWhenNeeded (settingsPanel );
599+ final Input heightInput = Input (Locator .input ("height" ), getDriver ()).findWhenNeeded (settingsPanel );
600+ final Input widthInput = Input (Locator .input ("width" ), getDriver ()).findWhenNeeded (settingsPanel );
601+ final Checkbox sharedCheckbox = Checkbox .Checkbox (Locator .input ("shared" )).findWhenNeeded (settingsPanel );
602+ final Checkbox inheritableCheckbox = Checkbox .Checkbox (Locator .input ("inheritable" )).findWhenNeeded (settingsPanel );
603+ final Checkbox fullWidthCheckbox = Checkbox .Checkbox (Locator .input ("use-full-width" )).findWhenNeeded (settingsPanel );
537604
538605 public ReactSelect reactSelectByLabel (String label )
539606 {
@@ -543,18 +610,18 @@ public ReactSelect reactSelectByLabel(String label)
543610 public ReactSelect reactSelectByLabel (String label , boolean allowNull )
544611 {
545612 Locator loc = Locator .tag ("div" ).withChild (Locator .tagContainingText ("label" , label ));
546- if (allowNull && loc .findElementOrNull (this ) == null )
613+ if (allowNull && loc .findElementOrNull (settingsPanel ) == null )
547614 return null ;
548615 else
549- return ReactSelect .finder (getDriver ()).find (loc .waitForElement (this , 1500 ));
616+ return ReactSelect .finder (getDriver ()).find (loc .waitForElement (settingsPanel , 1500 ));
550617 }
551618
552619 public WebElement fieldOptionIconByLabel (String label )
553620 {
554621 Locator loc = Locator .tag ("div" ).withChild (Locator .tagContainingText ("label" , label ));
555622 return Locator .tagWithClass ("div" , "field-option-icon" ).descendant ("span" ).findElementOrNull (loc .findElement (this ));
556623 }
557- private final Locator .XPathLocator previewContainerLoc = Locator .tag ("div" ).withChild (Locator .tagWithText ("label " , "Preview" ));
624+ private final Locator .XPathLocator previewContainerLoc = Locator .tag ("div" ).withChild (Locator .tagWithText ("h4 " , "Preview" ));
558625 public WebElement previewContainer ()
559626 {
560627 return previewContainerLoc .waitForElement (this , 1500 );
@@ -580,6 +647,16 @@ public WebElement svg()
580647 public RadioButton scaleManualRadio = RadioButton .RadioButton (Locator .radioButtonByNameAndValue ("scaleType" , "manual" )).refindWhenNeeded (fieldOptionPopover );
581648 public Input scaleRangeMinInput = Input (Locator .input ("scaleMin" ), getDriver ()).refindWhenNeeded (fieldOptionPopover );
582649 public Input scaleRangeMaxInput = Input (Locator .input ("scaleMax" ), getDriver ()).refindWhenNeeded (fieldOptionPopover );
650+ public Input yLabelInput = Input (Locator .input ("y-label" ), getDriver ()).refindWhenNeeded (fieldOptionPopover );
651+ public Input xLabelInput = Input (Locator .input ("x-label" ), getDriver ()).refindWhenNeeded (fieldOptionPopover );
652+
653+ final Locator .XPathLocator radioGroupLoc = Locator .byClass ("field-option-radio-group" );
654+
655+ public Optional <WebElement > radioGroupWithLabel (String label )
656+ {
657+ Locator .XPathLocator labelLoc = Locator .tagWithText ("label" , label );
658+ return radioGroupLoc .withChild (labelLoc ).findOptionalElement (fieldOptionPopover );
659+ }
583660 }
584661
585662 public enum CHART_TYPE {
0 commit comments