Merge pull request #2205 from edx/christina/duplicate
Front-end work for duplicating components on the unit page.
This commit is contained in:
@@ -101,3 +101,14 @@ Feature: CMS.Component Adding
|
||||
And I add a "Blank Advanced Problem" "Advanced Problem" component
|
||||
And I delete all components
|
||||
Then I see no components
|
||||
|
||||
Scenario: I can duplicate a component
|
||||
Given I am in Studio editing a new unit
|
||||
And I add a "Blank Common Problem" "Problem" component
|
||||
And I add a "Multiple Choice" "Problem" component
|
||||
And I duplicate the first component
|
||||
Then I see a Problem component with display name "Duplicate of 'Blank Common Problem'" in position "1"
|
||||
And I reload the page
|
||||
Then I see a Problem component with display name "Blank Common Problem" in position "0"
|
||||
And I see a Problem component with display name "Duplicate of 'Blank Common Problem'" in position "1"
|
||||
And I see a Problem component with display name "Multiple Choice" in position "2"
|
||||
|
||||
@@ -132,3 +132,25 @@ def delete_one_component(step):
|
||||
def edit_and_save_component(step):
|
||||
world.css_click('.edit-button')
|
||||
world.css_click('.save-button')
|
||||
|
||||
|
||||
@step(u'I duplicate the (first|second|third) component$')
|
||||
def duplicated_component(step, ordinal):
|
||||
ord_map = {
|
||||
"first": 0,
|
||||
"second": 1,
|
||||
"third": 2,
|
||||
}
|
||||
index = ord_map[ordinal]
|
||||
duplicate_btn_css = 'a.duplicate-button'
|
||||
world.css_click(duplicate_btn_css, int(index))
|
||||
|
||||
|
||||
@step(u'I see a Problem component with display name "([^"]*)" in position "([^"]*)"$')
|
||||
def see_component_in_position(step, display_name, index):
|
||||
component_css = 'section.xmodule_CapaModule'
|
||||
|
||||
def find_problem(_driver):
|
||||
return world.css_text(component_css, int(index)).startswith(display_name.upper())
|
||||
|
||||
world.wait_for(find_problem, timeout_msg='Did not find the duplicated problem')
|
||||
|
||||
@@ -288,8 +288,8 @@ class TestDuplicateItem(ItemTest):
|
||||
# Uses default display_name of 'Text' from HTML component.
|
||||
verify_name(self.html_locator, self.seq_locator, "Duplicate of 'Text'")
|
||||
|
||||
# The sequence does not have a display_name set, so None gets included as the string 'None'.
|
||||
verify_name(self.seq_locator, self.chapter_locator, "Duplicate of 'None'")
|
||||
# The sequence does not have a display_name set, so category is shown.
|
||||
verify_name(self.seq_locator, self.chapter_locator, "Duplicate of sequential")
|
||||
|
||||
# Now send a custom display name for the duplicate.
|
||||
verify_name(self.seq_locator, self.chapter_locator, "customized name", display_name="customized name")
|
||||
|
||||
@@ -321,7 +321,10 @@ def _duplicate_item(parent_location, duplicate_source_location, display_name=Non
|
||||
if display_name is not None:
|
||||
duplicate_metadata['display_name'] = display_name
|
||||
else:
|
||||
duplicate_metadata['display_name'] = _("Duplicate of '{0}'").format(source_item.display_name)
|
||||
if source_item.display_name is None:
|
||||
duplicate_metadata['display_name'] = _("Duplicate of {0}").format(source_item.category)
|
||||
else:
|
||||
duplicate_metadata['display_name'] = _("Duplicate of '{0}'").format(source_item.display_name)
|
||||
|
||||
get_modulestore(category).create_and_save_xmodule(
|
||||
dest_location,
|
||||
|
||||
Reference in New Issue
Block a user