@@ -7,37 +7,65 @@ import {Organization} from '../../../src/types'
77// will pass without this. However, the chain of actions
88// implemented here replicates what would realistically occur.
99
10- describe . skip ( 'Tasks' , ( ) => {
11- beforeEach ( ( ) => {
12- cy . flush ( )
13- cy . signin ( )
14- cy . get < Organization > ( '@org' ) . then ( ( { id : orgID } : Organization ) =>
15- cy
16- . createToken ( orgID , 'test token' , 'active' , [
17- { action : 'write' , resource : { type : 'views' , orgID} } ,
18- { action : 'write' , resource : { type : 'documents' , orgID} } ,
19- { action : 'write' , resource : { type : 'tasks' , orgID} } ,
20- ] )
21- . then ( ( { body} ) => {
22- cy . wrap ( body . token ) . as ( 'token' )
10+ const isIOxOrg = Boolean ( Cypress . env ( 'useIox' ) )
11+ const isTSMOrg = ! isIOxOrg
12+
13+ // shouldShowTasks determines whether the flag for 'forcing'
14+ // the display of tasks in iox orgs should be enabled.
15+ const setupTest = ( shouldShowTasks : boolean = true ) => {
16+ cy . flush ( )
17+ cy . signin ( )
18+
19+ cy . setFeatureFlags ( { showTasksInNewIOx : shouldShowTasks } )
20+
21+ cy . get < Organization > ( '@org' )
22+ . then ( ( { id : orgID } : Organization ) => {
23+ cy . createToken ( orgID , 'test token' , 'active' , [
24+ { action : 'write' , resource : { type : 'views' , orgID} } ,
25+ { action : 'write' , resource : { type : 'documents' , orgID} } ,
26+ { action : 'write' , resource : { type : 'tasks' , orgID} } ,
27+ ] ) . then ( ( { body} ) => {
28+ cy . wrap ( body . token ) . as ( 'token' )
29+ } )
30+ } )
31+ . then ( ( ) => {
32+ cy . fixture ( 'routes' ) . then ( ( { orgs} ) => {
33+ cy . get < Organization > ( '@org' ) . then ( ( { id} : Organization ) => {
34+ cy . getByTestID ( 'tree-nav' ) . should ( 'be.visible' )
35+ // Tasks link should appear in nav in TSM orgs.
36+ if ( isTSMOrg ) {
37+ cy . getByTestID ( 'nav-item-tasks' ) . should ( 'be.visible' ) . click ( )
38+ } else {
39+ cy . visit ( `${ orgs } /${ id } /tasks` )
40+ }
2341 } )
24- )
25-
26- cy . fixture ( 'routes' ) . then ( ( { orgs} ) => {
27- cy . get < Organization > ( '@org' ) . then ( ( { id} : Organization ) => {
28- cy . visit ( `${ orgs } /${ id } /tasks` )
29- cy . getByTestID ( 'tree-nav' )
3042 } )
3143 } )
44+ }
45+
46+ describe ( 'Tasks - IOx' , ( ) => {
47+ it ( 'New IOx orgs do not have Tasks' , ( ) => {
48+ cy . skipOn ( isTSMOrg )
49+ const shouldShowTasks = false
50+
51+ setupTest ( shouldShowTasks )
52+ cy . getByTestID ( 'nav-item-tasks' ) . should ( 'not.exist' )
53+ cy . contains ( '404: Page Not Found' )
54+ } )
55+ } )
56+
57+ describe ( 'Tasks - TSM' , ( ) => {
58+ beforeEach ( ( ) => {
59+ setupTest ( )
3260 } )
3361
3462 it ( 'can create a task' , ( ) => {
3563 const taskName = 'Task'
3664 cy . createTaskFromEmpty ( taskName , ( { name} ) => {
3765 return `import "influxdata/influxdb/v1"
38- v1.tagValues(bucket: "${ name } ", tag: "_field")
39- from(bucket: "${ name } ")
40- |> range(start: -2m)`
66+ v1.tagValues(bucket: "${ name } ", tag: "_field")
67+ from(bucket: "${ name } ")
68+ |> range(start: -2m)`
4169 } )
4270
4371 cy . getByTestID ( 'task-save-btn' ) . click ( )
@@ -53,7 +81,7 @@ from(bucket: "${name}")
5381 const taskName = 'Task'
5482 cy . createTaskFromEmpty ( taskName , ( ) => {
5583 return `import "http" {enter}
56- http.post(url: "https://foo.bar/baz", data: bytes(v: "body"))`
84+ http.post(url: "https://foo.bar/baz", data: bytes(v: "body"))`
5785 } )
5886
5987 cy . getByTestID ( 'task-save-btn' ) . click ( )
@@ -68,7 +96,7 @@ http.post(url: "https://foo.bar/baz", data: bytes(v: "body"))`
6896
6997 cy . createTaskFromEmpty ( taskName , ( { name} ) => {
7098 return `from(bucket: "${ name } ")
71- |> range(start: -2m)`
99+ |> range(start: -2m)`
72100 } )
73101
74102 cy . getByTestID ( 'task-card-cron-btn' ) . click ( )
@@ -104,12 +132,12 @@ http.post(url: "https://foo.bar/baz", data: bytes(v: "body"))`
104132 cy . focused ( )
105133
106134 cy . getByTestID ( 'flux-editor' ) . monacoType ( `option task = {
107- name: "Option Test",
108- every: 24h,
109- offset: 20m
110- }
111- from(bucket: "defbuck")
112- |> range(start: -2m)` )
135+ name: "Option Test",
136+ every: 24h,
137+ offset: 20m
138+ }
139+ from(bucket: "defbuck")
140+ |> range(start: -2m)` )
113141
114142 cy . getByTestID ( 'task-form-name' )
115143 . click ( )
@@ -427,9 +455,9 @@ from(bucket: "defbuck")
427455 taskName ,
428456 ( { name} ) => {
429457 return `import "influxdata/influxdb/v1"
430- v1.tagValues(bucket: "${ name } ", tag: "_field")
431- from(bucket: "${ name } ")
432- |> range(start: -2m)`
458+ v1.tagValues(bucket: "${ name } ", tag: "_field")
459+ from(bucket: "${ name } ")
460+ |> range(start: -2m)`
433461 } ,
434462 interval ,
435463 offset
0 commit comments