Fix a bunch of meeting schedule editor test bugs introduced by the

changes in the previous commit.
 - Legacy-Id: 18013
This commit is contained in:
Ole Laursen 2020-06-17 17:59:06 +00:00
parent b60939a26c
commit 674dae22c7
5 changed files with 38 additions and 32 deletions

View file

@ -115,13 +115,13 @@ class EditMeetingScheduleTests(IetfLiveServerTestCase):
s2_element = self.driver.find_element_by_css_selector('#session{}'.format(s2.pk))
s2_element.click()
session_info_element = self.driver.find_element_by_css_selector('.session-info-container label')
session_info_element = self.driver.find_element_by_css_selector('.session-info-container .title')
self.assertIn(s2.group.acronym, session_info_element.text)
# deselect
self.driver.find_element_by_css_selector('.session-info-container').click()
self.assertEqual(self.driver.find_elements_by_css_selector('.session-info-container label'), [])
self.assertEqual(self.driver.find_elements_by_css_selector('.session-info-container .title'), [])
# unschedule
@ -140,7 +140,7 @@ class EditMeetingScheduleTests(IetfLiveServerTestCase):
self.driver.execute_script('!function(s){s.fn.simulateDragDrop=function(t){return this.each(function(){new s.simulateDragDrop(this,t)})},s.simulateDragDrop=function(t,a){this.options=a,this.simulateEvent(t,a)},s.extend(s.simulateDragDrop.prototype,{simulateEvent:function(t,a){var e="dragstart",n=this.createEvent(e);this.dispatchEvent(t,e,n),e="drop";var r=this.createEvent(e,{});r.dataTransfer=n.dataTransfer,this.dispatchEvent(s(a.dropTarget)[0],e,r),e="dragend";var i=this.createEvent(e,{});i.dataTransfer=n.dataTransfer,this.dispatchEvent(t,e,i)},createEvent:function(t){var a=document.createEvent("CustomEvent");return a.initCustomEvent(t,!0,!0,null),a.dataTransfer={data:{},setData:function(t,a){this.data[t]=a},getData:function(t){return this.data[t]}},a},dispatchEvent:function(t,a,e){t.dispatchEvent?t.dispatchEvent(e):t.fireEvent&&t.fireEvent("on"+a,e)}})}(jQuery);')
self.driver.execute_script("jQuery('#session{}').simulateDragDrop({{dropTarget: '.unassigned-sessions'}});".format(s2.pk))
self.driver.execute_script("jQuery('#session{}').simulateDragDrop({{dropTarget: '.unassigned-sessions .drop-target'}});".format(s2.pk))
WebDriverWait(self.driver, 2).until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR, '.unassigned-sessions #session{}'.format(s2.pk))))
@ -149,22 +149,22 @@ class EditMeetingScheduleTests(IetfLiveServerTestCase):
# sorting unassigned
sorted_pks = [s.pk for s in sorted([s1, s2], key=lambda s: s.group.acronym)]
self.driver.find_element_by_css_selector('[name=sort_unassigned] option[value=name]').click()
self.assertTrue(self.driver.find_element_by_css_selector('.unassigned-sessions #session{} + #session{}'.format(*sorted_pks)))
self.assertTrue(self.driver.find_element_by_css_selector('.unassigned-sessions .drop-target #session{} + #session{}'.format(*sorted_pks)))
sorted_pks = [s.pk for s in sorted([s1, s2], key=lambda s: (s.group.parent.acronym, s.group.acronym))]
self.driver.find_element_by_css_selector('[name=sort_unassigned] option[value=parent]').click()
self.assertTrue(self.driver.find_element_by_css_selector('.unassigned-sessions #session{} + #session{}'.format(*sorted_pks)))
self.assertTrue(self.driver.find_element_by_css_selector('.unassigned-sessions .drop-target #session{} + #session{}'.format(*sorted_pks)))
sorted_pks = [s.pk for s in sorted([s1, s2], key=lambda s: (s.requested_duration, s.group.parent.acronym, s.group.acronym))]
self.driver.find_element_by_css_selector('[name=sort_unassigned] option[value=duration]').click()
self.assertTrue(self.driver.find_element_by_css_selector('.unassigned-sessions #session{} + #session{}'.format(*sorted_pks)))
self.assertTrue(self.driver.find_element_by_css_selector('.unassigned-sessions .drop-target #session{} + #session{}'.format(*sorted_pks)))
sorted_pks = [s.pk for s in sorted([s1, s2], key=lambda s: (bool(s.comments), s.group.parent.acronym, s.group.acronym))]
self.driver.find_element_by_css_selector('[name=sort_unassigned] option[value=comments]').click()
self.assertTrue(self.driver.find_element_by_css_selector('.unassigned-sessions #session{} + #session{}'.format(*sorted_pks)))
self.assertTrue(self.driver.find_element_by_css_selector('.unassigned-sessions .drop-target #session{} + #session{}'.format(*sorted_pks)))
# schedule
self.driver.execute_script("jQuery('#session{}').simulateDragDrop({{dropTarget: '#timeslot{}'}});".format(s2.pk, slot1.pk))
self.driver.execute_script("jQuery('#session{}').simulateDragDrop({{dropTarget: '#timeslot{} .drop-target'}});".format(s2.pk, slot1.pk))
WebDriverWait(self.driver, 2).until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR, '#timeslot{} #session{}'.format(slot1.pk, s2.pk))))
@ -172,7 +172,7 @@ class EditMeetingScheduleTests(IetfLiveServerTestCase):
self.assertEqual(assignment.timeslot, slot1)
# reschedule
self.driver.execute_script("jQuery('#session{}').simulateDragDrop({{dropTarget: '#timeslot{}'}});".format(s2.pk, slot2.pk))
self.driver.execute_script("jQuery('#session{}').simulateDragDrop({{dropTarget: '#timeslot{} .drop-target'}});".format(s2.pk, slot2.pk))
WebDriverWait(self.driver, 2).until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR, '#timeslot{} #session{}'.format(slot2.pk, s2.pk))))
@ -193,7 +193,7 @@ class EditMeetingScheduleTests(IetfLiveServerTestCase):
self.assertTrue(constraint_element.is_displayed())
# current constraint violations
self.driver.execute_script("jQuery('#session{}').simulateDragDrop({{dropTarget: '#timeslot{}'}});".format(s1.pk, slot1.pk))
self.driver.execute_script("jQuery('#session{}').simulateDragDrop({{dropTarget: '#timeslot{} .drop-target'}});".format(s1.pk, slot1.pk))
WebDriverWait(self.driver, 2).until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR, '#timeslot{} #session{}'.format(slot1.pk, s1.pk))))

