@@ -18,6 +18,20 @@ export const WorkspaceDetailTestCases = () => {
18
18
let workspaceDescription = 'This is a workspace description.' ;
19
19
let workspaceId ;
20
20
let workspaceFeatures = [ 'use-case-observability' ] ;
21
+ const workspaceBaseData = {
22
+ name : workspaceName ,
23
+ description : workspaceDescription ,
24
+ features : workspaceFeatures ,
25
+ color : '#54B399' ,
26
+ settings : {
27
+ permissions : {
28
+ library_write : { users : [ '%me%' ] } ,
29
+ write : { users : [ '%me%' ] } ,
30
+ library_read : { users : [ NONE_DASHBOARDS_ADMIN_USERNAME ] } ,
31
+ read : { users : [ NONE_DASHBOARDS_ADMIN_USERNAME ] } ,
32
+ } ,
33
+ } ,
34
+ } ;
21
35
22
36
if ( Cypress . env ( 'WORKSPACE_ENABLED' ) ) {
23
37
describe ( 'Workspace detail' , ( ) => {
@@ -34,19 +48,9 @@ export const WorkspaceDetailTestCases = () => {
34
48
) ;
35
49
}
36
50
cy . deleteWorkspaceByName ( workspaceName ) ;
37
- cy . createWorkspace ( {
38
- name : workspaceName ,
39
- description : workspaceDescription ,
40
- features : workspaceFeatures ,
41
- settings : {
42
- permissions : {
43
- library_write : { users : [ '%me%' ] } ,
44
- write : { users : [ '%me%' ] } ,
45
- library_read : { users : [ NONE_DASHBOARDS_ADMIN_USERNAME ] } ,
46
- read : { users : [ NONE_DASHBOARDS_ADMIN_USERNAME ] } ,
47
- } ,
48
- } ,
49
- } ) . then ( ( value ) => ( workspaceId = value ) ) ;
51
+ cy . createWorkspace ( workspaceBaseData ) . then (
52
+ ( value ) => ( workspaceId = value )
53
+ ) ;
50
54
} ) ;
51
55
52
56
after ( ( ) => {
@@ -294,6 +298,106 @@ export const WorkspaceDetailTestCases = () => {
294
298
} ) ;
295
299
} ) ;
296
300
} ) ;
301
+
302
+ describe ( 'update with different privacy settings' , ( ) => {
303
+ before ( ( ) => {
304
+ // Visit workspace update page
305
+ miscUtils . visitPage ( `w/${ workspaceId } /app/workspace_detail` ) ;
306
+ } ) ;
307
+
308
+ afterEach ( ( ) => {
309
+ cy . getElementByTestId (
310
+ 'workspaceForm-workspaceDetails-edit'
311
+ ) . click ( ) ;
312
+ cy . getElementByTestId ( 'workspacePrivacySettingSelector' ) . click ( {
313
+ force : true ,
314
+ } ) ;
315
+ cy . get ( '#private-to-collaborators' ) . click ( { force : true } ) ;
316
+ cy . getElementByTestId ( 'workspaceForm-bottomBar-updateButton' ) . click (
317
+ { force : true }
318
+ ) ;
319
+ cy . getElementByTestId (
320
+ 'workspaceForm-bottomBar-updateButton'
321
+ ) . should ( 'not.exist' ) ;
322
+ cy . checkWorkspace ( workspaceId , {
323
+ name : workspaceName ,
324
+ description : workspaceDescription ,
325
+ features : workspaceFeatures ,
326
+ permissions : {
327
+ library_write : { users : [ '%me%' ] } ,
328
+ write : { users : [ '%me%' ] } ,
329
+ library_read : {
330
+ users : [ NONE_DASHBOARDS_ADMIN_USERNAME ] ,
331
+ } ,
332
+ read : { users : [ NONE_DASHBOARDS_ADMIN_USERNAME ] } ,
333
+ } ,
334
+ } ) ;
335
+ } ) ;
336
+
337
+ it ( 'should able to update privacy setting to anyone can read' , ( ) => {
338
+ cy . getElementByTestId (
339
+ 'workspaceForm-workspaceDetails-edit'
340
+ ) . click ( ) ;
341
+ cy . getElementByTestId ( 'workspacePrivacySettingSelector' ) . click ( {
342
+ force : true ,
343
+ } ) ;
344
+ cy . get ( '#anyone-can-view' ) . click ( { force : true } ) ;
345
+ cy . getElementByTestId ( 'workspaceForm-bottomBar-updateButton' ) . click (
346
+ { force : true }
347
+ ) ;
348
+
349
+ cy . getElementByTestId (
350
+ 'workspaceForm-bottomBar-updateButton'
351
+ ) . should ( 'not.exist' ) ;
352
+
353
+ const expectedWorkspace = {
354
+ name : workspaceName ,
355
+ description : workspaceDescription ,
356
+ features : workspaceFeatures ,
357
+ permissions : {
358
+ library_write : { users : [ '%me%' ] } ,
359
+ write : { users : [ '%me%' ] } ,
360
+ library_read : {
361
+ users : [ NONE_DASHBOARDS_ADMIN_USERNAME , '*' ] ,
362
+ } ,
363
+ read : { users : [ NONE_DASHBOARDS_ADMIN_USERNAME , '*' ] } ,
364
+ } ,
365
+ } ;
366
+ cy . checkWorkspace ( workspaceId , expectedWorkspace ) ;
367
+ } ) ;
368
+
369
+ it ( 'should able to update privacy setting to anyone can write' , ( ) => {
370
+ cy . getElementByTestId (
371
+ 'workspaceForm-workspaceDetails-edit'
372
+ ) . click ( ) ;
373
+ cy . getElementByTestId ( 'workspacePrivacySettingSelector' ) . click ( {
374
+ force : true ,
375
+ } ) ;
376
+ cy . get ( '#anyone-can-edit' ) . click ( { force : true } ) ;
377
+ cy . getElementByTestId ( 'workspaceForm-bottomBar-updateButton' ) . click (
378
+ { force : true }
379
+ ) ;
380
+
381
+ cy . getElementByTestId (
382
+ 'workspaceForm-bottomBar-updateButton'
383
+ ) . should ( 'not.exist' ) ;
384
+
385
+ const expectedWorkspace = {
386
+ name : workspaceName ,
387
+ description : workspaceDescription ,
388
+ features : workspaceFeatures ,
389
+ permissions : {
390
+ library_write : { users : [ '%me%' , '*' ] } ,
391
+ write : { users : [ '%me%' ] } ,
392
+ library_read : {
393
+ users : [ NONE_DASHBOARDS_ADMIN_USERNAME ] ,
394
+ } ,
395
+ read : { users : [ NONE_DASHBOARDS_ADMIN_USERNAME , '*' ] } ,
396
+ } ,
397
+ } ;
398
+ cy . checkWorkspace ( workspaceId , expectedWorkspace ) ;
399
+ } ) ;
400
+ } ) ;
297
401
}
298
402
} ) ;
299
403
}
0 commit comments