1
1
import React from 'react' ;
2
2
import { Factory } from 'rosie' ;
3
- import { getConfig } from '@edx/frontend-platform' ;
3
+ import { getConfig , setConfig } from '@edx/frontend-platform' ;
4
4
import { sendTrackEvent } from '@edx/frontend-platform/analytics' ;
5
5
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth' ;
6
6
import { breakpoints } from '@openedx/paragon' ;
@@ -545,6 +545,111 @@ describe('Progress Tab', () => {
545
545
await fetchAndRender ( ) ;
546
546
expect ( screen . getByText ( 'Grades & Credit' ) ) . toBeInTheDocument ( ) ;
547
547
} ) ;
548
+
549
+ it ( 'does not render ungraded subsections when SHOW_UNGRADED_ASSIGNMENT_PROGRESS is false' , async ( ) => {
550
+ // The second assignment has has_graded_assignment set to false, so it should not be shown.
551
+ setTabData ( {
552
+ section_scores : [
553
+ {
554
+ display_name : 'First section' ,
555
+ subsections : [
556
+ {
557
+ assignment_type : 'Homework' ,
558
+ block_key : 'block-v1:edX+DemoX+Demo_Course+type@sequential+block@12345' ,
559
+ display_name : 'First subsection' ,
560
+ learner_has_access : true ,
561
+ has_graded_assignment : true ,
562
+ num_points_earned : 1 ,
563
+ num_points_possible : 2 ,
564
+ percent_graded : 1.0 ,
565
+ show_correctness : 'always' ,
566
+ show_grades : true ,
567
+ url : 'http://learning.edx.org/course/course-v1:edX+Test+run/first_subsection' ,
568
+ } ,
569
+ ] ,
570
+ } ,
571
+ {
572
+ display_name : 'Second section' ,
573
+ subsections : [
574
+ {
575
+ assignment_type : 'Homework' ,
576
+ display_name : 'Second subsection' ,
577
+ learner_has_access : true ,
578
+ has_graded_assignment : false ,
579
+ num_points_earned : 1 ,
580
+ num_points_possible : 1 ,
581
+ percent_graded : 1.0 ,
582
+ show_correctness : 'always' ,
583
+ show_grades : true ,
584
+ url : 'http://learning.edx.org/course/course-v1:edX+Test+run/second_subsection' ,
585
+ } ,
586
+ ] ,
587
+ } ,
588
+ ] ,
589
+ } ) ;
590
+
591
+ await fetchAndRender ( ) ;
592
+ expect ( screen . getByText ( 'First subsection' ) ) . toBeInTheDocument ( ) ;
593
+ expect ( screen . queryByText ( 'Second subsection' ) ) . not . toBeInTheDocument ( ) ;
594
+ } ) ;
595
+
596
+ it ( 'renders both graded and ungraded subsections when SHOW_UNGRADED_ASSIGNMENT_PROGRESS is true' , async ( ) => {
597
+ // The second assignment has has_graded_assignment set to false.
598
+ setConfig ( {
599
+ ...getConfig ( ) ,
600
+ SHOW_UNGRADED_ASSIGNMENT_PROGRESS : true ,
601
+ } ) ;
602
+
603
+ setTabData ( {
604
+ section_scores : [
605
+ {
606
+ display_name : 'First section' ,
607
+ subsections : [
608
+ {
609
+ assignment_type : 'Homework' ,
610
+ block_key : 'block-v1:edX+DemoX+Demo_Course+type@sequential+block@12345' ,
611
+ display_name : 'First subsection' ,
612
+ learner_has_access : true ,
613
+ has_graded_assignment : true ,
614
+ num_points_earned : 1 ,
615
+ num_points_possible : 2 ,
616
+ percent_graded : 1.0 ,
617
+ show_correctness : 'always' ,
618
+ show_grades : true ,
619
+ url : 'http://learning.edx.org/course/course-v1:edX+Test+run/first_subsection' ,
620
+ } ,
621
+ ] ,
622
+ } ,
623
+ {
624
+ display_name : 'Second section' ,
625
+ subsections : [
626
+ {
627
+ assignment_type : 'Homework' ,
628
+ display_name : 'Second subsection' ,
629
+ learner_has_access : true ,
630
+ has_graded_assignment : false ,
631
+ num_points_earned : 1 ,
632
+ num_points_possible : 1 ,
633
+ percent_graded : 1.0 ,
634
+ show_correctness : 'always' ,
635
+ show_grades : true ,
636
+ url : 'http://learning.edx.org/course/course-v1:edX+Test+run/second_subsection' ,
637
+ } ,
638
+ ] ,
639
+ } ,
640
+ ] ,
641
+ } ) ;
642
+
643
+ await fetchAndRender ( ) ;
644
+ expect ( screen . getByText ( 'First subsection' ) ) . toBeInTheDocument ( ) ;
645
+ expect ( screen . getByText ( 'Second subsection' ) ) . toBeInTheDocument ( ) ;
646
+
647
+ // reset config for other tests
648
+ setConfig ( {
649
+ ...getConfig ( ) ,
650
+ SHOW_UNGRADED_ASSIGNMENT_PROGRESS : false ,
651
+ } ) ;
652
+ } ) ;
548
653
} ) ;
549
654
550
655
describe ( 'Grade Summary' , ( ) => {
@@ -809,7 +914,7 @@ describe('Progress Tab', () => {
809
914
810
915
// Open the problem score drawer
811
916
fireEvent . click ( problemScoreDrawerToggle ) ;
812
- expect ( screen . getByText ( 'Problem Scores:') ) . toBeInTheDocument ( ) ;
917
+ expect ( screen . getAllByText ( 'Graded Scores:') . length ) . toBeGreaterThan ( 1 ) ;
813
918
expect ( screen . getAllByText ( '0/1' ) ) . toHaveLength ( 3 ) ;
814
919
} ) ;
815
920
@@ -821,6 +926,14 @@ describe('Progress Tab', () => {
821
926
expect ( screen . getByText ( 'Detailed grades' ) ) . toBeInTheDocument ( ) ;
822
927
expect ( screen . getByText ( 'You currently have no graded problem scores.' ) ) . toBeInTheDocument ( ) ;
823
928
} ) ;
929
+
930
+ it ( 'renders Detailed Grades table when section scores are populated' , async ( ) => {
931
+ await fetchAndRender ( ) ;
932
+ expect ( screen . getByText ( 'Detailed grades' ) ) . toBeInTheDocument ( ) ;
933
+
934
+ expect ( screen . getByText ( 'First subsection' ) ) ;
935
+ expect ( screen . getByText ( 'Second subsection' ) ) ;
936
+ } ) ;
824
937
} ) ;
825
938
826
939
describe ( 'Certificate Status' , ( ) => {
0 commit comments