1818import debug # pyflakes:ignore
1919
2020from ietf .doc .factories import DocumentFactory
21+ from ietf .doc .models import State
2122from ietf .group import colors
2223from ietf .person .models import Person
2324from ietf .group .models import Group
@@ -784,7 +785,7 @@ def assert_agenda_view_filter_matches_ics_filter(self, filter_string):
784785 ics_url = self .absreverse ('ietf.meeting.views.agenda_ical' )
785786
786787 # parse out the events
787- agenda_rows = self .driver .find_elements_by_css_selector ('[id^="row-"' )
788+ agenda_rows = self .driver .find_elements_by_css_selector ('[id^="row-"] ' )
788789 visible_rows = [r for r in agenda_rows if r .is_displayed ()]
789790 sessions = [self .session_from_agenda_row_id (row .get_attribute ("id" ))
790791 for row in visible_rows ]
@@ -798,6 +799,111 @@ def assert_agenda_view_filter_matches_ics_filter(self, filter_string):
798799 expected_event_uids = expected_uids ,
799800 expected_event_count = len (sessions ))
800801
802+ def test_session_materials_modal (self ):
803+ """Test opening and re-opening a session materals modal
804+
805+ This currently only tests the slides to ensure that changes to these are picked up
806+ without reloading the main agenda page. This should also test that the agenda and
807+ minutes are displayed and updated correctly, but problems with WebDriver/Selenium/Chromedriver
808+ are blocking this.
809+ """
810+ session = self .meeting .session_set .filter (group__acronym = "mars" ).first ()
811+ assignment = session .official_timeslotassignment ()
812+ slug = assignment .slug ()
813+
814+ url = self .absreverse ('ietf.meeting.views.agenda' )
815+ self .driver .get (url )
816+
817+ # modal should start hidden
818+ modal_div = self .driver .find_element_by_css_selector ('div#modal-%s' % slug )
819+ self .assertFalse (modal_div .is_displayed ())
820+
821+ # Click the 'materials' button
822+ open_modal_button = WebDriverWait (self .driver , 2 ).until (
823+ expected_conditions .element_to_be_clickable (
824+ (By .CSS_SELECTOR , '[data-target="#modal-%s"]' % slug )
825+ ),
826+ 'Modal open button not found or not clickable' ,
827+ )
828+ open_modal_button .click ()
829+ WebDriverWait (self .driver , 2 ).until (
830+ expected_conditions .visibility_of (modal_div ),
831+ 'Modal did not become visible after clicking open button' ,
832+ )
833+
834+ # Check that we have the expected slides
835+ not_deleted_slides = session .materials .filter (
836+ type = 'slides'
837+ ).exclude (
838+ states__type__slug = 'slides' ,states__slug = 'deleted'
839+ )
840+ self .assertGreater (not_deleted_slides .count (), 0 ) # make sure this isn't a pointless test
841+ for slide in not_deleted_slides :
842+ anchor = self .driver .find_element_by_xpath ('//a[text()="%s"]' % slide .title )
843+ self .assertIsNotNone (anchor )
844+
845+ deleted_slides = session .materials .filter (
846+ type = 'slides' , states__type__slug = 'slides' , states__slug = 'deleted'
847+ )
848+ self .assertGreater (deleted_slides .count (), 0 ) # make sure this isn't a pointless test
849+ for slide in deleted_slides :
850+ with self .assertRaises (NoSuchElementException ):
851+ self .driver .find_element_by_xpath ('//a[text()="%s"]' % slide .title )
852+
853+ # Now close the modal
854+ close_modal_button = WebDriverWait (self .driver , 2 ).until (
855+ expected_conditions .element_to_be_clickable (
856+ (By .CSS_SELECTOR , '.modal-footer button[data-dismiss="modal"]' )
857+ ),
858+ 'Modal close button not found or not clickable' ,
859+ )
860+ close_modal_button .click ()
861+ WebDriverWait (self .driver , 2 ).until (
862+ expected_conditions .invisibility_of_element (modal_div ),
863+ 'Modal was not hidden after clicking close button' ,
864+ )
865+
866+ # Modify the session info
867+ newly_deleted_slide = not_deleted_slides .first ()
868+ newly_undeleted_slide = deleted_slides .first ()
869+ newly_deleted_slide .set_state (State .objects .get (type = "slides" , slug = "deleted" ))
870+ newly_undeleted_slide .set_state (State .objects .get (type = "slides" , slug = "active" ))
871+
872+ # Click the 'materials' button
873+ open_modal_button = WebDriverWait (self .driver , 2 ).until (
874+ expected_conditions .element_to_be_clickable (
875+ (By .CSS_SELECTOR , '[data-target="#modal-%s"]' % slug )
876+ ),
877+ 'Modal open button not found or not clickable for refresh test' ,
878+ )
879+ open_modal_button .click ()
880+ WebDriverWait (self .driver , 2 ).until (
881+ expected_conditions .visibility_of (modal_div ),
882+ 'Modal did not become visible after clicking open button for refresh test' ,
883+ )
884+
885+ # Check that we now see the updated slides
886+ not_deleted_slides = session .materials .filter (
887+ type = 'slides'
888+ ).exclude (
889+ states__type__slug = 'slides' ,states__slug = 'deleted'
890+ )
891+ self .assertNotIn (newly_deleted_slide , not_deleted_slides )
892+ self .assertIn (newly_undeleted_slide , not_deleted_slides )
893+ for slide in not_deleted_slides :
894+ anchor = self .driver .find_element_by_xpath ('//a[text()="%s"]' % slide .title )
895+ self .assertIsNotNone (anchor )
896+
897+ deleted_slides = session .materials .filter (
898+ type = 'slides' , states__type__slug = 'slides' , states__slug = 'deleted'
899+ )
900+ self .assertIn (newly_deleted_slide , deleted_slides )
901+ self .assertNotIn (newly_undeleted_slide , deleted_slides )
902+ for slide in deleted_slides :
903+ with self .assertRaises (NoSuchElementException ):
904+ self .driver .find_element_by_xpath ('//a[text()="%s"]' % slide .title )
905+
906+
801907@skipIf (skip_selenium , skip_message )
802908class InterimTests (MeetingTestCase ):
803909 def setUp (self ):
0 commit comments