<commit_before>#pylint: disable=C0111
#pylint: disable=W0621

from lettuce import world, step
from nose.tools import assert_true, assert_in, assert_equal  # pylint: disable=E0611
from common import create_studio_user, add_course_author, log_into_studio

@step(u'I am in Studio editing a new unit$')
def add_unit(step):
    world.clear_courses()
    course = world.CourseFactory.create()
    section = world.ItemFactory.create(parent_location=course.location)
    world.ItemFactory.create(
        parent_location=section.location,
        category='sequential',
        display_name='Subsection One',)
    user = create_studio_user(is_staff=False)
    add_course_author(user, course)
    log_into_studio()
    world.wait_for_requirejs([
        "jquery", "js/models/course", "coffee/src/models/module",
        "coffee/src/views/unit", "jquery.ui",
    ])
    world.wait_for_mathjax()
    css_selectors = [
        'a.course-link', 'div.section-item a.expand-collapse-icon',
        'a.new-unit-item',
    ]
    for selector in css_selectors:
        world.css_click(selector)


@step(u'I add this type of single step component:$')
def add_a_single_step_component(step):
    world.wait_for_xmodule()
    for step_hash in step.hashes:
        component = step_hash['Component']
        assert_in(component, ['Discussion', 'Video'])
        css_selector = 'a[data-type="{}"]'.format(component.lower())
        world.css_click(css_selector)


@step(u'I see this type of single step component:$')
def see_a_single_step_component(step):
    for step_hash in step.hashes:
        component = step_hash['Component']
        assert_in(component, ['Discussion', 'Video'])
        component_css = 'section.xmodule_{}Module'.format(component)
        assert_true(world.is_css_present(component_css),
                    "{} couldn't be found".format(component))


@step(u'I add this type of( Advanced)? (HTML|Problem) component:$')
def add_a_multi_step_component(step, is_advanced, category):<commit_msg>Wait between clicks for new component<commit_after>#pylint: disable=C0111
#pylint: disable=W0621

from lettuce import world, step
from nose.tools import assert_true, assert_in, assert_equal  # pylint: disable=E0611
from common import create_studio_user, add_course_author, log_into_studio

@step(u'I am in Studio editing a new unit$')
def add_unit(step):
    world.clear_courses()
    course = world.CourseFactory.create()
    section = world.ItemFactory.create(parent_location=course.location)
    world.ItemFactory.create(
        parent_location=section.location,
        category='sequential',
        display_name='Subsection One',)
    user = create_studio_user(is_staff=False)
    add_course_author(user, course)
    log_into_studio()
    world.wait_for_requirejs([
        "jquery", "js/models/course", "coffee/src/models/module",
        "coffee/src/views/unit", "jquery.ui",
    ])
    world.wait_for_mathjax()
    css_selectors = [
        'a.course-link', 'div.section-item a.expand-collapse-icon',
        'a.new-unit-item',
    ]
    for selector in css_selectors:
        world.css_click(selector)


@step(u'I add this type of single step component:$')
def add_a_single_step_component(step):
    world.wait_for_xmodule()
    for step_hash in step.hashes:
        component = step_hash['Component']
        assert_in(component, ['Discussion', 'Video'])
        css_selector = 'a[data-type="{}"]'.format(component.lower())
        world.css_click(css_selector)

	# In the current implementation, all the "new component"
	# buttons are handled by one BackBone.js view.
	# If we click two buttons at super-human speed,
	# the view will miss the second click while it's
	# processing the first.
	# To account for this, we wait for each component
	# to be created before clicking the next component.
        world.wait_for_visible('section.xmodule_{}Module'.format(component))


@step(u'I see this type of single step component:$')
def see_a_single_step_component(step):
    for step_hash in step.hashes:
        component = step_hash['Component']
        assert_in(component, ['Discussion', 'Video'])
        component_css = 'section.xmodule_{}Module'.format(component)
        assert_true(world.is_css_present(component_css),
                    "{} couldn't be found".format(component))


@step(u'I add this type of( Advanced)? (HTML|Problem) component:$')
def add_a_multi_step_component(step, is_advanced, category):
{'fraction_non_alphanumeric': 0.11601085481682497, 'fraction_numerical': 0.005427408412483039, 'mean_word_length': 3.958520179372197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4036306', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1369, 'n_words': 307}