Merge pull request #18728 from edx/awais/lett_2_bc_grading_III
studio grading bokchoy tests III
This commit is contained in:
@@ -2,6 +2,17 @@
|
||||
Feature: CMS.Course Grading
|
||||
As a course author, I want to be able to configure how my course is graded
|
||||
|
||||
# Note that "7" is a special weight because it revealed rounding errors (STUD-826).
|
||||
Scenario: Users can set weight to Assignment types
|
||||
Given I have opened a new course in Studio
|
||||
And I am viewing the grading settings
|
||||
When I add a new assignment type "New Type"
|
||||
And I set the assignment weight to "7"
|
||||
And I press the "Save" notification button
|
||||
Then the assignment weight is displayed as "7"
|
||||
And I reload the page
|
||||
Then the assignment weight is displayed as "7"
|
||||
|
||||
Scenario: Users can delete Assignment types
|
||||
Given I have populated a new course in Studio
|
||||
And I am viewing the grading settings
|
||||
@@ -18,37 +29,6 @@ Feature: CMS.Course Grading
|
||||
And I go back to the main course page
|
||||
Then I do see the assignment name "New Type"
|
||||
|
||||
# Note that "7" is a special weight because it revealed rounding errors (STUD-826).
|
||||
Scenario: Users can set weight to Assignment types
|
||||
Given I have opened a new course in Studio
|
||||
And I am viewing the grading settings
|
||||
When I add a new assignment type "New Type"
|
||||
And I set the assignment weight to "7"
|
||||
And I press the "Save" notification button
|
||||
Then the assignment weight is displayed as "7"
|
||||
And I reload the page
|
||||
Then the assignment weight is displayed as "7"
|
||||
|
||||
Scenario: Settings are only persisted when saved
|
||||
Given I have populated a new course in Studio
|
||||
And I am viewing the grading settings
|
||||
When I change assignment type "Homework" to "New Type"
|
||||
Then I do not see the changes persisted on refresh
|
||||
|
||||
Scenario: Settings are reset on cancel
|
||||
Given I have populated a new course in Studio
|
||||
And I am viewing the grading settings
|
||||
When I change assignment type "Homework" to "New Type"
|
||||
And I press the "Cancel" notification button
|
||||
Then I see the assignment type "Homework"
|
||||
|
||||
Scenario: Confirmation is shown on save
|
||||
Given I have populated a new course in Studio
|
||||
And I am viewing the grading settings
|
||||
When I change assignment type "Homework" to "New Type"
|
||||
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 populated a new course in Studio
|
||||
And I am viewing the grading settings
|
||||
|
||||
@@ -16,6 +16,7 @@ class GradingPage(SettingsPage):
|
||||
|
||||
url_path = "settings/grading"
|
||||
grade_ranges = '.grades .grade-specific-bar'
|
||||
assignments = '.field-group.course-grading-assignment-list-item'
|
||||
|
||||
def is_browser_on_page(self):
|
||||
return self.q(css='body.grading').present
|
||||
@@ -32,7 +33,8 @@ class GradingPage(SettingsPage):
|
||||
def total_number_of_grades(self):
|
||||
"""
|
||||
Gets total number of grades present in the grades bar
|
||||
returns: Single number length of grades
|
||||
Returns:
|
||||
int: Single number length of grades
|
||||
"""
|
||||
self.wait_for_element_visibility(self.grade_ranges, 'Grades are visible')
|
||||
return len(self.q(css=self.grade_ranges))
|
||||
@@ -82,11 +84,36 @@ class GradingPage(SettingsPage):
|
||||
moveable_css = self.q(css='.ui-resizable-e').results[0]
|
||||
action.drag_and_drop_by_offset(moveable_css, 0, 0).perform()
|
||||
|
||||
@property
|
||||
def get_assignment_names(self):
|
||||
"""
|
||||
Get name of the all the assignment types.
|
||||
Returns:
|
||||
list: A list containing names of the assignment types.
|
||||
"""
|
||||
self.wait_for_element_visibility(
|
||||
'#course-grading-assignment-name',
|
||||
'Grade Names not visible.'
|
||||
)
|
||||
return self.q(css='#course-grading-assignment-name').attrs('value')
|
||||
|
||||
def change_assignment_name(self, old_name, new_name):
|
||||
"""
|
||||
Changes the assignment name.
|
||||
Arguments:
|
||||
old_name (str): The assignment type name which is to be changed.
|
||||
new_name (str): New name of the assignment.
|
||||
"""
|
||||
self.wait_for_element_visibility('#course-grading-assignment-name', 'Assignment Name field visible')
|
||||
self.q(css='#course-grading-assignment-name').filter(
|
||||
lambda el: el.get_attribute('value') == old_name).fill(new_name)
|
||||
|
||||
@property
|
||||
def grade_letters(self):
|
||||
"""
|
||||
Get names of grade ranges.
|
||||
Returns: A list containing names of the grade ranges.
|
||||
Returns:
|
||||
list: A list containing names of the grade ranges.
|
||||
"""
|
||||
return self.q(css='.letter-grade').text
|
||||
|
||||
@@ -99,8 +126,9 @@ class GradingPage(SettingsPage):
|
||||
def is_grade_added(self, length):
|
||||
"""
|
||||
Checks to see if grade is added by comparing number of grades after the addition
|
||||
Returns: True if grade is added
|
||||
Returns: False if grade is not added
|
||||
Returns:
|
||||
bool: True if grade is added
|
||||
bool: False if grade is not added
|
||||
"""
|
||||
try:
|
||||
self.wait_for(
|
||||
@@ -112,18 +140,12 @@ class GradingPage(SettingsPage):
|
||||
except BrokenPromise:
|
||||
return False
|
||||
|
||||
def add_new_assignment_type(self):
|
||||
"""
|
||||
Add New Assignment type
|
||||
"""
|
||||
self.q(css='.add-grading-data').click()
|
||||
self.save_changes()
|
||||
|
||||
@property
|
||||
def grades_range(self):
|
||||
"""
|
||||
Get ranges of all the grades.
|
||||
Returns: A list containing ranges of all the grades
|
||||
Returns:
|
||||
list: A list containing ranges of all the grades
|
||||
"""
|
||||
self.wait_for_element_visibility('.range', 'Ranges are visible')
|
||||
return self.q(css='.range').text
|
||||
@@ -159,7 +181,8 @@ class GradingPage(SettingsPage):
|
||||
|
||||
def assignment_name_field_value(self):
|
||||
"""
|
||||
Returns: Assignment type field value
|
||||
Returns:
|
||||
list: Assignment type field value
|
||||
"""
|
||||
return self.q(css='#course-grading-assignment-name').attrs('value')
|
||||
|
||||
@@ -177,12 +200,40 @@ class GradingPage(SettingsPage):
|
||||
while len(self.q(css='.remove-grading-data')) > 0:
|
||||
self.delete_assignment_type()
|
||||
|
||||
def get_confirmation_message(self):
|
||||
"""
|
||||
Get confirmation message received after saving settings.
|
||||
"""
|
||||
self.wait_for_element_visibility('#alert-confirmation-title', 'Confirmation text present')
|
||||
return self.q(css='#alert-confirmation-title').text[0]
|
||||
|
||||
def _get_type_index(self, name):
|
||||
"""
|
||||
Gets the index of assignment type.
|
||||
Arguments:
|
||||
name(str): name of the assignment
|
||||
Returns:
|
||||
int: index of the assignment type
|
||||
"""
|
||||
name_id = '#course-grading-assignment-name'
|
||||
all_types = self.q(css=name_id).results
|
||||
for index, element in enumerate(all_types):
|
||||
if element.get_attribute('value') == name:
|
||||
return index
|
||||
return -1
|
||||
|
||||
def save(self):
|
||||
"""
|
||||
Click on save settings button.
|
||||
"""
|
||||
press_the_notification_button(self, "Save")
|
||||
|
||||
def cancel(self):
|
||||
"""
|
||||
Click on cancel settings button.
|
||||
"""
|
||||
press_the_notification_button(self, "Cancel")
|
||||
|
||||
def refresh_and_wait_for_load(self):
|
||||
"""
|
||||
Refresh the page and wait for all resources to load.
|
||||
|
||||
@@ -130,3 +130,43 @@ class GradingPageTest(StudioCourseTest):
|
||||
grade_ranges,
|
||||
'expected range: 0-3, not found in grade ranges:{}'.format(grade_ranges)
|
||||
)
|
||||
|
||||
def test_settings_are_persisted_on_save_only(self):
|
||||
"""
|
||||
Scenario: Settings are only persisted when saved
|
||||
Given I have populated a new course in Studio
|
||||
And I am viewing the grading settings
|
||||
When I change assignment type "Homework" to "New Type"
|
||||
Then I do not see the changes persisted on refresh
|
||||
"""
|
||||
self.grading_page.change_assignment_name('Homework', 'New Type')
|
||||
self.grading_page.refresh_and_wait_for_load()
|
||||
self.assertIn('Homework', self.grading_page.get_assignment_names)
|
||||
|
||||
def test_settings_are_reset_on_cancel(self):
|
||||
"""
|
||||
Scenario: Settings are reset on cancel
|
||||
Given I have populated a new course in Studio
|
||||
And I am viewing the grading settings
|
||||
When I change assignment type "Homework" to "New Type"
|
||||
And I press the "Cancel" notification button
|
||||
Then I see the assignment type "Homework"
|
||||
"""
|
||||
self.grading_page.change_assignment_name('Homework', 'New Type')
|
||||
self.grading_page.cancel()
|
||||
assignment_names = self.grading_page.get_assignment_names
|
||||
self.assertIn('Homework', assignment_names)
|
||||
|
||||
def test_confirmation_is_shown_on_save(self):
|
||||
"""
|
||||
Scenario: Confirmation is shown on save
|
||||
Given I have populated a new course in Studio
|
||||
And I am viewing the grading settings
|
||||
When I change assignment type "Homework" to "New Type"
|
||||
And I press the "Save" notification button
|
||||
Then I see a confirmation that my changes have been saved
|
||||
"""
|
||||
self.grading_page.change_assignment_name('Homework', 'New Type')
|
||||
self.grading_page.save()
|
||||
confirmation_message = self.grading_page.get_confirmation_message()
|
||||
self.assertEqual(confirmation_message, 'Your changes have been saved.')
|
||||
|
||||
Reference in New Issue
Block a user