@@ -7,7 +7,7 @@ const MDSEnabled = Cypress.env('DATASOURCE_MANAGEMENT_ENABLED');
7
7
8
8
export const WorkspaceImportSampleDataTestCases = ( ) => {
9
9
if ( Cypress . env ( 'WORKSPACE_ENABLED' ) ) {
10
- describe ( 'import sample data to workspace ' , ( ) => {
10
+ describe ( 'workspace import sample data' , ( ) => {
11
11
let workspaceId ;
12
12
let dataSourceId ;
13
13
let dataSourceTitle ;
@@ -58,117 +58,96 @@ export const WorkspaceImportSampleDataTestCases = () => {
58
58
}
59
59
} ) ;
60
60
61
- beforeEach ( ( ) => {
62
- cy . visit ( `/w/${ workspaceId } /app/import_sample_data` ) ;
63
- if ( MDSEnabled ) {
64
- cy . selectTopRightNavigationDataSource ( dataSourceTitle , dataSourceId ) ;
65
- }
66
- } ) ;
67
-
68
- it ( 'should show Add data buttons if sample data not installed' , ( ) => {
69
- cy . getElementByTestId ( 'addSampleDataSetecommerce' ) . should ( 'be.visible' ) ;
70
- cy . getElementByTestId ( 'addSampleDataSetflights' ) . should ( 'be.visible' ) ;
71
- cy . getElementByTestId ( 'addSampleDataSetlogs' ) . should ( 'be.visible' ) ;
72
- } ) ;
73
-
74
- it ( 'should show remove buttons after sample data installed' , ( ) => {
75
- cy . getElementByTestId ( 'addSampleDataSetecommerce' ) . click ( ) ;
76
- cy . getElementByTestId ( 'addSampleDataSetflights' ) . click ( ) ;
77
- cy . getElementByTestId ( 'addSampleDataSetlogs' ) . click ( ) ;
78
-
79
- cy . getElementByTestId ( 'removeSampleDataSetecommerce' ) . should (
80
- 'be.visible'
81
- ) ;
82
- cy . getElementByTestId ( 'removeSampleDataSetflights' ) . should (
83
- 'be.visible'
84
- ) ;
85
- cy . getElementByTestId ( 'removeSampleDataSetlogs' ) . should ( 'be.visible' ) ;
86
-
87
- cy . getElementByTestId ( 'removeSampleDataSetecommerce' ) . click ( ) ;
88
- cy . getElementByTestId ( 'removeSampleDataSetflights' ) . click ( ) ;
89
- cy . getElementByTestId ( 'removeSampleDataSetlogs' ) . click ( ) ;
61
+ describe ( 'add and remove buttons' , ( ) => {
62
+ beforeEach ( ( ) => {
63
+ cy . visit ( `/w/${ workspaceId } /app/import_sample_data` ) ;
64
+ if ( MDSEnabled ) {
65
+ cy . selectTopRightNavigationDataSource (
66
+ dataSourceTitle ,
67
+ dataSourceId
68
+ ) ;
69
+ }
70
+ } ) ;
71
+
72
+ it ( 'should show Add data buttons if sample data not installed' , ( ) => {
73
+ cy . getElementByTestId ( 'addSampleDataSetecommerce' ) . should (
74
+ 'be.visible'
75
+ ) ;
76
+ cy . getElementByTestId ( 'addSampleDataSetflights' ) . should ( 'be.visible' ) ;
77
+ cy . getElementByTestId ( 'addSampleDataSetlogs' ) . should ( 'be.visible' ) ;
78
+ } ) ;
79
+
80
+ it ( 'should show remove buttons after sample data installed' , ( ) => {
81
+ cy . intercept (
82
+ {
83
+ pathname : '/w/**/api/sample_data/**' ,
84
+ times : 3 ,
85
+ } ,
86
+ {
87
+ statusCode : 200 ,
88
+ }
89
+ ) . as ( 'importSampleData' ) ;
90
+ cy . getElementByTestId ( 'addSampleDataSetecommerce' ) . click ( ) ;
91
+ cy . wait ( '@importSampleData' )
92
+ . its ( 'request.url' )
93
+ . should ( 'include' , 'ecommerce' ) ;
94
+
95
+ cy . getElementByTestId ( 'addSampleDataSetflights' ) . click ( ) ;
96
+ cy . wait ( '@importSampleData' )
97
+ . its ( 'request.url' )
98
+ . should ( 'include' , 'flights' ) ;
99
+
100
+ cy . getElementByTestId ( 'addSampleDataSetlogs' ) . click ( ) ;
101
+ cy . wait ( '@importSampleData' )
102
+ . its ( 'request.url' )
103
+ . should ( 'include' , 'logs' ) ;
104
+
105
+ cy . getElementByTestId ( 'removeSampleDataSetecommerce' ) . should (
106
+ 'be.visible'
107
+ ) ;
108
+ cy . getElementByTestId ( 'removeSampleDataSetflights' ) . should (
109
+ 'be.visible'
110
+ ) ;
111
+ cy . getElementByTestId ( 'removeSampleDataSetlogs' ) . should ( 'be.visible' ) ;
112
+ } ) ;
90
113
} ) ;
91
114
92
115
it ( 'should be able to visit ecommerce dashboard' , ( ) => {
93
- cy . getElementByTestId ( 'addSampleDataSetecommerce' ) . click ( ) ;
94
-
95
- cy . getElementByTestId ( 'launchSampleDataSetecommerce' )
96
- . should ( 'be.visible' )
97
- . click ( ) ;
98
-
99
- cy . location ( 'href' ) . should (
100
- 'include' ,
101
- `/w/${ workspaceId } /app/dashboards`
102
- ) ;
103
- cy . getElementByTestId ( 'headerAppActionMenu' ) . should (
104
- 'contain' ,
105
- getTitleWithDataSource ( '[eCommerce] Revenue Dashboard' )
106
- ) ;
107
- cy . get (
108
- `[data-title="${ getTitleWithDataSource (
109
- '[eCommerce] Total Revenue'
110
- ) } "]`
111
- ) . should ( 'not.contain' , 'No results found' ) ;
112
- cy . visit ( `/w/${ workspaceId } /app/import_sample_data` ) ;
113
-
114
- if ( MDSEnabled ) {
115
- cy . selectTopRightNavigationDataSource ( dataSourceTitle , dataSourceId ) ;
116
- }
117
- cy . getElementByTestId ( 'removeSampleDataSetecommerce' ) . click ( ) ;
118
- } ) ;
119
-
120
- it ( 'should be able to visit flights dashboards' , ( ) => {
121
- cy . getElementByTestId ( 'addSampleDataSetflights' ) . click ( ) ;
122
-
123
- cy . getElementByTestId ( 'launchSampleDataSetflights' )
124
- . should ( 'be.visible' )
125
- . click ( ) ;
126
-
127
- cy . location ( 'href' ) . should (
128
- 'include' ,
129
- `/w/${ workspaceId } /app/dashboards`
130
- ) ;
131
- cy . getElementByTestId ( 'headerAppActionMenu' ) . should (
132
- 'contain' ,
133
- getTitleWithDataSource ( '[Flights] Global Flight Dashboard' )
134
- ) ;
135
- cy . get (
136
- `[data-title="${ getTitleWithDataSource ( '[Flights] Flight Delays' ) } "]`
137
- ) . should ( 'not.contain' , 'No results found' ) ;
138
- cy . visit ( `/w/${ workspaceId } /app/import_sample_data` ) ;
139
-
140
- if ( MDSEnabled ) {
141
- cy . selectTopRightNavigationDataSource ( dataSourceTitle , dataSourceId ) ;
142
- }
143
- cy . getElementByTestId ( 'removeSampleDataSetflights' ) . click ( ) ;
144
- } ) ;
145
-
146
- it ( 'should be able to visit logs dashboards' , ( ) => {
147
- cy . getElementByTestId ( 'addSampleDataSetlogs' ) . click ( ) ;
148
-
149
- cy . getElementByTestId ( 'launchSampleDataSetlogs' )
150
- . should ( 'be.visible' )
151
- . click ( ) ;
152
-
153
- cy . location ( 'href' ) . should (
154
- 'include' ,
155
- `/w/${ workspaceId } /app/dashboards`
156
- ) ;
157
- cy . getElementByTestId ( 'headerAppActionMenu' ) . should (
158
- 'contain' ,
159
- getTitleWithDataSource ( '[Logs] Web Traffic' )
160
- ) ;
161
- cy . get (
162
- `[data-title="${ getTitleWithDataSource (
163
- '[Logs] Unique Visitors vs. Average Bytes'
164
- ) } "]`
165
- ) . should ( 'not.contain' , 'No results found' ) ;
166
- cy . visit ( `/w/${ workspaceId } /app/import_sample_data` ) ;
167
-
168
- if ( MDSEnabled ) {
169
- cy . selectTopRightNavigationDataSource ( dataSourceTitle , dataSourceId ) ;
170
- }
171
- cy . getElementByTestId ( 'removeSampleDataSetlogs' ) . click ( ) ;
116
+ cy . loadSampleDataForWorkspace ( 'ecommerce' , workspaceId , dataSourceId )
117
+ . then ( ( ) => {
118
+ cy . visit ( `/w/${ workspaceId } /app/import_sample_data` ) ;
119
+ if ( MDSEnabled ) {
120
+ cy . selectTopRightNavigationDataSource (
121
+ dataSourceTitle ,
122
+ dataSourceId
123
+ ) ;
124
+ }
125
+
126
+ cy . getElementByTestId ( 'launchSampleDataSetecommerce' )
127
+ . should ( 'be.visible' )
128
+ . click ( ) ;
129
+
130
+ cy . location ( 'href' ) . should (
131
+ 'include' ,
132
+ `/w/${ workspaceId } /app/dashboards`
133
+ ) ;
134
+ cy . getElementByTestId ( 'headerAppActionMenu' ) . should (
135
+ 'contain' ,
136
+ getTitleWithDataSource ( '[eCommerce] Revenue Dashboard' )
137
+ ) ;
138
+ cy . get (
139
+ `[data-title="${ getTitleWithDataSource (
140
+ '[eCommerce] Total Revenue'
141
+ ) } "]`
142
+ ) . should ( 'not.contain' , 'No results found' ) ;
143
+ } )
144
+ . then ( ( ) => {
145
+ cy . removeSampleDataForWorkspace (
146
+ 'ecommerce' ,
147
+ workspaceId ,
148
+ dataSourceId
149
+ ) ;
150
+ } ) ;
172
151
} ) ;
173
152
} ) ;
174
153
}
0 commit comments