@@ -3,12 +3,15 @@ import { Context, PermissionLevel } from '@graasp/sdk';
33import {
44 ADMIN_PANEL_CY ,
55 DETAILS_INSTRUCTIONS_CY ,
6+ LIKERT_RATING_CY ,
67 ORCHESTRATION_BAR_CY ,
78 PROMPTS_CY ,
89 PROPOSE_NEW_RESPONSE_BTN_CY ,
910 RESPONSE_COLLECTION_VIEW_CY ,
11+ RESPONSE_CY ,
1012 RESPONSE_EVALUATION_VIEW_CY ,
1113 RESPONSE_RESULTS_VIEW_CY ,
14+ SUBMIT_RESPONSE_BTN_CY ,
1215 TITLE_INSTRUCTIONS_CY ,
1316 buildDataCy ,
1417} from '@/config/selectors' ;
@@ -22,6 +25,7 @@ import {
2225 ALL_SETTINGS ,
2326 ALL_SETTINGS_OBJECT ,
2427 SETTINGS_WITH_ASSISTANT ,
28+ SETTINGS_WITH_RATINGS ,
2529} from '../../fixtures/appSettings' ;
2630import { MEMBERS } from '../../fixtures/members' ;
2731
@@ -108,7 +112,7 @@ describe('Player with read rights, configured with one assistant and no data.',
108112 } ) ;
109113
110114 it ( 'goes through all the steps.' , ( ) => {
111- const MEAN_WAITING_TIME = 6000 ;
115+ const MEAN_WAITING_TIME = 4000 ;
112116 // Propose a new idea, then go to next step
113117 cy . get ( buildDataCy ( ADMIN_PANEL_CY ) ) . should ( 'not.exist' ) ;
114118
@@ -128,15 +132,75 @@ describe('Player with read rights, configured with one assistant and no data.',
128132 // eslint-disable-next-line cypress/no-unnecessary-waiting
129133 cy . wait ( MEAN_WAITING_TIME ) ;
130134
131- // cy.get(buildDataCy(RESPONSE_CY))
132- // .first()
133- // .within(() => {
134- // cy.get(buildDataCy(LIKERT_RATING_CY))
135- // .first()
136- // .within(() => {
137- // cy.get('input[value=5]').click({ force: true });
138- // });
139- // });
135+ cy . get ( buildDataCy ( ORCHESTRATION_BAR_CY . NEXT_STEP_BTN ) ) . click ( ) ;
136+
137+ cy . get ( buildDataCy ( RESPONSE_RESULTS_VIEW_CY ) ) . should ( 'exist' ) ;
138+ } ) ;
139+ } ) ;
140+
141+ describe ( 'Player with read rights, configured to rate ideas.' , ( ) => {
142+ beforeEach ( ( ) => {
143+ cy . setUpApi (
144+ {
145+ appSettings : SETTINGS_WITH_RATINGS ,
146+ appData : [ ] ,
147+ } ,
148+ {
149+ context : Context . Player ,
150+ permission : PermissionLevel . Read ,
151+ accountId : MEMBERS . ANNA . id ,
152+ } ,
153+ ) ;
154+ cy . visit ( '/' ) ;
155+ } ) ;
156+
157+ it ( 'types a few ideas and rate them.' , ( ) => {
158+ const MEAN_WAITING_TIME = 4000 ;
159+ // Propose a new idea, then go to next step
160+ cy . get ( buildDataCy ( ADMIN_PANEL_CY ) ) . should ( 'not.exist' ) ;
161+
162+ cy . get ( buildDataCy ( ORCHESTRATION_BAR_CY . PLAY_BUTTON ) ) . click ( ) ;
163+
164+ const newIdeas = [ 'Testing this software' , "I don't know." , 'Sleep...' ] ;
165+
166+ cy . get ( buildDataCy ( RESPONSE_COLLECTION_VIEW_CY ) ) . within ( ( ) => {
167+ newIdeas . forEach ( ( idea ) => {
168+ cy . get ( buildDataCy ( PROPOSE_NEW_RESPONSE_BTN_CY ) ) . click ( ) ;
169+ cy . get ( '#input-response' ) . type ( 'a' ) ;
170+ cy . get ( '#input-response' ) . type ( '{backspace}' ) ;
171+ cy . get ( '#input-response' ) . should ( 'be.enabled' ) ;
172+ cy . get ( '#input-response' ) . type ( idea , { delay : 20 } ) ;
173+ cy . get ( buildDataCy ( SUBMIT_RESPONSE_BTN_CY ) ) . click ( ) ;
174+ } ) ;
175+ } ) ;
176+
177+ cy . get ( buildDataCy ( ORCHESTRATION_BAR_CY . NEXT_STEP_BTN ) ) . click ( ) ;
178+ // eslint-disable-next-line cypress/no-unnecessary-waiting
179+ cy . wait ( MEAN_WAITING_TIME ) ;
180+
181+ cy . get ( buildDataCy ( RESPONSE_EVALUATION_VIEW_CY ) ) . should ( 'exist' ) ;
182+
183+ cy . get ( buildDataCy ( RESPONSE_CY ) )
184+ . first ( )
185+ . within ( ( ) => {
186+ cy . get ( buildDataCy ( LIKERT_RATING_CY ) ) . should ( 'have.length' , 2 ) ;
187+ cy . get ( buildDataCy ( LIKERT_RATING_CY ) )
188+ . first ( )
189+ . within ( ( ) => {
190+ cy . get ( 'input[value=5]' ) . click ( { force : true } ) ;
191+ } ) ;
192+ } ) ;
193+
194+ cy . get ( buildDataCy ( RESPONSE_CY ) )
195+ . last ( )
196+ . within ( ( ) => {
197+ cy . get ( buildDataCy ( LIKERT_RATING_CY ) ) . should ( 'have.length' , 2 ) ;
198+ cy . get ( buildDataCy ( LIKERT_RATING_CY ) )
199+ . last ( )
200+ . within ( ( ) => {
201+ cy . get ( 'input[value=2]' ) . click ( { force : true } ) ;
202+ } ) ;
203+ } ) ;
140204
141205 cy . get ( buildDataCy ( ORCHESTRATION_BAR_CY . NEXT_STEP_BTN ) ) . click ( ) ;
142206
0 commit comments