Get tests working, template issues
authorCharles Connell <charles@connells.org>
Mon, 14 Apr 2014 20:06:01 +0000 (16:06 -0400)
committerCharles Connell <charles@connells.org>
Mon, 14 Apr 2014 20:06:01 +0000 (16:06 -0400)
karmaworld/apps/courses/test/test_selenium.py
karmaworld/templates/courses/course_detail.html

index ac13425e32b565868cfbfca197260a98f7844815..094396f6f74c739764c8acbe6c3d0692550f3e6c 100644 (file)
@@ -129,6 +129,8 @@ HONEYPOT_FIELD_OPTIONS = (
     FieldAction(HONEYPOT_FIELD_NAME, '', autocomplete=False, error_expected=False),
 )
 
+FIRST_AUTOCOMPLETE_XPATH = "//ul[contains(@style,'display: block')]/li[contains(@class,'ui-menu-item')][1]"
+
 
 class DynamicTestCasesType(type):
     """Borrowed from
@@ -162,6 +164,7 @@ class AddCourseTest(LiveServerTestCase):
     def setUpClass(cls):
         cls.driver = webdriver.Firefox()
         cls.driver.implicitly_wait(3)
+        cls.driver.maximize_window()
         cls.wait = WebDriverWait(cls.driver, 10)
         super(AddCourseTest, cls).setUpClass()
 
@@ -187,11 +190,9 @@ class AddCourseTest(LiveServerTestCase):
         the first item in the autocomplete menu that appears."""
         input = self.driver.find_element_by_name(name)
         input.send_keys(keys)
-        self.wait.until(EC.element_to_be_clickable(
-            (By.XPATH, "//ul[contains(@style,'display: block')]/li[contains(@class,'ui-menu-item')][1]")))
-        input.send_keys(Keys.DOWN)
-        autocomplete_menu_item = self.driver.find_element_by_id("ui-active-menuitem")
-        autocomplete_menu_item.click()
+
+        self.wait.until(EC.element_to_be_clickable((By.XPATH, FIRST_AUTOCOMPLETE_XPATH)))
+        self.driver.find_element_by_xpath(FIRST_AUTOCOMPLETE_XPATH).click()
 
     @staticmethod
     def flatten_actions(actions):
@@ -208,7 +209,6 @@ class AddCourseTest(LiveServerTestCase):
         """Fill out the Add Course form with the given actions."""
         add_course_button = self.driver.find_element_by_id("add-course-btn")
         add_course_button.click()
-        self.driver.execute_script("javascript:window.scrollBy(0,200)")
 
         for action in AddCourseTest.flatten_actions(field_actions):
             if action.autocomplete:
index 2be094239b8ca8c8ac52a896d8ef03b14172a4d7..f513b26d003bf58bb61b1a4c9d1b5a7db4a62e54 100644 (file)
     <div id="course-header">
       <div class="row header-byline">
         <div class="small-12 columns">
-          <span id="course-header-school">{{ course.school.name }}</span>&nbsp;&nbsp;&bull;&nbsp;&nbsp;
+          {% if course.school %}
+            <span id="course-header-school">{{ course.school.name }}</span>
+          {% else %}
+            <span id="course-header-school">{{ course.department.school.name }}</span>
+          {% endif %}
+          &nbsp;&nbsp;&bull;&nbsp;&nbsp;
           {% if course.department %}<span class="course-header-department">{{ course.department.name }}</span>&nbsp;&nbsp;&bull;&nbsp;&nbsp;{% endif %}
-          <span id="course-header-instructor">{{ course.instructor_name }}</span>
+          {% if course.instructor_name %}
+            <span id="course-header-instructor">{{ course.instructor_name }}</span>
+          {% else %}
+            <span id="course-header-instructor">{{ course.instructor.name }}</span>
+          {% endif %}
         </div>
       </div>
 
     <div id="course_container">
       <div class="row">
         <div class="small-12 columns">
-          <!-- Main course table -->
-          <table id="data_table_list">
-            <thead class="hide">
-              <tr>
-                <th class="no-display" id="data-table-date"> Date </th>
-                <th class="no-display" id="data-table-thanks"> Popularity </th>
-                <th class="no-display" id="data-table-note"> Note </th>
-              </tr>
-            </thead>
-            <tbody>
-              {% for note in note_set %}
-                {% include 'notes/note_list_entry.html' with note=note %}
-              {% endfor %}
-            </tbody>
-          </table>
+          {% if not note_set %}
+            <p>This course has no notes yet.</p>
+          {% else %}
+            <!-- Main course table -->
+            <table id="data_table_list">
+              <thead class="hide">
+                <tr>
+                  <th class="no-display" id="data-table-date"> Date </th>
+                  <th class="no-display" id="data-table-thanks"> Popularity </th>
+                  <th class="no-display" id="data-table-note"> Note </th>
+                </tr>
+              </thead>
+              <tbody>
+                {% for note in note_set %}
+                  {% include 'notes/note_list_entry.html' with note=note %}
+                {% endfor %}
+              </tbody>
+            </table>
+          {% endif %}
         </div>
       </div> <!-- .row -->