-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Jonahstanley/add courseteam tests #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
271de4f
b767467
d471bcb
c74d76a
81b06d5
eb14a07
1b5050c
6d686dd
3c43dbb
40bf251
ef1f523
25fe8e8
46da897
15facf8
650a2ba
0b51f1b
9dc1262
0524ff5
b9d79ae
70d48e2
ec4547b
a52d0be
d632ffe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused by this naming. Why not just have a single 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): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| 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" |
| 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' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| 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 |
| 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 |
There was a problem hiding this comment.
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.