video.py 2.04 KB
Newer Older
1
# pylint: disable=missing-docstring
2 3

from lettuce import world, step
4

5 6 7 8 9
SELECTORS = {
    'spinner': '.video-wrapper .spinner',
    'controls': 'section.video-controls',
}

10 11 12
# We should wait 300 ms for event handler invocation + 200ms for safety.
DELAY = 0.5

13

14 15 16 17
@step('I have uploaded subtitles "([^"]*)"$')
def i_have_uploaded_subtitles(_step, sub_id):
    _step.given('I go to the files and uploads page')
    _step.given('I upload the test file "subs_{}.srt.sjson"'.format(sub_id.strip()))
18

19

20
@step('I have created a Video component$')
21 22
def i_created_a_video_component(step):
    step.given('I am in Studio editing a new unit')
23
    world.create_component_instance(
24
        step=step,
25
        category='video',
26 27
    )

28 29 30 31 32
    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait(DELAY)
33
    world.wait_for_invisible(SELECTORS['spinner'])
34 35
    if not world.youtube.config.get('youtube_api_blocked'):
        world.wait_for_visible(SELECTORS['controls'])
36

37

polesye committed
38 39
@step('I have created a Video component with subtitles$')
def i_created_a_video_with_subs(_step):
40
    _step.given('I have created a Video component with subtitles "3_yD_cEKoCk"')
polesye committed
41

polesye committed
42

polesye committed
43 44
@step('I have created a Video component with subtitles "([^"]*)"$')
def i_created_a_video_with_subs_with_name(_step, sub_id):
polesye committed
45
    _step.given('I have created a Video component')
46 47 48 49 50

    # Store the current URL so we can return here
    video_url = world.browser.url

    # Upload subtitles for the video using the upload interface
polesye committed
51
    _step.given('I have uploaded subtitles "{}"'.format(sub_id))
52 53 54

    # Return to the video
    world.visit(video_url)
55

56
    world.wait_for_xmodule()
57 58 59 60 61 62 63

    # 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')

64 65 66
    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
67
    world.wait_for_invisible(SELECTORS['spinner'])