From 6b8347ce90386f92dd926c2125d9997a2eb59a25 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Thu, 15 Apr 2021 16:28:25 +0000 Subject: [PATCH] Fix occasional failure in test_agenda_view_team_group_filter_toggle. Commit ready for merge. - Legacy-Id: 18958 --- ietf/meeting/tests_js.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/ietf/meeting/tests_js.py b/ietf/meeting/tests_js.py index 180d90033..243688159 100644 --- a/ietf/meeting/tests_js.py +++ b/ietf/meeting/tests_js.py @@ -10,7 +10,6 @@ import re from unittest import skipIf import django -from django.urls import reverse as urlreverse from django.utils.text import slugify from django.db.models import F from pytz import timezone @@ -30,7 +29,6 @@ from ietf.meeting.models import (Schedule, SchedTimeSessAssignment, Session, Room, TimeSlot, Constraint, ConstraintName, Meeting, SchedulingEvent, SessionStatusName) from ietf.meeting.utils import add_event_info_to_session_qs -from ietf.utils.test_runner import IetfLiveServerTestCase from ietf.utils.test_utils import assert_ical_response_is_valid from ietf.utils.jstest import IetfSeleniumTestCase, ifSeleniumEnabled, selenium_enabled from ietf import settings @@ -702,6 +700,14 @@ class AgendaTests(IetfSeleniumTestCase): e.g., 'hackathon', or 'tools' group sessions from being shown/hidden when their parent group filter button is clicked. """ + def _schedule_session(meeting, session): + """Schedule a session, guaranteeing that it is not in a private timeslot""" + SchedTimeSessAssignment.objects.create( + schedule=meeting.schedule, + timeslot=TimeSlotFactory(meeting=meeting), + session=session, + ) + wait = WebDriverWait(self.driver, 10) meeting = Meeting.objects.get(type_id='ietf') parent_group = GroupFactory(type_id='area') @@ -709,15 +715,26 @@ class AgendaTests(IetfSeleniumTestCase): hackathon_group = GroupFactory(acronym='hackathon', type_id='team', parent=parent_group) # hackathon session - SessionFactory( - meeting=meeting, - type_id='other', - group=hackathon_group, - name='Hackathon', + # + # Add to schedule ourselves because the default scheduling sometimes puts the session + # in a private timeslot, preventing the session from appearing on the agenda and breaking + # the test. + _schedule_session( + meeting, + SessionFactory( + meeting=meeting, + type_id='other', + group=hackathon_group, + name='Hackathon', + add_to_schedule=False + ) ) - # session to cause the parent_group to appear in the filter UI tables - SessionFactory(meeting=meeting, type_id='regular', group=other_group) + # Session to cause the parent_group to appear in the filter UI tables. + _schedule_session( + meeting, + SessionFactory(meeting=meeting, type_id='regular', group=other_group, add_to_schedule=False) + ) self.login() url = self.absreverse('ietf.meeting.views.agenda')