Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions cms/djangoapps/contentstore/features/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
from logging import getLogger
logger = getLogger(__name__)

COURSE_NAME = 'Robot Super Course'
COURSE_NUM = '999'
COURSE_ORG = 'MITx'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please prefix these variable names with an underscore.


########### STEP HELPERS ##############

@step('I (?:visit|access|open) the Studio homepage$')
Expand Down Expand Up @@ -54,6 +58,7 @@ def i_have_opened_a_new_course(step):
####### HELPER FUNCTIONS ##############
def open_new_course():
world.clear_courses()
create_studio_user()
log_into_studio()
create_a_course()

Expand All @@ -75,9 +80,9 @@ def create_studio_user(


def fill_in_course_info(
name='Robot Super Course',
org='MITx',
num='101'):
name=COURSE_NAME,
org=COURSE_ORG,
num=COURSE_NUM):
world.css_fill('.new-course-name', name)
world.css_fill('.new-course-org', org)
world.css_fill('.new-course-number', num)
Expand All @@ -86,10 +91,7 @@ def fill_in_course_info(
def log_into_studio(
uname='robot',
email='robot+studio@edx.org',
password='test',
is_staff=False):

create_studio_user(uname=uname, email=email, is_staff=is_staff)
password='test'):

world.browser.cookies.delete()
world.visit('/')
Expand All @@ -107,11 +109,11 @@ def log_into_studio(


def create_a_course():
c = world.CourseFactory.create(org='MITx', course='999', display_name='Robot Super Course')
c = world.CourseFactory.create(org=COURSE_ORG, course=COURSE_NUM, display_name=COURSE_NAME)

# Add the user to the instructor group of the course
# so they will have the permissions to see it in studio
g = world.GroupFactory.create(name='instructor_MITx/999/Robot_Super_Course')
g = world.GroupFactory.create(name='instructor_MITx/{course_num}/{course_name}'.format(course_num=COURSE_NUM, course_name=COURSE_NAME.replace(" ", "_")))
u = get_user_by_email('robot+studio@edx.org')
u.groups.add(g)
u.save()
Expand Down
34 changes: 34 additions & 0 deletions cms/djangoapps/contentstore/features/course-team.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Feature: Course Team
As a course author, I want to be able to add others to my team

Scenario: Users can add other users
Given I have opened a new course in Studio
And The user "abcd" exists
And I am viewing the course team settings
When I add "abcd" to the course team
And "abcd" logs in
Then He does see the course on his page

Scenario: Added users cannot delete or add other users
Given I have opened a new course in Studio
And The user "abcd" exists
And I am viewing the course team settings
When I add "abcd" to the course team
And "abcd" logs in
Then He cannot delete users
And He cannot add users

Scenario: Users can delete other users
Given I have opened a new course in Studio
And The user "abcd" exists
And I am viewing the course team settings
When I add "abcd" to the course team
And I delete "abcd" from the course team
And "abcd" logs in
Then He does not see the course on his page

Scenario: Users cannot add users that do not exist
Given I have opened a new course in Studio
And I am viewing the course team settings
When I add "abcd" to the course team
Then I should see "Could not find user by email address" somewhere on the page
67 changes: 67 additions & 0 deletions cms/djangoapps/contentstore/features/course-team.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#pylint: disable=C0111
#pylint: disable=W0621

from lettuce import world, step
from common import create_studio_user, log_into_studio, COURSE_NAME

PASSWORD = 'test'
EMAIL_EXTENSION = '@edx.org'


@step(u'I am viewing the course team settings')
def view_grading_settings(step):
world.click_course_settings()
link_css = 'li.nav-course-settings-team a'
world.css_click(link_css)


@step(u'The user "([^"]*)" exists$')
def create_other_user(step, name):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by this naming. Why not just have a single create_user method that gets called multiple times with different usernames?

Same goes for uses of "other" below.

create_studio_user(uname=name, password=PASSWORD, email=(name + EMAIL_EXTENSION))


@step(u'I add "([^"]*)" to the course team')
def add_other_user(step, name):
new_user_css = 'a.new-user-button'
world.css_click(new_user_css)

email_css = 'input.email-input'
f = world.css_find(email_css)
f._element.send_keys(name, EMAIL_EXTENSION)

confirm_css = '#add_user'
world.css_click(confirm_css)


@step(u'I delete "([^"]*)" from the course team')
def delete_other_user(step, name):
to_delete_css = '.remove-user[data-id="{name}{extension}"]'.format(name=name, extension=EMAIL_EXTENSION)
world.css_click(to_delete_css)


@step(u'"([^"]*)" logs in$')
def other_user_login(step, name):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method duplicates code we have elsewhere. Could you extend existing login helpers to accept an arbitrary name/password?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it stands, the login function also creates the user. Would you like me to instead refactor that method (in common.py) to take in an optional argument stating if the user is a new user or not?

log_into_studio(uname=name, password=PASSWORD, email=name + EMAIL_EXTENSION)


@step(u'He does( not)? see the course on his page')
def see_course(step, doesnt_see_course):
class_css = '.class-name'
all_courses = world.css_find(class_css)
all_names = [item.html for item in all_courses]
if doesnt_see_course:
assert not COURSE_NAME in all_names
else:
assert COURSE_NAME in all_names


@step(u'He cannot delete users')
def cannot_delete(step):
to_delete_css = '.remove-user'
assert world.is_css_not_present(to_delete_css)


@step(u'He cannot add users')
def cannot_add(step):
add_css = '.new-user'
assert world.is_css_not_present(add_css)
37 changes: 37 additions & 0 deletions cms/djangoapps/contentstore/features/course-updates.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Feature: Course updates
As a course author, I want to be able to provide updates to my students

Scenario: Users can add updates
Given I have opened a new course in Studio
And I go to the course updates page
When I add a new update with the text "Hello"
Then I should see the update "Hello"

Scenario: Users can edit updates
Given I have opened a new course in Studio
And I go to the course updates page
When I add a new update with the text "Hello"
And I modify the text to "Goodbye"
Then I should see the update "Goodbye"

Scenario: Users can delete updates
Given I have opened a new course in Studio
And I go to the course updates page
And I add a new update with the text "Hello"
When I will confirm all alerts
And I delete the update
Then I should not see the update "Hello"


Scenario: Users can edit update dates
Given I have opened a new course in Studio
And I go to the course updates page
And I add a new update with the text "Hello"
When I edit the date to "June 1, 2013"
Then I should see the date "June 1, 2013"

Scenario: Users can change handouts
Given I have opened a new course in Studio
And I go to the course updates page
When I modify the handout to "<ol>Test</ol>"
Then I see the handout "Test"
92 changes: 92 additions & 0 deletions cms/djangoapps/contentstore/features/course-updates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#pylint: disable=C0111
#pylint: disable=W0621

from lettuce import world, step
from selenium.webdriver.common.keys import Keys


@step(u'I go to the course updates page')
def go_to_uploads(step):
menu_css = 'li.nav-course-courseware'
uploads_css = '.nav-course-courseware-updates'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this, and all the other elements that we will be finding via css in this file, please use the element type as well as the class, instead of just the class.

world.css_click(menu_css)
world.css_click(uploads_css)


@step(u'I add a new update with the text "([^"]*)"$')
def add_update(step, text):
update_css = '.new-update-button'
world.css_click(update_css)
change_text(text)


@step(u'I should( not)? see the update "([^"]*)"$')
def check_update(step, doesnt_see_update, text):
update_css = '.update-contents'
update = world.css_find(update_css)
if doesnt_see_update:
assert len(update) == 0 or not text in update.html
else:
assert text in update.html


@step(u'I modify the text to "([^"]*)"$')
def modify_update(step, text):
button_css = '.post-preview .edit-button'
world.css_click(button_css)
change_text(text)


@step(u'I delete the update$')
def click_button(step):
button_css = '.post-preview .delete-button'
world.css_click(button_css)


@step(u'I edit the date to "([^"]*)"$')
def change_date(step, new_date):
button_css = '.post-preview .edit-button'
world.css_click(button_css)
date_css = 'input.date'
date = world.css_find(date_css)
for i in range(len(date.value)):
date._element.send_keys(Keys.END, Keys.BACK_SPACE)
date._element.send_keys(new_date)
save_css = '.save-button'
world.css_click(save_css)


@step(u'I should see the date "([^"]*)"$')
def check_date(step, date):
date_css = '.date-display'
date_html = world.css_find(date_css)
assert date == date_html.html


@step(u'I modify the handout to "([^"]*)"$')
def edit_handouts(step, text):
edit_css = '.course-handouts > .edit-button'
world.css_click(edit_css)
change_text(text)


@step(u'I see the handout "([^"]*)"$')
def check_handout(step, handout):
handout_css = '.handouts-content'
handouts = world.css_find(handout_css)
assert handout in handouts.html


def change_text(text):
text_css = 'div.CodeMirror > div > textarea'
prev_css = 'div.CodeMirror-lines > div > div:last-child > pre'
all_lines = world.css_find(prev_css)
all_text = ''
for i in range(len(all_lines)):
all_text = all_lines[i].html
text_area = world.css_find(text_css)
for i in range(len(all_text)):
text_area._element.send_keys(Keys.END, Keys.BACK_SPACE)
text_area._element.send_keys(text)
save_css = '.save-button'
world.css_click(save_css)
1 change: 1 addition & 0 deletions cms/djangoapps/contentstore/features/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@step('There are no courses$')
def no_courses(step):
world.clear_courses()
create_studio_user()


@step('I click the New Course button$')
Expand Down
24 changes: 24 additions & 0 deletions cms/djangoapps/contentstore/features/static-pages.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Feature: Static Pages
As a course author, I want to be able to add static pages

Scenario: Users can add static pages
Given I have opened a new course in Studio
And I go to the static pages page
When I add a new page
Then I should see a "Empty" static page

Scenario: Users can delete static pages
Given I have opened a new course in Studio
And I go to the static pages page
And I add a new page
When I will confirm all alerts
And I "delete" the "Empty" page
Then I should not see a "Empty" static page

Scenario: Users can edit static pages
Given I have opened a new course in Studio
And I go to the static pages page
And I add a new page
When I "edit" the "Empty" page
And I change the name to "New"
Then I should see a "New" static page
59 changes: 59 additions & 0 deletions cms/djangoapps/contentstore/features/static-pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#pylint: disable=C0111
#pylint: disable=W0621

from lettuce import world, step
from selenium.webdriver.common.keys import Keys


@step(u'I go to the static pages page')
def go_to_uploads(step):
menu_css = 'li.nav-course-courseware'
uploads_css = '.nav-course-courseware-pages'
world.css_find(menu_css).click()
world.css_find(uploads_css).click()


@step(u'I add a new page')
def add_page(step):
button_css = '.new-button'
world.css_find(button_css).click()


@step(u'I should( not)? see a "([^"]*)" static page$')
def see_page(step, doesnt, page):
index = get_index(page)
if doesnt:
assert index == -1
else:
assert index != -1


@step(u'I "([^"]*)" the "([^"]*)" page$')
def click_edit_delete(step, edit_delete, page):
button_css = '.%s-button' % edit_delete
index = get_index(page)
assert index != -1
world.css_find(button_css)[index].click()


@step(u'I change the name to "([^"]*)"$')
def change_name(step, new_name):
settings_css = '#settings-mode'
world.css_find(settings_css).click()
input_css = '.setting-input'
name_input = world.css_find(input_css)
old_name = name_input.value
for count in range(len(old_name)):
name_input._element.send_keys(Keys.END, Keys.BACK_SPACE)
name_input._element.send_keys(new_name)
save_button = '.save-button'
world.css_find(save_button).click()


def get_index(name):
page_name_css = 'section[data-type="HTMLModule"]'
all_pages = world.css_find(page_name_css)
for i in range(len(all_pages)):
if all_pages[i].html == '\n {name}\n'.format(name=name):
return i
return -1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def have_a_course_with_two_sections(step):

@step(u'I navigate to the course overview page$')
def navigate_to_the_course_overview_page(step):
log_into_studio(is_staff=True)
create_studio_user(is_staff=True)
log_into_studio()
course_locator = '.class-name'
world.css_click(course_locator)

Expand Down
Loading