Commit 186b3bad by Muddasser

course-settings.feature conversion to bokchoy

parent 26d49a75
@shard_2
Feature: CMS.Course Settings
As a course author, I want to be able to configure my course settings.
# Safari has trouble keeps dates on refresh
@skip_safari
Scenario: User can set course dates
Given I have opened a new course in Studio
When I select Schedule and Details
And I set course dates
And I press the "Save" notification button
And I reload the page
Then I see the set dates
# IE has trouble with saving information
@skip_internetexplorer
Scenario: User can clear previously set course dates (except start date)
Given I have set course dates
And I clear all the dates except start
And I press the "Save" notification button
And I reload the page
Then I see cleared dates
# IE has trouble with saving information
@skip_internetexplorer
Scenario: User cannot clear the course start date
Given I have set course dates
And I press the "Save" notification button
And I clear the course start date
Then I receive a warning about course start date
And I reload the page
And the previously set start date is shown
# IE has trouble with saving information
# Safari gets CSRF token errors
@skip_internetexplorer
@skip_safari
Scenario: User can correct the course start date warning
Given I have tried to clear the course start
And I have entered a new course start date
And I press the "Save" notification button
Then The warning about course start date goes away
And I reload the page
Then my new course start date is shown
# Safari does not save + refresh properly through sauce labs
@skip_safari
Scenario: Settings are only persisted when saved
Given I have set course dates
And I press the "Save" notification button
When I change fields
And I reload the page
Then I do not see the changes
# Safari does not save + refresh properly through sauce labs
@skip_safari
Scenario: Settings are reset on cancel
Given I have set course dates
And I press the "Save" notification button
When I change fields
And I press the "Cancel" notification button
Then I do not see the changes
# Safari gets CSRF token errors
@skip_safari
Scenario: Confirmation is shown on save
Given I have opened a new course in Studio
When I select Schedule and Details
And I change the "<field>" field to "<value>"
And I press the "Save" notification button
Then I see a confirmation that my changes have been saved
# Lettuce hooks don't get called between each example, so we need
# to run the before.each_scenario hook manually to avoid database
# errors.
And I reset the database
Examples:
| field | value |
| Course Start Time | 11:00 |
| Course Introduction Video | 4r7wHMg5Yjg |
| Course Effort | 200:00 |
# Special case because we have to type in code mirror
Scenario: Changes in Course Overview show a confirmation
Given I have opened a new course in Studio
When I select Schedule and Details
And I change the course overview
And I press the "Save" notification button
Then I see a confirmation that my changes have been saved
Scenario: User cannot save invalid settings
Given I have opened a new course in Studio
When I select Schedule and Details
And I change the "Course Start Date" field to ""
Then the save notification button is disabled
...@@ -9,7 +9,10 @@ from bok_choy.javascript import requirejs ...@@ -9,7 +9,10 @@ from bok_choy.javascript import requirejs
from common.test.acceptance.pages.studio.course_page import CoursePage from common.test.acceptance.pages.studio.course_page import CoursePage
from common.test.acceptance.pages.studio.users import wait_for_ajax_or_reload from common.test.acceptance.pages.studio.users import wait_for_ajax_or_reload
from common.test.acceptance.pages.studio.utils import press_the_notification_button from common.test.acceptance.pages.studio.utils import (
press_the_notification_button,
type_in_codemirror
)
@requirejs('js/factories/settings') @requirejs('js/factories/settings')
...@@ -70,6 +73,36 @@ class SettingsPage(CoursePage): ...@@ -70,6 +73,36 @@ class SettingsPage(CoursePage):
results = self.get_elements(css_selector=css_selector) results = self.get_elements(css_selector=css_selector)
return results[0] if results else None return results[0] if results else None
def set_element_values(self, element_values):
"""
Set the values of the elements to those specified
in the element_values dict.
"""
for css, value in element_values.iteritems():
element = self.get_element(css)
element.clear()
element.send_keys(value)
def un_focus_input_field(self):
"""
Makes an input field un-focus by
clicking outside of it.
"""
self.get_element('.title-2').click()
def is_element_present(self, css_selector):
"""
Returns boolean based on the presence
of an element with css as passed.
"""
return self.q(css=css_selector).present
def change_course_description(self, change_text):
"""
Changes the course description
"""
type_in_codemirror(self, 0, change_text, find_prefix="$")
################ ################
# Properties # Properties
################ ################
...@@ -208,6 +241,17 @@ class SettingsPage(CoursePage): ...@@ -208,6 +241,17 @@ class SettingsPage(CoursePage):
# Clicks # Clicks
################ ################
def click_button(self, name):
"""
Clicks the button
"""
btn_css = 'div#page-notification button.action-{}'.format(name.lower())
EmptyPromise(
lambda: self.q(css=btn_css).visible,
'{} button is visible'.format(name)
).fulfill()
press_the_notification_button(self, name)
################ ################
# Workflows # Workflows
################ ################
......
...@@ -160,6 +160,17 @@ def get_codemirror_value(page, index=0, find_prefix="$"): ...@@ -160,6 +160,17 @@ def get_codemirror_value(page, index=0, find_prefix="$"):
) )
def get_input_value(page, css_selector):
"""
Returns the value of the field matching the css selector.
"""
page.wait_for_element_presence(
css_selector,
'Elements matching "{}" selector are present'.format(css_selector)
)
return page.q(css=css_selector).attrs('value')[0]
def set_input_value(page, css, value): def set_input_value(page, css, value):
""" """
Sets the text field with the given label (display name) to the specified value. Sets the text field with the given label (display name) to the specified value.
......
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