def create_component_instance(step, category, component_type=None, is_advanced=False): """ Create a new component in a Unit. Parameters ---------- category: component type (discussion, html, problem, video) component_type: for components with multiple templates, the link text in the menu is_advanced: for problems, is the desired component under the advanced menu? """ assert_in(category, ["problem", "html", "video", "discussion"]) component_button_css = "span.large-{}-icon".format(category.lower()) if category == "problem": module_css = "section.xmodule_CapaModule" else: module_css = "section.xmodule_{}Module".format(category.title()) # Count how many of that module is on the page. Later we will # assert that one more was added. # We need to use world.browser.find_by_css instead of world.css_find # because it's ok if there are currently zero of them. module_count_before = len(world.browser.find_by_css(module_css)) # Disable the jquery animation for the transition to the menus. world.disable_jquery_animations() world.css_click(component_button_css) if category in ("problem", "html"): world.wait_for_invisible(component_button_css) click_component_from_menu(category, component_type, is_advanced) expected_count = module_count_before + 1 world.wait_for(lambda _: len(world.css_find(module_css)) == expected_count, timeout=20)
def create_component_instance(step, category, component_type=None, is_advanced=False): """ Create a new component in a Unit. Parameters ---------- category: component type (discussion, html, problem, video) component_type: for components with multiple templates, the link text in the menu is_advanced: for problems, is the desired component under the advanced menu? """ assert_in(category, ['problem', 'html', 'video', 'discussion']) component_button_css = 'span.large-{}-icon'.format(category.lower()) if category == 'problem': module_css = 'section.xmodule_CapaModule' else: module_css = 'section.xmodule_{}Module'.format(category.title()) # Count how many of that module is on the page. Later we will # assert that one more was added. # We need to use world.browser.find_by_css instead of world.css_find # because it's ok if there are currently zero of them. module_count_before = len(world.browser.find_by_css(module_css)) # Disable the jquery animation for the transition to the menus. world.disable_jquery_animations() world.css_click(component_button_css) if category in ('problem', 'html'): world.wait_for_invisible(component_button_css) click_component_from_menu(category, component_type, is_advanced) world.wait_for(lambda _: _is_expected_element_count(module_css, module_count_before + 1))
def when_i_navigate_to_a_section(step): # Prevent jQuery menu animations from interferring with the clicks world.disable_jquery_animations() # Open the 2nd section world.css_click(css_selector='div.chapter', index=1) subsection_css = 'a[href*="Test_Subsection_2/"]' # Click on the subsection to see the content world.css_click(subsection_css)
def when_i_navigate_to_a_section(step): # Prevent jQuery menu animations from interferring with the clicks world.disable_jquery_animations() # Open the 2nd section world.css_click(css_selector='.chapter', index=1) subsection_css = 'a[href*="Test_Subsection_2/"]' # Click on the subsection to see the content world.css_click(subsection_css)
def i_created_a_video_component(step): world.create_course_with_unit() world.create_component_instance(step=step, category="video") world.wait_for_xmodule() world.disable_jquery_animations() world.wait_for_present(".is-initialized") world.wait(DELAY) world.wait_for_invisible(SELECTORS["spinner"])
def i_created_a_video_component(step): step.given("I am in Studio editing a new unit") world.create_component_instance(step=step, category="video") world.wait_for_xmodule() world.disable_jquery_animations() world.wait_for_present(".is-initialized") world.wait(DELAY) world.wait_for_invisible(SELECTORS["spinner"]) if not world.youtube.config.get("youtube_api_blocked"): world.wait_for_visible(SELECTORS["controls"])
def i_created_a_video_component(_step): world.create_course_with_unit() world.create_component_instance( step=_step, category='video', ) world.wait_for_xmodule() world.disable_jquery_animations() world.wait_for_present('.is-initialized') world.wait(DELAY) world.wait_for_invisible(SELECTORS['spinner'])
def i_created_a_video_component(step): world.create_course_with_unit() world.create_component_instance( step=step, category='video', ) world.wait_for_xmodule() world.disable_jquery_animations() world.wait_for_present('.is-initialized') world.wait(DELAY) world.wait_for_invisible(SELECTORS['spinner'])
def i_created_a_video_component(step): step.given('I am in Studio editing a new unit') world.create_component_instance( step=step, category='video', ) world.wait_for_xmodule() world.disable_jquery_animations() world.wait_for_present('.is-initialized') world.wait(DELAY) world.wait_for_invisible(SELECTORS['spinner']) if not world.youtube.config.get('youtube_api_blocked'): world.wait_for_visible(SELECTORS['controls'])
def i_created_a_video_with_subs_with_name(_step, sub_id): _step.given('I have created a Video component') # Store the current URL so we can return here video_url = world.browser.url # Upload subtitles for the video using the upload interface _step.given('I have uploaded subtitles "{}"'.format(sub_id)) # Return to the video world.visit(video_url) world.wait_for_xmodule() world.disable_jquery_animations() world.wait_for_present('.is-initialized') world.wait_for_invisible(SELECTORS['spinner'])
def i_created_a_video_component(_step): assert_less(world.youtube.config['youtube_api_response'].status_code, 400, "Real Youtube server is unavailable") world.create_course_with_unit() world.create_component_instance( step=_step, category='video', ) world.wait_for_xmodule() world.disable_jquery_animations() world.wait_for_present('.is-initialized') world.wait(DELAY) world.wait_for_invisible(SELECTORS['spinner']) if not world.youtube.config.get('youtube_api_blocked'): world.wait_for_visible(SELECTORS['controls'])
def create_component_instance(step, category, component_type=None, is_advanced=False, advanced_component=None): """ Create a new component in a Unit. Parameters ---------- category: component type (discussion, html, problem, video, advanced) component_type: for components with multiple templates, the link text in the menu is_advanced: for problems, is the desired component under the advanced menu? advanced_component: for advanced components, the related value of policy key 'advanced_modules' """ assert_in(category, ['advanced', 'problem', 'html', 'video', 'discussion']) component_button_css = 'span.large-{}-icon'.format(category.lower()) if category == 'problem': module_css = 'div.xmodule_CapaModule' elif category == 'advanced': module_css = 'div.xmodule_{}Module'.format(advanced_component.title()) elif category == 'discussion': module_css = 'div.xblock-author_view-{}'.format(category.lower()) else: module_css = 'div.xmodule_{}Module'.format(category.title()) # Count how many of that module is on the page. Later we will # assert that one more was added. # We need to use world.browser.find_by_css instead of world.css_find # because it's ok if there are currently zero of them. module_count_before = len(world.browser.find_by_css(module_css)) # Disable the jquery animation for the transition to the menus. world.disable_jquery_animations() world.css_click(component_button_css) if category in ('problem', 'html', 'advanced'): world.wait_for_invisible(component_button_css) click_component_from_menu(category, component_type, is_advanced) expected_count = module_count_before + 1 world.wait_for( lambda _: len(world.css_find(module_css)) == expected_count, timeout=20 )
def i_created_a_video_with_subs_with_name(_step, sub_id): _step.given('I have created a Video component') # Store the current URL so we can return here video_url = world.browser.url # Upload subtitles for the video using the upload interface _step.given('I have uploaded subtitles "{}"'.format(sub_id)) # Return to the video world.visit(video_url) world.wait_for_xmodule() # update .sub filed with proper subs name (which mimics real Studio/XML behavior) # this is needed only for that videos which are created in acceptance tests. _step.given('I edit the component') world.wait_for_ajax_complete() _step.given('I save changes') world.disable_jquery_animations() world.wait_for_present('.is-initialized') world.wait_for_invisible(SELECTORS['spinner'])