import { createAndLoginTA , checkInTA , createQueue , createQuestion , loginUser , createAndLoginStudent , } from "../../utils" ; describe ( "TA interacts with student question" , ( ) => { beforeEach ( ( ) => { createAndLoginStudent ( ) ; createQueue ( { courseId : "student.course.id" } ) ; createAndLoginTA ( { courseId : "student.course.id" } ) ; checkInTA ( { courseId : "student.course.id" } ) ; createQuestion ( { identifier : "question1" , queueId : "queue.id" , studentId : "student.user.id" , data : { text : "How do I use the design recipe?" } } ) ; createQuestion ( { queueId : "queue.id" , identifier : "question2" } ) ; loginUser ( "ta" ) ; cy . get ( "@queue" ) . then ( ( queue ) => { cy . visit ( `/course/${ queue . courseId }/queue/${ queue . id }` ) ; } ) ; } ) ; it ( "clicks the help button then finish helping" , function ( ) { cy . get ( "[data-cy='list-queue'] [data-cy^='queue-list-item']" ) . should ( "have.length" , 2 ) ; cy . get ( `[data-cy='queue-list-item-${ this . question1 . id }']` ) . should ( "be.visible" ) . click ( ) ; cy . get ( "[data-cy='help-student']" ) . click ( ) ; cy . get ( "[data-cy='finish-helping-button']" ) . should ( "be.visible" ) . click ( ) ; cy . get ( "[data-cy='list-queue'] [data-cy^='queue-list-item']" ) . should ( "have.length" , 1 ) ; cy . get ( `[data-cy='list-helping'] [data-cy='queue-list-item-${ this . question1 . id }']` ) ; } ) ; it ( "clicks the Help Next button to help the next student" , ( ) => { cy . get ( "[data-cy='help-next']" ) . click ( ) ; cy . get ( "[data-cy='finish-helping-button']" ) . should ( "exist" ) ; cy . get ( "body" ) . should ( "not.contain" , "#2" ) ; cy . percySnapshot ( "TA Queue Page - Helping Student Banner" ) ; } ) ; it ( "clicks a students question and then removes it from the queue" , function ( ) { cy . get ( "[data-cy='list-queue'] [data-cy^='queue-list-item']" ) . should ( "have.length" , 2 ) ; cy . get ( `[data-cy='queue-list-item-${ this . question1 . id }']` ) . should ( "be.visible" ) . click ( ) ; cy . get ( "[data-cy='remove-from-queue']" ) . should ( "be.visible" ) . click ( ) ; cy . get ( "span" ) . contains ( "Yes" ) . click ( ) ; cy . get ( "[data-cy='list-queue'] [data-cy^='queue-list-item']" ) . should ( "have.length" , 1 ) ; } ) ; it ( "removes another student from the queue while helping" , function ( ) { cy . get ( `[data-cy='queue-list-item-${ this . question1 . id }']` ) . should ( "be.visible" ) . click ( ) ; cy . get ( "[data-cy='help-student']" ) . click ( ) ; cy . get ( "body" ) . should ( "contain" , "Helping" ) ; cy . get ( "[data-cy='list-queue'] [data-cy^='queue-list-item']" ) . first ( ) . should ( "be.visible" ) . click ( ) ; cy . get ( "[data-cy='remove-from-queue']" ) . should ( "be.visible" ) . click ( ) ; cy . get ( "span" ) . contains ( "Yes" ) . click ( ) ; cy . get ( `[data-cy='list-helping'] [data-cy='queue-list-item-${ this . question1 . id }']` ) ; } ) ; describe ( "Remove from Queue" , ( ) => { it ( "TA removes student question from the queue and student rejoins" , function ( ) { cy . get ( `[data-cy='list-queue'] [data-cy^='queue-list-item-${ this . question1 . id }']` ) . should ( "be.visible" ) . click ( ) ; cy . get ( "[data-cy='remove-from-queue']" ) . first ( ) . click ( ) ; cy . get ( "body" ) . should ( "contain" , "Yes" ) ; cy . get ( "button" ) . contains ( "Yes" ) . click ( ) ; loginUser ( "student" ) ; cy . visit ( `course/${ this . queue . courseId }/queue/${ this . queue . id }` ) . then ( ( ) => { cy . get ( "body" ) . should ( "contain" , "You've been removed from the queue by a TA. If you have any questions, please reach out to the TA. If you'd like to join back into the queue with your previous question, click Rejoin Queue, otherwise click Leave Queue." ) ; cy . get ( "body" ) . should ( "contain" , "Rejoin Queue" ) ; cy . get ( "button" ) . contains ( "Rejoin Queue" ) . click ( ) ; cy . get ( "body" ) . should ( "contain" , "How do I use the design recipe?" ) ; } ) ; } ) ; it ( "TA removes student question from the queue and student leaves" , function ( ) { cy . visit ( `/course/${ this . queue . courseId }/queue/${ this . queue . id }` ) ; cy . get ( `[data-cy='list-queue'] [data-cy^='queue-list-item-${ this . question1 . id }']` ) . should ( "be.visible" ) . click ( ) ; cy . get ( "[data-cy='remove-from-queue']" ) . click ( ) ; cy . get ( "body" ) . should ( "contain" , "Yes" ) ; cy . get ( "button" ) . contains ( "Yes" ) . click ( ) ; loginUser ( "student" ) ; cy . visit ( `course/${ this . queue . courseId }/queue/${ this . queue . id }` ) . then ( ( ) => { cy . get ( "body" ) . should ( "contain" , "You've been removed from the queue by a TA. If you have any questions, please reach out to the TA. If you'd like to join back into the queue with your previous question, click Rejoin Queue, otherwise click Leave Queue." ) ; cy . get ( "button" ) . contains ( "Leave Queue" ) . click ( ) ; cy . get ( "body" ) . should ( "not.contain" , "How do I use the design recipe?" ) ; } ) ; } ) ; it ( "TA removes a question that is in Drafting status" , function ( ) { createQuestion ( { identifier : "draftingQuestion" , queueId : "queue.id" , data : { status : "Drafting" , text : "" } } ) ; cy . get ( "body" ) . contains ( "Still Drafting" ) . click ( ) ; cy . get ( "[data-cy='remove-from-queue']" ) . click ( ) ; cy . get ( "body" ) . should ( "contain" , "Yes" ) ; cy . get ( "button" ) . contains ( "Yes" ) . click ( ) ; cy . get ( "body" ) . should ( "not.contain" , "Still Drafting" ) ; } ) ; } ) ; } ) ;