@@ -27,7 +27,6 @@ import {
2727 QUESTION_APP_SETTINGS ,
2828} from '../../../fixtures/appSettings' ;
2929import { QuizNavigator } from '../../../utils/navigation' ;
30- import { WAITING_DELAY_MS } from '../../../utils/time' ;
3130import { fillMultipleChoiceQuestion } from './multipleChoices.cy' ;
3231
3332const newMultipleChoiceData = {
@@ -43,7 +42,7 @@ const newMultipleChoiceData = {
4342 } ,
4443 ] ,
4544 explanation : 'my new explanation' ,
46- hints : 'my new hints'
45+ hints : 'my new hints' ,
4746} ;
4847
4948describe ( 'Create View' , ( ) => {
@@ -77,25 +76,23 @@ describe('Create View', () => {
7776 // Add three questions and make sure they are added to the QuestionTopBar
7877 cy . get ( dataCyWrapper ( ADD_NEW_QUESTION_TITLE_CY ) ) . should ( 'be.visible' ) ;
7978 fillMultipleChoiceQuestion ( newMultipleChoiceData ) ;
80- // eslint-disable-next-line cypress/no-unnecessary-waiting
81- cy . wait ( WAITING_DELAY_MS ) ; // Wait for the new question to appear
79+ // Wait for the new question to appear
80+ cy . get ( `. ${ QUESTION_STEP_CLASSNAME } ` ) . should ( 'have.length' , 1 ) ;
8281 cy . get ( dataCyWrapper ( NAVIGATION_ADD_QUESTION_BUTTON_CY ) ) . click ( ) ;
8382 cy . get ( dataCyWrapper ( CREATE_QUESTION_TITLE_CY ) )
8483 . should ( 'be.visible' )
8584 . should ( 'have.value' , '' ) ;
8685 fillMultipleChoiceQuestion ( newMultipleChoiceData ) ;
87- // eslint-disable-next-line cypress/no-unnecessary-waiting
88- cy . wait ( WAITING_DELAY_MS ) ;
86+ // Wait for the new question to appear
87+ cy . get ( `. ${ QUESTION_STEP_CLASSNAME } ` ) . should ( 'have.length' , 2 ) ;
8988 cy . get ( dataCyWrapper ( NAVIGATION_ADD_QUESTION_BUTTON_CY ) ) . click ( ) ;
9089 cy . get ( dataCyWrapper ( CREATE_QUESTION_TITLE_CY ) )
9190 . should ( 'be.visible' )
9291 . should ( 'have.value' , '' ) ;
9392 fillMultipleChoiceQuestion ( newMultipleChoiceData ) ;
9493 // Verify the questions are added to the order list by checking the number of
9594 // question nodes in the QuestionTopBar, as we cannot check the app settings directly
96- cy . get ( 'html' )
97- . find ( `.${ QUESTION_STEP_CLASSNAME } ` )
98- . should ( 'have.length' , 3 ) ;
95+ cy . get ( `.${ QUESTION_STEP_CLASSNAME } ` ) . should ( 'have.length' , 3 ) ;
9996 } ) ;
10097 } ) ;
10198
@@ -192,9 +189,7 @@ describe('Create View', () => {
192189 ) ;
193190 cy . get ( dataCyWrapper ( QUESTION_BAR_CY ) ) . should ( 'be.visible' ) ;
194191 fillMultipleChoiceQuestion ( newMultipleChoiceData ) ;
195- cy . get ( 'html' )
196- . find ( `.${ QUESTION_STEP_CLASSNAME } ` )
197- . should ( 'have.length' , 5 ) ;
192+ cy . get ( `.${ QUESTION_STEP_CLASSNAME } ` ) . should ( 'have.length' , 5 ) ;
198193 } ) ;
199194
200195 it ( 'Update Question type should not create a new question' , ( ) => {
@@ -210,9 +205,10 @@ describe('Create View', () => {
210205 cy . get ( `${ dataCyWrapper ( CREATE_VIEW_SAVE_BUTTON_CY ) } ` ) . click ( ) ;
211206
212207 // Check the current number of questions
213- cy . get ( 'html' )
214- . find ( `.${ QUESTION_STEP_CLASSNAME } ` )
215- . should ( 'have.length' , numberOfQuestions ) ;
208+ cy . get ( `.${ QUESTION_STEP_CLASSNAME } ` ) . should (
209+ 'have.length' ,
210+ numberOfQuestions
211+ ) ;
216212
217213 // update the question type and save
218214 const updatedQuestion = {
@@ -236,9 +232,10 @@ describe('Create View', () => {
236232 cy . get ( `${ dataCyWrapper ( CREATE_VIEW_SAVE_BUTTON_CY ) } ` ) . click ( ) ;
237233
238234 // Check that the current number of questions is still unchanged
239- cy . get ( 'html' )
240- . find ( `.${ QUESTION_STEP_CLASSNAME } ` )
241- . should ( 'have.length' , numberOfQuestions ) ;
235+ cy . get ( `.${ QUESTION_STEP_CLASSNAME } ` ) . should (
236+ 'have.length' ,
237+ numberOfQuestions
238+ ) ;
242239
243240 // Check the question title, question type, the answer and attempts.
244241 cy . get ( `${ dataCyWrapper ( CREATE_QUESTION_TITLE_CY ) } input` ) . should (
0 commit comments