Commit 2fddd2bd by Kevin Kim Committed by Eric Fischer

Initial check of removing feature flag (#13058)

parent b04a6a6a
......@@ -7,6 +7,8 @@ from nose.plugins.attrib import attr
from bok_choy.web_app_test import WebAppTest
from bok_choy.page_object import XSS_INJECTION
from datetime import datetime
from pytz import timezone, utc
from ...pages.lms.account_settings import AccountSettingsPage
from ...pages.lms.auto_auth import AutoAuthPage
......@@ -406,6 +408,32 @@ class AccountSettingsPageTest(AccountSettingsTestMixin, WebAppTest):
[u'Pakistan', u'Palau'],
)
def test_time_zone_field(self):
"""
Test behaviour of "Time Zone" field
"""
kiev_abbr, kiev_offset = self._get_time_zone_info('Europe/Kiev')
pacific_abbr, pacific_offset = self._get_time_zone_info('US/Pacific')
self._test_dropdown_field(
u'time_zone',
u'Time Zone',
u'',
[
u'Europe/Kiev ({abbr}, UTC{offset})'.format(abbr=kiev_abbr, offset=kiev_offset),
u'US/Pacific ({abbr}, UTC{offset})'.format(abbr=pacific_abbr, offset=pacific_offset),
],
)
def _get_time_zone_info(self, time_zone_str):
"""
Helper that returns current time zone abbreviation and UTC offset
and accounts for daylight savings time
"""
time_zone = datetime.now(utc).astimezone(timezone(time_zone_str))
abbr = time_zone.strftime('%Z')
offset = time_zone.strftime('%z')
return abbr, offset
def test_preferred_language_field(self):
"""
Test behaviour of "Preferred Language" field.
......
# -*- coding: utf-8 -*-
""" Tests for student account views. """
from copy import copy
import re
from unittest import skipUnless
from urllib import urlencode
......@@ -462,9 +461,6 @@ class AccountSettingsViewTest(ThirdPartyAuthTestMixin, TestCase, ProgramsApiConf
'password',
'year_of_birth',
'preferred_language',
]
HIDDEN_FIELDS = [
'time_zone',
]
......@@ -512,35 +508,15 @@ class AccountSettingsViewTest(ThirdPartyAuthTestMixin, TestCase, ProgramsApiConf
self.assertEqual(context['auth']['providers'][0]['name'], 'Facebook')
self.assertEqual(context['auth']['providers'][1]['name'], 'Google')
def test_hidden_fields_not_visible(self):
"""
Test that hidden fields are not visible when disabled.
"""
temp_features = copy(settings.FEATURES)
temp_features['ENABLE_TIME_ZONE_PREFERENCE'] = False
with self.settings(FEATURES=temp_features):
view_path = reverse('account_settings')
response = self.client.get(path=view_path)
for attribute in self.FIELDS:
self.assertIn(attribute, response.content)
for attribute in self.HIDDEN_FIELDS:
self.assertIn('"%s": {"enabled": false' % (attribute), response.content)
def test_hidden_fields_are_visible(self):
def test_view(self):
"""
Test that hidden fields are visible when enabled.
Test that all fields are visible
"""
temp_features = copy(settings.FEATURES)
temp_features['ENABLE_TIME_ZONE_PREFERENCE'] = True
with self.settings(FEATURES=temp_features):
view_path = reverse('account_settings')
response = self.client.get(path=view_path)
for attribute in self.FIELDS:
self.assertIn(attribute, response.content)
for attribute in self.HIDDEN_FIELDS:
self.assertIn('"%s": {"enabled": true' % (attribute), response.content)
view_path = reverse('account_settings')
response = self.client.get(path=view_path)
for attribute in self.FIELDS:
self.assertIn(attribute, response.content)
def test_header_with_programs_listing_enabled(self):
"""
......
......@@ -454,7 +454,6 @@ def account_settings_context(request):
'options': all_languages(),
}, 'time_zone': {
'options': TIME_ZONE_CHOICES,
'enabled': settings.FEATURES.get('ENABLE_TIME_ZONE_PREFERENCE'),
}
},
'platform_name': get_themed_value('PLATFORM_NAME', settings.PLATFORM_NAME),
......
......@@ -164,9 +164,6 @@ FEATURES['ENABLE_DASHBOARD_SEARCH'] = True
# Enable support for OpenBadges accomplishments
FEATURES['ENABLE_OPENBADGES'] = True
# Enable time zone field in account settings. Will be removed in Ticket #TNL-4750.
FEATURES['ENABLE_TIME_ZONE_PREFERENCE'] = True
# Use MockSearchEngine as the search engine for test scenario
SEARCH_ENGINE = "search.tests.mock_search_engine.MockSearchEngine"
# Path at which to store the mock index
......
......@@ -358,9 +358,6 @@ FEATURES = {
# lives in the Extended table, saving the frontend from
# making multiple queries.
'ENABLE_READING_FROM_MULTIPLE_HISTORY_TABLES': True,
# WIP -- will be removed in Ticket #TNL-4750.
'ENABLE_TIME_ZONE_PREFERENCE': False,
}
# Ignore static asset files on import which match this pattern
......
......@@ -32,7 +32,6 @@ define(['backbone',
'options': Helpers.FIELD_OPTIONS
}, 'time_zone': {
'options': Helpers.FIELD_OPTIONS,
'enabled': false
}
};
......
......@@ -101,14 +101,7 @@ define(['underscore'], function(_) {
if (fieldsAreRendered === false) {
expect(sectionFieldElements.length).toBe(0);
} else {
var visible_count = 0;
_.each(sectionsData[sectionIndex].fields, function(field) {
if (field.view.enabled) {
visible_count++;
}
});
expect(sectionFieldElements.length).toBe(visible_count);
expect(sectionFieldElements.length).toBe(sectionsData[sectionIndex].fields.length);
_.each(sectionFieldElements, function (sectionFieldElement, fieldIndex) {
expectElementContainsField(sectionFieldElement, sectionsData[sectionIndex].fields[fieldIndex]);
......
......@@ -116,7 +116,6 @@
required: true,
title: gettext('Time Zone'),
valueAttribute: 'time_zone',
enabled: fieldsData.time_zone.enabled,
helpMessage: gettext(
'Select the time zone for displaying course dates. If you do not specify a ' +
'time zone here, course dates, including assignment deadlines, are displayed in ' +
......
......@@ -68,9 +68,7 @@
_.each(view.$('.account-settings-section-body'), function (sectionEl, index) {
_.each(view.options.tabSections[view.activeTab][index].fields, function (field) {
if (field.view.enabled) {
$(sectionEl).append(field.view.render().el);
}
$(sectionEl).append(field.view.render().el);
});
});
return this;
......
......@@ -82,7 +82,6 @@
this.helpMessage = this.options.helpMessage || '';
this.showMessages = _.isUndefined(this.options.showMessages) ? true : this.options.showMessages;
this.enabled = _.isUndefined(this.options.enabled) ? true: this.options.enabled;
_.bindAll(this, 'modelValue', 'modelValueIsSet', 'showNotificationMessage','getNotificationMessage',
'getMessage', 'title', 'showHelpMessage', 'showInProgressMessage', 'showSuccessMessage',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment