Commit fba50589 by David Baumgold

Add a lettuce test for course team admins granting admin status

parent c82ad6cd
...@@ -53,6 +53,14 @@ def i_have_opened_a_new_course(_step): ...@@ -53,6 +53,14 @@ def i_have_opened_a_new_course(_step):
open_new_course() open_new_course()
@step('(I select|s?he selects) the new course')
def select_new_course(_step, whom):
course_link_xpath = '//div[contains(@class, "courses")]//a[contains(@class, "class-link")]//span[contains(., "{name}")]/..'.format(
name="Robot Super Course")
element = world.browser.find_by_xpath(course_link_xpath)
element.click()
@step(u'I press the "([^"]*)" notification button$') @step(u'I press the "([^"]*)" notification button$')
def press_the_notification_button(_step, name): def press_the_notification_button(_step, name):
css = 'a.action-%s' % name.lower() css = 'a.action-%s' % name.lower()
......
...@@ -32,3 +32,16 @@ Feature: Course Team ...@@ -32,3 +32,16 @@ Feature: Course Team
And I am viewing the course team settings And I am viewing the course team settings
When I add "dennis" to the course team When I add "dennis" to the course team
Then I should see "Could not find user by email address" somewhere on the page Then I should see "Could not find user by email address" somewhere on the page
Scenario: Admins should be able to make other people into admins
Given I have opened a new course in Studio
And the user "emily" exists
And I am viewing the course team settings
And I add "emily" to the course team
When I make "emily" a course team admin
And "emily" logs in
And she selects the new course
And she views the course team settings
Then "emily" should be marked as an admin
And she can add users
And she can delete users
...@@ -8,8 +8,8 @@ PASSWORD = 'test' ...@@ -8,8 +8,8 @@ PASSWORD = 'test'
EMAIL_EXTENSION = '@edx.org' EMAIL_EXTENSION = '@edx.org'
@step(u'I am viewing the course team settings') @step(u'(I am viewing|s?he views) the course team settings')
def view_grading_settings(_step): def view_grading_settings(_step, whom):
world.click_course_settings() world.click_course_settings()
link_css = 'li.nav-course-settings-team a' link_css = 'li.nav-course-settings-team a'
world.css_click(link_css) world.css_click(link_css)
...@@ -41,29 +41,52 @@ def delete_other_user(_step, name): ...@@ -41,29 +41,52 @@ def delete_other_user(_step, name):
world.css_click(to_delete_css) world.css_click(to_delete_css)
@step(u'I make "([^"]*)" a course team admin')
def make_course_team_admin(_step, name):
admin_btn_css = '.user-item[data-email="{email}"] .user-actions .add-admin-role'.format(
email=name+EMAIL_EXTENSION)
world.css_click(admin_btn_css)
@step(u'"([^"]*)" logs in$') @step(u'"([^"]*)" logs in$')
def other_user_login(_step, name): def other_user_login(_step, name):
log_into_studio(uname=name, password=PASSWORD, email=name + EMAIL_EXTENSION) log_into_studio(uname=name, password=PASSWORD, email=name + EMAIL_EXTENSION)
@step(u's?he does( not)? see the course on (his|her) page') @step(u's?he does( not)? see the course on (his|her) page')
def see_course(_step, doesnt_see_course, gender): def see_course(_step, inverted, gender):
class_css = 'span.class-name' class_css = 'span.class-name'
all_courses = world.css_find(class_css, wait_time=1) all_courses = world.css_find(class_css, wait_time=1)
all_names = [item.html for item in all_courses] all_names = [item.html for item in all_courses]
if doesnt_see_course: if inverted:
assert not world.scenario_dict['COURSE'].display_name in all_names assert not world.scenario_dict['COURSE'].display_name in all_names
else: else:
assert world.scenario_dict['COURSE'].display_name in all_names assert world.scenario_dict['COURSE'].display_name in all_names
@step(u's?he cannot delete users') @step(u'"([^"]*)" should( not)? be marked as an admin')
def cannot_delete(_step): def marked_as_admin(_step, name, inverted):
flag_css = '.user-item[data-email="{email}"] .flag-role.flag-role-admin'.format(
email=name+EMAIL_EXTENSION)
if inverted:
assert world.is_css_not_present(flag_css)
else:
assert world.is_css_present(flag_css)
@step(u's?he can(not)? delete users')
def can_delete_users(_step, inverted):
to_delete_css = 'a.remove-user' to_delete_css = 'a.remove-user'
assert world.is_css_not_present(to_delete_css) if inverted:
assert world.is_css_not_present(to_delete_css)
else:
assert world.is_css_present(to_delete_css)
@step(u's?he cannot add users') @step(u's?he can(not)? add users')
def cannot_add(_step): def can_add_users(_step, inverted):
add_css = 'a.create-user-button' add_css = 'a.create-user-button'
assert world.is_css_not_present(add_css) if inverted:
assert world.is_css_not_present(add_css)
else:
assert world.is_css_present(add_css)
...@@ -57,12 +57,14 @@ ...@@ -57,12 +57,14 @@
<ol class="user-list"> <ol class="user-list">
% for user in staff: % for user in staff:
<li class="user-item" data-url="${reverse('course_team_user', kwargs=dict( <% api_url = reverse('course_team_user', kwargs=dict(
org=context_course.location.org, org=context_course.location.org,
course=context_course.location.course, course=context_course.location.course,
name=context_course.location.name, name=context_course.location.name,
email=user.email, email=user.email,
))}"> ))
%>
<li class="user-item" data-email="${user.email}" data-url="${api_url}">
<% is_instuctor = is_user_in_course_group_role(user, context_course.location, 'instructor', check_staff=False) %> <% is_instuctor = is_user_in_course_group_role(user, context_course.location, 'instructor', check_staff=False) %>
% if is_instuctor: % if is_instuctor:
......
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