Skip to content

Commit ae67fc0

Browse files
committed
Merged in [18884] from jennifer@painless-security.com:
Move agenda TZ selector out of sidebar so it is always available. Fixes ietf-tools#3172. - Legacy-Id: 18885 Note: SVN reference [18884] has been migrated to Git commit 4a287d6
2 parents 8beda6c + 4a287d6 commit ae67fc0

4 files changed

Lines changed: 153 additions & 13 deletions

File tree

ietf/meeting/tests_js.py

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from selenium import webdriver
4242
from selenium.webdriver.common.action_chains import ActionChains
4343
from selenium.webdriver.common.by import By
44-
from selenium.webdriver.support.ui import WebDriverWait
44+
from selenium.webdriver.support.ui import Select, WebDriverWait
4545
from selenium.webdriver.support import expected_conditions
4646
from selenium.common.exceptions import NoSuchElementException
4747
except ImportError as e:
@@ -904,6 +904,107 @@ def test_session_materials_modal(self):
904904
with self.assertRaises(NoSuchElementException):
905905
self.driver.find_element_by_xpath('//a[text()="%s"]' % slide.title)
906906

907+
def _wait_for_tz_change_from(self, old_tz):
908+
"""Helper to wait for tz displays to change from their old value"""
909+
match = 'text()!="%s"' % old_tz
910+
WebDriverWait(self.driver, 2).until(
911+
expected_conditions.presence_of_element_located((By.XPATH, '//*[@class="current-tz"][%s]' % match))
912+
)
913+
914+
def test_agenda_time_zone_selection(self):
915+
self.assertNotEqual(self.meeting.time_zone, 'UTC', 'Meeting time zone must not be UTC')
916+
917+
self.driver.get(self.absreverse('ietf.meeting.views.agenda'))
918+
919+
# wait for the select box to be updated - look for an arbitrary time zone to be in
920+
# its options list to detect this
921+
WebDriverWait(self.driver, 2).until(
922+
expected_conditions.presence_of_element_located((By.XPATH, '//option[@value="America/Halifax"]'))
923+
)
924+
925+
tz_select_input = Select(self.driver.find_element_by_id('timezone_select'))
926+
meeting_tz_link = self.driver.find_element_by_id('meeting-timezone')
927+
local_tz_link = self.driver.find_element_by_id('local-timezone')
928+
utc_tz_link = self.driver.find_element_by_id('utc-timezone')
929+
tz_displays = self.driver.find_elements_by_css_selector('.current-tz')
930+
self.assertGreaterEqual(len(tz_displays), 1)
931+
# we'll check that all current-tz elements are updated, but first check that at least one is in the nav sidebar
932+
self.assertIsNotNone(self.driver.find_element_by_css_selector('.nav .current-tz'))
933+
934+
# Moment.js guesses local time zone based on the behavior of Selenium's web client. This seems
935+
# to inherit Django's settings.TIME_ZONE but I don't know whether that's guaranteed to be consistent.
936+
# To avoid test fragility, ask Moment what it considers local and expect that.
937+
local_tz = self.driver.execute_script('return moment.tz.guess();')
938+
self.assertNotEqual(self.meeting.time_zone, local_tz, 'Meeting time zone must not be local time zone')
939+
self.assertNotEqual(local_tz, 'UTC', 'Local time zone must not be UTC')
940+
941+
# Should start off in meeting time zone
942+
self.assertEqual(tz_select_input.first_selected_option.get_attribute('value'), self.meeting.time_zone)
943+
for disp in tz_displays:
944+
self.assertEqual(disp.text.strip(), self.meeting.time_zone)
945+
946+
# Click 'local' button
947+
local_tz_link.click()
948+
self._wait_for_tz_change_from(self.meeting.time_zone)
949+
self.assertEqual(tz_select_input.first_selected_option.get_attribute('value'), local_tz)
950+
for disp in tz_displays:
951+
self.assertEqual(disp.text.strip(), local_tz)
952+
953+
# click 'utc' button
954+
utc_tz_link.click()
955+
self._wait_for_tz_change_from(local_tz)
956+
self.assertEqual(tz_select_input.first_selected_option.get_attribute('value'), 'UTC')
957+
for disp in tz_displays:
958+
self.assertEqual(disp.text.strip(), 'UTC')
959+
960+
# click back to meeting
961+
meeting_tz_link.click()
962+
self._wait_for_tz_change_from('UTC')
963+
self.assertEqual(tz_select_input.first_selected_option.get_attribute('value'), self.meeting.time_zone)
964+
for disp in tz_displays:
965+
self.assertEqual(disp.text.strip(), self.meeting.time_zone)
966+
967+
# and then back to UTC...
968+
utc_tz_link.click()
969+
self._wait_for_tz_change_from(self.meeting.time_zone)
970+
self.assertEqual(tz_select_input.first_selected_option.get_attribute('value'), 'UTC')
971+
for disp in tz_displays:
972+
self.assertEqual(disp.text.strip(), 'UTC')
973+
974+
# ... and test the switch from UTC to local
975+
local_tz_link.click()
976+
self._wait_for_tz_change_from('UTC')
977+
self.assertEqual(tz_select_input.first_selected_option.get_attribute('value'), local_tz)
978+
for disp in tz_displays:
979+
self.assertEqual(disp.text.strip(), local_tz)
980+
981+
# Now select a different item from the select input
982+
tz_select_input.select_by_value('America/Halifax')
983+
self._wait_for_tz_change_from(self.meeting.time_zone)
984+
self.assertEqual(tz_select_input.first_selected_option.get_attribute('value'), 'America/Halifax')
985+
for disp in tz_displays:
986+
self.assertEqual(disp.text.strip(), 'America/Halifax')
987+
988+
def test_agenda_time_zone_selection_updates_weekview(self):
989+
"""Changing the time zone should update the weekview to match"""
990+
# enable a filter so the weekview iframe is visible
991+
self.driver.get(self.absreverse('ietf.meeting.views.agenda') + '?show=mars')
992+
# wait for the select box to be updated - look for an arbitrary time zone to be in
993+
# its options list to detect this
994+
WebDriverWait(self.driver, 2).until(
995+
expected_conditions.presence_of_element_located((By.XPATH, '//option[@value="America/Halifax"]'))
996+
)
997+
998+
tz_select_input = Select(self.driver.find_element_by_id('timezone_select'))
999+
1000+
# Now select a different item from the select input
1001+
tz_select_input.select_by_value('America/Halifax')
1002+
self._wait_for_tz_change_from(self.meeting.time_zone)
1003+
self.assertEqual(tz_select_input.first_selected_option.get_attribute('value'), 'America/Halifax')
1004+
self.driver.switch_to.frame('weekview')
1005+
wv_url = self.driver.execute_script('return document.location.href')
1006+
self.assertIn('tz=america/halifax', wv_url)
1007+
9071008

