diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py
index 516659fadb..1cc71097a0 100644
--- a/cms/djangoapps/contentstore/features/common.py
+++ b/cms/djangoapps/contentstore/features/common.py
@@ -5,9 +5,11 @@ from lettuce import world, step
from nose.tools import assert_true
from auth.authz import get_user_by_email, get_course_groupname_for_role
+from django.conf import settings
from selenium.webdriver.common.keys import Keys
import time
+import os
from django.contrib.auth.models import Group
from logging import getLogger
@@ -15,6 +17,8 @@ logger = getLogger(__name__)
from terrain.browser import reset_data
+TEST_ROOT = settings.COMMON_TEST_DATA_ROOT
+
########### STEP HELPERS ##############
@@ -257,3 +261,12 @@ def type_in_codemirror(index, text):
g._element.send_keys(text)
if world.is_firefox():
world.trigger_event('div.CodeMirror', index=index, event='blur')
+
+
+def upload_file(filename):
+ file_css = '.upload-dialog input[type=file]'
+ upload = world.css_find(file_css).first
+ path = os.path.join(TEST_ROOT, filename)
+ upload._element.send_keys(os.path.abspath(path))
+ button_css = '.upload-dialog .action-upload'
+ world.css_click(button_css)
diff --git a/cms/djangoapps/contentstore/features/course-settings.feature b/cms/djangoapps/contentstore/features/course-settings.feature
index 69183bc3da..8f00452efe 100644
--- a/cms/djangoapps/contentstore/features/course-settings.feature
+++ b/cms/djangoapps/contentstore/features/course-settings.feature
@@ -76,6 +76,7 @@ Feature: Course Settings
Scenario: User can upload course image
Given I have opened a new course in Studio
When I select Schedule and Details
+ And I click the "Upload Course Image" button
And I upload a new course image
Then I should see the new course image
And the image URL should be present in the field
diff --git a/cms/djangoapps/contentstore/features/course-settings.py b/cms/djangoapps/contentstore/features/course-settings.py
index 0847c62a18..570c49a8c4 100644
--- a/cms/djangoapps/contentstore/features/course-settings.py
+++ b/cms/djangoapps/contentstore/features/course-settings.py
@@ -4,9 +4,8 @@
from lettuce import world, step
from terrain.steps import reload_the_page
from selenium.webdriver.common.keys import Keys
-from common import type_in_codemirror
+from common import type_in_codemirror, upload_file
from django.conf import settings
-import os
from nose.tools import assert_true, assert_false, assert_equal
@@ -150,16 +149,15 @@ def test_change_course_overview(_step):
type_in_codemirror(0, "
Overview
")
+@step('I click the "Upload Course Image" button')
+def click_upload_button(_step):
+ button_css = '.action-upload-image'
+ world.css_click(button_css)
+
+
@step('I upload a new course image$')
def upload_new_course_image(_step):
- upload_css = '.action-upload-image'
- world.css_click(upload_css)
- file_css = '.upload-dialog input[type=file]'
- upload = world.css_find(file_css)
- path = os.path.join(TEST_ROOT, 'image.jpg')
- upload._element.send_keys(os.path.abspath(path))
- button_css = '.upload-dialog .action-upload'
- world.css_click(button_css)
+ upload_file('image.jpg')
@step('I should see the new course image$')
diff --git a/cms/djangoapps/contentstore/features/textbooks.py b/cms/djangoapps/contentstore/features/textbooks.py
index d9c08ec6eb..b432b84d4f 100644
--- a/cms/djangoapps/contentstore/features/textbooks.py
+++ b/cms/djangoapps/contentstore/features/textbooks.py
@@ -3,7 +3,7 @@
from lettuce import world, step
from django.conf import settings
-import os
+from common import upload_file
TEST_ROOT = settings.COMMON_TEST_DATA_ROOT
@@ -24,14 +24,8 @@ def assert_create_new_textbook_msg(_step):
@step(u'I upload the textbook "([^"]*)"$')
-def upload_file(_step, file_name):
- file_css = '.upload-dialog input[type=file]'
- upload = world.css_find(file_css)
- # uploading the file itself
- path = os.path.join(TEST_ROOT, 'uploads', file_name)
- upload._element.send_keys(os.path.abspath(path))
- button_css = ".upload-dialog .action-upload"
- world.css_click(button_css)
+def upload_textbook(_step, file_name):
+ upload_file(file_name)
@step(u'I click (on )?the New Textbook button')
diff --git a/cms/static/coffee/spec/models/textbook_spec.coffee b/cms/static/coffee/spec/models/textbook_spec.coffee
index 6e601ecf68..d88e09f57a 100644
--- a/cms/static/coffee/spec/models/textbook_spec.coffee
+++ b/cms/static/coffee/spec/models/textbook_spec.coffee
@@ -196,32 +196,3 @@ describe "CMS.Collections.ChapterSet", ->
# try going back one
@collection.remove(@collection.last())
expect(@collection.nextOrder()).toEqual(2)
-
-
-describe "CMS.Models.FileUpload", ->
- beforeEach ->
- @model = new CMS.Models.FileUpload()
-
- it "is unfinished by default", ->
- expect(@model.get("finished")).toBeFalsy()
-
- it "is not uploading by default", ->
- expect(@model.get("uploading")).toBeFalsy()
-
- it "is valid by default", ->
- expect(@model.isValid()).toBeTruthy()
-
- it "is valid for PDF files", ->
- file = {"type": "application/pdf"}
- @model.set("selectedFile", file);
- expect(@model.isValid()).toBeTruthy()
-
- it "is invalid for text files", ->
- file = {"type": "text/plain"}
- @model.set("selectedFile", file);
- expect(@model.isValid()).toBeFalsy()
-
- it "is invalid for PNG files", ->
- file = {"type": "image/png"}
- @model.set("selectedFile", file);
- expect(@model.isValid()).toBeFalsy()
diff --git a/cms/static/coffee/spec/models/upload_spec.coffee b/cms/static/coffee/spec/models/upload_spec.coffee
new file mode 100644
index 0000000000..e4be3b9a80
--- /dev/null
+++ b/cms/static/coffee/spec/models/upload_spec.coffee
@@ -0,0 +1,33 @@
+describe "CMS.Models.FileUpload", ->
+ beforeEach ->
+ @model = new CMS.Models.FileUpload()
+
+ it "is unfinished by default", ->
+ expect(@model.get("finished")).toBeFalsy()
+
+ it "is not uploading by default", ->
+ expect(@model.get("uploading")).toBeFalsy()
+
+ it "is valid by default", ->
+ expect(@model.isValid()).toBeTruthy()
+
+ it "is valid for PDF files by default", ->
+ file = {"type": "application/pdf"}
+ @model.set("selectedFile", file);
+ expect(@model.isValid()).toBeTruthy()
+
+ it "is invalid for text files by default", ->
+ file = {"type": "text/plain"}
+ @model.set("selectedFile", file);
+ expect(@model.isValid()).toBeFalsy()
+
+ it "is invalid for PNG files by default", ->
+ file = {"type": "image/png"}
+ @model.set("selectedFile", file);
+ expect(@model.isValid()).toBeFalsy()
+
+ it "can accept non-PDF files when explicitly set", ->
+ file = {"type": "image/png"}
+ @model.set("mimeType": "image/png")
+ @model.set("selectedFile", file)
+ expect(@model.isValid()).toBeTruthy()
diff --git a/cms/static/coffee/spec/views/textbook_spec.coffee b/cms/static/coffee/spec/views/textbook_spec.coffee
index 5185c9fb47..ade8c4cb6e 100644
--- a/cms/static/coffee/spec/views/textbook_spec.coffee
+++ b/cms/static/coffee/spec/views/textbook_spec.coffee
@@ -311,121 +311,3 @@ describe "CMS.Views.EditChapter", ->
@view.$(".action-upload").click()
expect(@model.get("name")).toEqual("rainbows")
expect(@model.get("asset_path")).toEqual("unicorns")
-
-
-describe "CMS.Views.UploadDialog", ->
- tpl = readFixtures("upload-dialog.underscore")
-
- beforeEach ->
- setFixtures($("