@@ -96,40 +96,52 @@ export const WorkspaceCopyTestCases = () => {
96
96
97
97
if ( Cypress . env ( 'WORKSPACE_ENABLED' ) ) {
98
98
before ( ( ) => {
99
- cy . deleteWorkspaceByName ( sourceWorkspaceName ) ;
100
- cy . deleteWorkspaceByName ( targetWorkspaceName ) ;
99
+ cy . deleteAllWorkspaces ( ) ;
101
100
cy . createDataSourceNoAuth ( { title : dataSourceTitle1 } ) . then ( ( result ) => {
102
101
dataSourceId1 = result [ 0 ] ;
103
- cy . createWorkspace ( {
104
- name : sourceWorkspaceName ,
105
- features : [ 'use-case-observability' ] ,
106
- settings : {
107
- permissions : {
108
- library_write : { users : [ '%me%' ] } ,
109
- write : { users : [ '%me%' ] } ,
110
- } ,
111
- dataSources : [ dataSourceId1 ] ,
112
- } ,
113
- } ) . then ( ( value ) => {
114
- sourceWorkspaceId = value ;
115
- // Import ecommerce sample data to source workspace.
116
- cy . loadSampleDataForWorkspace (
117
- 'ecommerce' ,
118
- sourceWorkspaceId ,
119
- dataSourceId1
120
- ) ;
121
- } ) ;
122
102
} ) ;
123
103
cy . createDataSourceNoAuth ( { title : dataSourceTitle2 } ) . then ( ( result ) => {
124
104
dataSourceId2 = result [ 0 ] ;
125
105
} ) ;
106
+
107
+ cy . wrap ( null )
108
+ . should ( ( ) => {
109
+ expect ( dataSourceId1 ) . to . not . be . undefined ;
110
+ expect ( dataSourceId2 ) . to . not . be . undefined ;
111
+ } )
112
+ . then ( ( ) => {
113
+ cy . createWorkspace ( {
114
+ name : sourceWorkspaceName ,
115
+ features : [ 'use-case-observability' ] ,
116
+ settings : {
117
+ permissions : {
118
+ library_write : { users : [ '%me%' ] } ,
119
+ write : { users : [ '%me%' ] } ,
120
+ } ,
121
+ dataSources : [ dataSourceId1 , dataSourceId2 ] ,
122
+ } ,
123
+ } ) . then ( ( value ) => {
124
+ sourceWorkspaceId = value ;
125
+ // Import ecommerce sample data to dataSourceId1 of source workspace.
126
+ cy . loadSampleDataForWorkspace (
127
+ 'ecommerce' ,
128
+ sourceWorkspaceId ,
129
+ dataSourceId1
130
+ ) ;
131
+ } ) ;
132
+ } ) ;
126
133
} ) ;
127
134
128
135
after ( ( ) => {
129
- cy . deleteDataSource ( dataSourceId1 ) ;
130
- cy . deleteDataSource ( dataSourceId2 ) ;
131
- cy . deleteWorkspaceByName ( sourceWorkspaceName ) ;
132
- cy . deleteWorkspaceByName ( targetWorkspaceName ) ;
136
+ cy . wrap ( null ) . then ( ( ) => {
137
+ if ( dataSourceId1 ) {
138
+ cy . deleteDataSource ( dataSourceId1 ) ;
139
+ }
140
+ if ( dataSourceId2 ) {
141
+ cy . deleteDataSource ( dataSourceId2 ) ;
142
+ }
143
+ } ) ;
144
+ cy . deleteAllWorkspaces ( ) ;
133
145
} ) ;
134
146
135
147
beforeEach ( ( ) => {
@@ -199,6 +211,12 @@ export const WorkspaceCopyTestCases = () => {
199
211
200
212
describe ( 'Partial copy assets' , ( ) => {
201
213
before ( ( ) => {
214
+ // Import ecommerce sample data to dataSourceId2 of source workspace.
215
+ cy . loadSampleDataForWorkspace (
216
+ 'ecommerce' ,
217
+ sourceWorkspaceId ,
218
+ dataSourceId2
219
+ ) ;
202
220
createTargetWorkspace ( dataSourceId2 ) ;
203
221
miscUtils . visitPage ( `w/${ sourceWorkspaceId } /app/objects` ) ;
204
222
} ) ;
@@ -221,7 +239,7 @@ export const WorkspaceCopyTestCases = () => {
221
239
cy . wait ( '@copyAssetsRequest' ) . then ( ( interception ) => {
222
240
expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
223
241
expect ( interception . response . body . success ) . to . equal ( false ) ;
224
- expect ( interception . response . body . successCount ) . to . equal ( 1 ) ;
242
+ expect ( interception . response . body . successCount ) . to . equal ( 15 ) ;
225
243
} ) ;
226
244
227
245
cy . get ( '.euiFlyout' )
@@ -232,21 +250,21 @@ export const WorkspaceCopyTestCases = () => {
232
250
cy . contains (
233
251
`The following assets can not be copied, some of the data sources they use are not associated with ${ targetWorkspaceName } `
234
252
) ;
235
- cy . contains ( 'Copy remaining 1 asset' ) . should ( 'exist' ) . click ( ) ;
253
+ cy . contains ( 'Copy remaining 15 asset' ) . should ( 'exist' ) . click ( ) ;
236
254
} ) ;
237
255
238
256
// should successfully copy remaining assets from source workspace to target workspace
239
257
cy . wait ( '@copyAssetsRequest' ) . then ( ( interception ) => {
240
258
expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
241
259
expect ( interception . response . body . success ) . to . equal ( true ) ;
242
- expect ( interception . response . body . successCount ) . to . equal ( 1 ) ;
260
+ expect ( interception . response . body . successCount ) . to . equal ( 15 ) ;
243
261
} ) ;
244
262
cy . get ( '.euiFlyout' )
245
263
. should ( 'be.visible' )
246
264
. within ( ( ) => {
247
265
cy . contains ( 'Copy assets to ' + targetWorkspaceName ) ;
248
- cy . contains ( '1 asset copied' ) ;
249
- cy . contains ( '1 Successful' ) ;
266
+ cy . contains ( '15 assets copied' ) ;
267
+ cy . contains ( '15 Successful' ) ;
250
268
} ) ;
251
269
miscUtils . visitPage ( `w/${ targetWorkspaceId } /app/objects` ) ;
252
270
@@ -255,7 +273,7 @@ export const WorkspaceCopyTestCases = () => {
255
273
cy . getElementByTestId ( 'savedObjectsTable' )
256
274
. find ( 'tbody' )
257
275
. get ( '.euiTableRow' )
258
- . should ( 'have.length' , 1 ) ;
276
+ . should ( 'have.length' , 15 ) ;
259
277
} ) ;
260
278
} ) ;
261
279
}
0 commit comments