9081009
@skipIf(skip_selenium, skip_message)
9091010
class WeekviewTests(MeetingTestCase):

ietf/meeting/tests_views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ def test_meeting_agenda(self):
143143
self.assertIn(session.group.parent.acronym.upper(), agenda_content)
144144
self.assertIn(slot.location.name, agenda_content)
145145
self.assertIn(time_interval, agenda_content)
146+
self.assertIsNotNone(q(':input[value="%s"]' % meeting.time_zone),
147+
'Time zone selector should show meeting timezone')
148+
self.assertIsNotNone(q('.nav *:contains("%s")' % meeting.time_zone),
149+
'Time zone indicator should be in nav sidebar')
146150

147151
# plain
148152
time_interval = "%s-%s" % (slot.time.strftime("%H:%M").lstrip("0"), (slot.time + slot.duration).strftime("%H:%M").lstrip("0"))

ietf/static/ietf/js/agenda/timezone.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ function timezone_init(current) {
2828
var tz_names = moment.tz.names();
2929
var select = $('#timezone_select');
3030

31+
select.empty();
3132
$.each(tz_names, function(i, item) {
32-
if (current == item) {
33+
if (current === item) {
3334
select.append($('<option/>', {
3435
selected: "selected", html: item, value: item }));
3536
} else {
@@ -178,7 +179,7 @@ function add_tooltips() {
178179
// Update times on the agenda based on the selected timezone
179180
function update_times(newtz) {
180181
current_timezone = newtz;
181-
$('#title-timezone').html(newtz);
182+
$('span.current-tz').html(newtz);
182183
$('span.time').each(function () {
183184
if (this.format == 4) {
184185
var tz = this.start_ts.tz(newtz).format(" z");

ietf/templates/meeting/agenda.html

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@
2828
.session-materials .agenda-frame,.minutes-frame {
2929
white-space: normal;
3030
}
31+
div.tz-display {
32+
margin-bottom: 0.5em;
33+
margin-top: 1em;
34+
text-align: right;
35+
}
36+
.tz-display a {
37+
cursor: pointer;
38+
}
39+
.tz-display label {
40+
font-weight: normal;
41+
}
42+
.tz-display select {
43+
min-width: 15em;
44+
}
45+
#affix .nav li.tz-display {
46+
padding: 4px 20px;
47+
}
48+
#affix .nav li.tz-display a {
49+
display: inline;
50+
padding: 0;
51+
}
3152
{% endblock %}
3253

3354
{% block bodyAttrs %}data-spy="scroll" data-target="#affix"{% endblock %}
@@ -50,8 +71,23 @@
5071
{# cache this part -- it takes 3-6 seconds to generate #}
5172
{% load cache %}
5273
{% cache cache_time ietf_meeting_agenda_utc schedule.meeting.number request.path %}
53-
<h1>Agenda <small id="title-timezone" class="pull-right" >{{timezone}}</small></h1>
54-
74+
<div class="row">
75+
<div class="col-xs-6"><h1>Agenda</h1></div>
76+
<div class="col-xs-6">
77+
<div class="tz-display">
78+
<div><small>
79+
<label for="timezone_select">Time zone:</label>
80+
<a id="meeting-timezone" onclick="use_timezone(0)">Meeting</a> |
81+
<a id="local-timezone" onclick="use_timezone(1)">Local</a> |
82+
<a id="utc-timezone" onclick="use_timezone(2)">UTC</a>
83+
</small></div>
84+
<select id="timezone_select">
85+
{# Avoid blank while loading. JavaScript replaces the option list after init. #}
86+
<option selected>{{ timezone }}</option>
87+
</select>
88+
</div>
89+
</div>
90+
</div>
5591
{% if is_current_meeting %}
5692
<p class="alert alert-info">
5793
<b>Note:</b> IETF agendas are subject to change, up to and during a meeting.
@@ -319,15 +355,13 @@ <h2>
319355
{% endifchanged %}
320356
{% endfor %}
321357
<li><hr/></li>
322-
323-
<li class="tzselect">Select timezone:</li>
324-
<li><a id="meeting-timezone" onclick="use_timezone(0)">Meeting Timezone</a></li>
325-
<li><a id="local-timezone" onclick="use_timezone(1)">Local Timezone</a></li>
326-
<li><a id="utc-timezone" onclick="use_timezone(2)">UTC</a></li>
327-
<li id="timezone">
328-
<select style="width: 12em;" id="timezone_select"></select>
358+
<li class="tz-display">Showing <span class="current-tz">{{ timezone }}</span> time</li>
359+
<li class="tz-display"><span> {# span avoids applying nav link styling to these shortcuts #}
360+
<a onclick="use_timezone(0)">Meeting time</a> |
361+
<a onclick="use_timezone(1)">Local time</a> |
362+
<a onclick="use_timezone(2)">UTC</a></span>
329363
</li>
330-
{% if settings.DEBUG and settings.DEBUG_AGENDA %}
364+
{% if settings.DEBUG and settings.DEBUG_AGENDA %}
331365
<li><hr/></li>
332366
<li><span id="current-time"></span></li>
333367
{% endif %}

0 commit comments

Comments
 (0)