View file

@ -970,7 +970,7 @@ class EditTests(TestCase):
name=ConstraintName.objects.get(slug="conflict"),
)
p = Person.objects.all().first()
p = Person.objects.order_by('pk')[1]
Constraint.objects.create(
meeting=meeting,
@ -1003,7 +1003,7 @@ class EditTests(TestCase):
for s in [s1, s2]:
e = q("#session{}".format(s.pk))
# info in the movable entity
# info in the item representing the session that can be moved around
self.assertIn(s.group.acronym, e.find(".session-label").text())
if s.comments:
self.assertTrue(e.find(".comments"))
@ -1011,8 +1011,16 @@ class EditTests(TestCase):
self.assertIn(str(s.attendees), e.find(".attendees").text())
self.assertTrue(e.hasClass("parent-{}".format(s.group.parent.acronym)))
constraints = e.find(".constraints > span")
s_other = s2 if s == s1 else s1
self.assertEqual(len(constraints), 2)
self.assertEqual(constraints.eq(0).attr("data-sessions"), str(s_other.pk))
self.assertEqual(constraints.eq(1).attr("data-sessions"), str(s_other.pk))
self.assertEqual(constraints.find(".encircled").text(), "1" if s_other == s2 else "-1")
self.assertEqual(constraints.find(".fa-user-o").parent().text(), "1") # 1 person in the constraint
# session info for the panel
self.assertIn(str(s.requested_duration.total_seconds() / 60.0 / 60), e.find(".session-info label").text())
self.assertIn(str(round(s.requested_duration.total_seconds() / 60.0 / 60, 1)), e.find(".session-info .title").text())
event = SchedulingEvent.objects.filter(session=s).order_by("id").first()
if event:
@ -1021,14 +1029,12 @@ class EditTests(TestCase):
if s.comments:
self.assertIn(s.comments, e.find(".comments").text())
# constraints
constraints = e.find(".constraints > span")
s_other = s2 if s == s1 else s1
self.assertEqual(len(constraints), 2)
self.assertEqual(constraints.eq(0).attr("data-sessions"), str(s_other.pk))
self.assertEqual(constraints.eq(1).attr("data-sessions"), str(s_other.pk))
self.assertEqual(constraints.find(".encircled").text(), "1")
self.assertEqual(constraints.find(".fa-user-o").parent().text(), "1") # 1 person in the constraint
formatted_constraints = e.find(".session-info .formatted-constraints > *")
if s == s1:
self.assertIn(s_other.group.acronym, formatted_constraints.eq(0).html())
self.assertIn(p.name, formatted_constraints.eq(1).html())
elif s == s2:
self.assertIn(p.name, formatted_constraints.eq(0).html())
self.assertTrue(q("em:contains(\"You can't edit this schedule\")"))

View file

@ -5589,9 +5589,9 @@
{
"fields": {
"desc": "",
"editor_label": "(person)",
"editor_label": "(person){count}",
"name": "Person must be present",
"order": 0,
"order": 4,
"penalty": 200000,
"used": true
},
@ -5603,7 +5603,7 @@
"desc": "",
"editor_label": "(2)",
"name": "Conflicts with (secondary)",
"order": 0,
"order": 2,
"penalty": 10000,
"used": true
},
@ -5615,7 +5615,7 @@
"desc": "",
"editor_label": "(3)",
"name": "Conflicts with (tertiary)",
"order": 0,
"order": 3,
"penalty": 1000,
"used": true
},
@ -5627,7 +5627,7 @@
"desc": "",
"editor_label": "(1)",
"name": "Conflicts with",
"order": 0,
"order": 1,
"penalty": 100000,
"used": true
},
@ -5639,7 +5639,7 @@
"desc": "",
"editor_label": "time_relation",
"name": "Preference for time between sessions",
"order": 0,
"order": 6,
"penalty": 1000,
"used": true
},
@ -5651,7 +5651,7 @@
"desc": "",
"editor_label": "timerange",
"name": "Can't meet within timerange",
"order": 0,
"order": 5,
"penalty": 100000,
"used": true
},
@ -5663,7 +5663,7 @@
"desc": "",
"editor_label": "wg_adjacent",
"name": "Request for adjacent scheduling with another WG",
"order": 0,
"order": 7,
"penalty": 10000,
"used": true
},

View file

@ -268,7 +268,7 @@ jQuery(document).ready(function () {
function updateAttendeesViolations() {
sessions.each(function () {
let roomCapacity = jQuery(this).closest(".timeline").data("roomcapacity");
let roomCapacity = jQuery(this).closest(".timeslots").data("roomcapacity");
if (roomCapacity && this.dataset.attendees)
jQuery(this).toggleClass("too-many-attendees", +this.dataset.attendees > +roomCapacity);
});
@ -341,7 +341,7 @@ jQuery(document).ready(function () {
else if (sortBy == "comments")
keyFunctions = [extractComments, extractParent, extractName, extractDuration];
let unassignedSessionsContainer = content.find(".unassigned-sessions");
let unassignedSessionsContainer = content.find(".unassigned-sessions .drop-target");
let sortedSessions = sortArrayWithKeyFunctions(unassignedSessionsContainer.children(".session").toArray(), keyFunctions);
for (let i = 0; i < sortedSessions.length; ++i)

View file

@ -25,7 +25,7 @@
{# the JS uses this to display session information in the bottom panel #}
<div class="session-info">
<div>
<div class="title">
<strong>
<span class="time pull-right"></span>
{{ session.scheduling_label }}