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