@@ -3,14 +3,19 @@ const {
33 [ env ] : { adminUrl } ,
44} = Cypress . env ( )
55
6- const USER_WITH_ACCESS_CREDENTIALS = {
7- 8- password : 'Password1234' ,
9- }
10-
11- const USER_WITHOUT_ACCESS_CREDENTIALS = {
12- 13- password : 'Password1234' ,
6+ const USER_CREDENTIALS = {
7+ NO_ACCESS : {
8+ 9+ password : 'Password1234' ,
10+ } ,
11+ CAN_ACCESS : {
12+ 13+ password : 'Password1234' ,
14+ } ,
15+ CAN_CREATE : {
16+ 17+ password : 'Password1234' ,
18+ } ,
1419}
1520
1621describe ( 'Roles' , ( ) => {
@@ -34,11 +39,11 @@ describe('Roles', () => {
3439 describe ( 'User without plugin access' , ( ) => {
3540 beforeEach ( ( ) => {
3641 cy . session (
37- USER_WITHOUT_ACCESS_CREDENTIALS . email ,
42+ USER_CREDENTIALS . NO_ACCESS . email ,
3843 ( ) => {
3944 loginUser ( {
40- email : USER_WITHOUT_ACCESS_CREDENTIALS . email ,
41- password : USER_WITHOUT_ACCESS_CREDENTIALS . password ,
45+ email : USER_CREDENTIALS . NO_ACCESS . email ,
46+ password : USER_CREDENTIALS . NO_ACCESS . password ,
4247 } )
4348 } ,
4449 {
@@ -66,11 +71,11 @@ describe('Roles', () => {
6671 describe ( 'User with `read` access' , ( ) => {
6772 beforeEach ( ( ) => {
6873 cy . session (
69- USER_WITH_ACCESS_CREDENTIALS . email ,
74+ USER_CREDENTIALS . CAN_ACCESS . email ,
7075 ( ) => {
7176 loginUser ( {
72- email : USER_WITH_ACCESS_CREDENTIALS . email ,
73- password : USER_WITH_ACCESS_CREDENTIALS . password ,
77+ email : USER_CREDENTIALS . CAN_ACCESS . email ,
78+ password : USER_CREDENTIALS . CAN_ACCESS . password ,
7479 } )
7580 } ,
7681 {
@@ -96,12 +101,50 @@ describe('Roles', () => {
96101
97102 it ( 'cannot create an index' , ( ) => {
98103 visitPluginPage ( )
104+ // There are checkboxes in front of each collection
99105 cy . root ( ) . should ( 'not.contain' , 'button[role="checkbox"]' )
100106 } )
101107
102- it . only ( 'cannot change settings' , ( ) => {
108+ it ( 'cannot change settings' , ( ) => {
103109 visitPluginPage ( )
104110 cy . root ( ) . should ( 'not.contain' , 'button:contains("Save")' )
105111 } )
106112 } )
113+
114+ describe ( 'User with `create` access' , ( ) => {
115+ beforeEach ( ( ) => {
116+ cy . session (
117+ USER_CREDENTIALS . CAN_CREATE . email ,
118+ ( ) => {
119+ loginUser ( {
120+ email : USER_CREDENTIALS . CAN_CREATE . email ,
121+ password : USER_CREDENTIALS . CAN_CREATE . password ,
122+ } )
123+ } ,
124+ {
125+ validate ( ) {
126+ cy . wait ( 1000 )
127+ cy . contains ( 'Hello User who can create' ) . should ( 'be.visible' )
128+ } ,
129+ } ,
130+ )
131+ } )
132+
133+ it ( 'can create an index' , ( ) => {
134+ visitPluginPage ( )
135+
136+ // There are checkboxes in front of each collection
137+ cy . get ( 'button[role="checkbox"]' ) . should ( 'be.visible' )
138+ } )
139+
140+ it . only ( 'can index the user collection' , ( ) => {
141+ visitPluginPage ( )
142+
143+ cy . get ( 'tr:contains("user") button[role="checkbox"]' ) . first ( ) . click ( )
144+
145+ cy . get ( 'tr:contains("user")' ) . contains ( 'Yes' ) . should ( 'be.visible' )
146+ cy . get ( 'tr:contains("user")' ) . contains ( '1 / 1' ) . should ( 'be.visible' )
147+ cy . get ( 'tr:contains("user")' ) . contains ( 'Hooked' ) . should ( 'be.visible' )
148+ } )
149+ } )
107150} )
0 commit comments