33 * @param should Passed to should expression after plot points are captured
44 */
55export function assertPlotPreview ( should = "exist" ) {
6- cy . getByTestId ( "VisualizationPreview" )
7- . find ( "g.overplot" )
8- . should ( "exist" )
9- . find ( "g.points" )
10- . should ( should ) ;
6+ cy . getByTestId ( "VisualizationPreview" ) . find ( "g.overplot" ) . should ( "exist" ) . find ( "g.points" ) . should ( should ) ;
117}
128
139export function createChartThroughUI ( chartName , chartSpecificAssertionFn = ( ) => { } ) {
1410 cy . getByTestId ( "NewVisualization" ) . click ( ) ;
1511 cy . getByTestId ( "VisualizationType" ) . selectAntdOption ( "VisualizationType.CHART" ) ;
16- cy . getByTestId ( "VisualizationName" )
17- . clear ( )
18- . type ( chartName ) ;
12+ cy . getByTestId ( "VisualizationName" ) . clear ( ) . type ( chartName ) ;
1913
2014 chartSpecificAssertionFn ( ) ;
2115
2216 cy . server ( ) ;
2317 cy . route ( "POST" , "**/api/visualizations" ) . as ( "SaveVisualization" ) ;
2418
25- cy . getByTestId ( "EditVisualizationDialog" )
26- . contains ( "button" , "Save" )
27- . click ( ) ;
19+ cy . getByTestId ( "EditVisualizationDialog" ) . contains ( "button" , "Save" ) . click ( ) ;
2820
29- cy . getByTestId ( "QueryPageVisualizationTabs" )
30- . contains ( "span" , chartName )
31- . should ( "exist" ) ;
21+ cy . getByTestId ( "QueryPageVisualizationTabs" ) . contains ( "span" , chartName ) . should ( "exist" ) ;
3222
3323 cy . wait ( "@SaveVisualization" ) . should ( "have.property" , "status" , 200 ) ;
3424
35- return cy . get ( "@SaveVisualization" ) . then ( xhr => {
25+ return cy . get ( "@SaveVisualization" ) . then ( ( xhr ) => {
3626 const { id, name, options } = xhr . response . body ;
3727 return cy . wrap ( { id, name, options } ) ;
3828 } ) ;
@@ -42,19 +32,13 @@ export function assertTabbedEditor(chartSpecificTabbedEditorAssertionFn = () =>
4232 cy . getByTestId ( "Chart.GlobalSeriesType" ) . should ( "exist" ) ;
4333
4434 cy . getByTestId ( "VisualizationEditor.Tabs.Series" ) . click ( ) ;
45- cy . getByTestId ( "VisualizationEditor" )
46- . find ( "table" )
47- . should ( "exist" ) ;
35+ cy . getByTestId ( "VisualizationEditor" ) . find ( "table" ) . should ( "exist" ) ;
4836
4937 cy . getByTestId ( "VisualizationEditor.Tabs.Colors" ) . click ( ) ;
50- cy . getByTestId ( "VisualizationEditor" )
51- . find ( "table" )
52- . should ( "exist" ) ;
38+ cy . getByTestId ( "VisualizationEditor" ) . find ( "table" ) . should ( "exist" ) ;
5339
5440 cy . getByTestId ( "VisualizationEditor.Tabs.DataLabels" ) . click ( ) ;
55- cy . getByTestId ( "VisualizationEditor" )
56- . getByTestId ( "Chart.DataLabels.ShowDataLabels" )
57- . should ( "exist" ) ;
41+ cy . getByTestId ( "VisualizationEditor" ) . getByTestId ( "Chart.DataLabels.ShowDataLabels" ) . should ( "exist" ) ;
5842
5943 chartSpecificTabbedEditorAssertionFn ( ) ;
6044
@@ -63,39 +47,29 @@ export function assertTabbedEditor(chartSpecificTabbedEditorAssertionFn = () =>
6347
6448export function assertAxesAndAddLabels ( xaxisLabel , yaxisLabel ) {
6549 cy . getByTestId ( "VisualizationEditor.Tabs.XAxis" ) . click ( ) ;
66- cy . getByTestId ( "Chart.XAxis.Type" )
67- . contains ( ".ant-select-selection-item" , "Auto Detect" )
68- . should ( "exist" ) ;
50+ cy . getByTestId ( "Chart.XAxis.Type" ) . contains ( ".ant-select-selection-item" , "Auto Detect" ) . should ( "exist" ) ;
6951
70- cy . getByTestId ( "Chart.XAxis.Name" )
71- . clear ( )
72- . type ( xaxisLabel ) ;
52+ cy . getByTestId ( "Chart.XAxis.Name" ) . clear ( ) . type ( xaxisLabel ) ;
7353
7454 cy . getByTestId ( "VisualizationEditor.Tabs.YAxis" ) . click ( ) ;
75- cy . getByTestId ( "Chart.LeftYAxis.Type" )
76- . contains ( ".ant-select-selection-item" , "Linear" )
77- . should ( "exist" ) ;
55+ cy . getByTestId ( "Chart.LeftYAxis.Type" ) . contains ( ".ant-select-selection-item" , "Linear" ) . should ( "exist" ) ;
7856
79- cy . getByTestId ( "Chart.LeftYAxis.Name" )
80- . clear ( )
81- . type ( yaxisLabel ) ;
57+ cy . getByTestId ( "Chart.LeftYAxis.Name" ) . clear ( ) . type ( yaxisLabel ) ;
8258
83- cy . getByTestId ( "Chart.LeftYAxis.TickFormat" )
84- . clear ( )
85- . type ( "+" ) ;
59+ cy . getByTestId ( "Chart.LeftYAxis.TickFormat" ) . clear ( ) . type ( "+" ) ;
8660
8761 cy . getByTestId ( "VisualizationEditor.Tabs.General" ) . click ( ) ;
8862}
8963
9064export function createDashboardWithCharts ( title , chartGetters , widgetsAssertionFn = ( ) => { } ) {
91- cy . createDashboard ( title ) . then ( dashboard => {
65+ cy . createDashboard ( title ) . then ( ( dashboard ) => {
9266 const dashboardUrl = `/dashboards/${ dashboard . id } ` ;
93- const widgetGetters = chartGetters . map ( chartGetter => `${ chartGetter } Widget` ) ;
67+ const widgetGetters = chartGetters . map ( ( chartGetter ) => `${ chartGetter } Widget` ) ;
9468
9569 chartGetters . forEach ( ( chartGetter , i ) => {
9670 const position = { autoHeight : false , sizeY : 8 , sizeX : 3 , col : ( i % 2 ) * 3 } ;
9771 cy . get ( `@${ chartGetter } ` )
98- . then ( chart => cy . addWidget ( dashboard . id , chart . id , { position } ) )
72+ . then ( ( chart ) => cy . addWidget ( dashboard . id , chart . id , { position } ) )
9973 . as ( widgetGetters [ i ] ) ;
10074 } ) ;
10175
0 commit comments