test_studio_video_transcript.py 55 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# -*- coding: utf-8 -*-

"""
Acceptance tests for CMS Video Transcripts.

For transcripts acceptance tests there are 3 available caption
files. They can be used to test various transcripts features. Two of
them can be imported from YouTube.

The length of each file name is 11 characters. This is because the
YouTube's ID length is 11 characters. If file name is not of length 11,
front-end validation will not pass.

    t__eq_exist - this file exists on YouTube, and can be imported
                  via the transcripts menu; after import, this file will
                  be equal to the one stored locally
    t_neq_exist - same as above, except local file will differ from the
                  one stored on YouTube
    t_not_exist - this file does not exist on YouTube; it exists locally
"""
21
from nose.plugins.attrib import attr
22
from common.test.acceptance.tests.video.test_studio_video_module import CMSVideoBaseTest
23 24


25
@attr(shard=6)
26 27 28 29 30 31 32 33
class VideoTranscriptTest(CMSVideoBaseTest):
    """
    CMS Video Transcript Test Class
    """

    def setUp(self):
        super(VideoTranscriptTest, self).setUp()

34
    def _create_video_component(self, subtitles=False, subtitle_id='3_yD_cEKoCk'):
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
        """
        Create a video component and navigate to unit page

        Arguments:
            subtitles (bool): Upload subtitles or not
            subtitle_id (str): subtitle file id

        """
        if subtitles:
            self.assets.append('subs_{}.srt.sjson'.format(subtitle_id))

        self.navigate_to_course_unit()

    def test_input_validation(self):
        """
        Scenario: Check input error messages
        Given I have created a Video component
52

53 54 55
        Entering "123.webm" and "456.webm" source to field number 1 and 2 respectively should disable field 1 and 3
        Then I see error message "Link types should be unique."
        When I clear fields, input fields should be enabled
56

57 58
        And I enter a "http://link.c" source to field number 1 should disable fields 2 and 3
        Then I see error message "Incorrect url format."
59

60 61 62
        Entering "http://goo.gl/pxxZrg" source to both field number 1 and 2 should disable fields 1 and 3
        Then I see error message "Links should be unique."
        When I clear fields, input fields should be enabled
63

64 65 66 67 68 69
        And I enter a "http://youtu.be/t_not_exist" source to field number 1
        Then I do not see error message
        And I expect inputs are enabled
        """
        self._create_video_component()
        self.edit_component()
70

71 72 73 74
        #User inputs html5 links with equal extension
        self.video.set_url_field('123.webm', 1)
        self.video.set_url_field('456.webm', 2)
        self.assertEqual(self.video.message('error'), 'Link types should be unique.')
75

76 77 78 79 80 81
        # Currently we are working with 2nd field. It means, that if 2nd field
        # contain incorrect value, 1st and 3rd fields should be disabled until
        # 2nd field will be filled by correct correct value
        self.assertEqual(self.video.url_field_status(1, 3).values(), [False, False])
        self.video.clear_fields()
        self.assertEqual(self.video.url_field_status().values(), [True, True, True])
82

83 84 85 86
        #User input URL with incorrect format
        self.video.set_url_field('http://link.c', 1)
        self.assertEqual(self.video.message('error'), 'Incorrect url format.')
        self.assertEqual(self.video.url_field_status(2, 3).values(), [False, False])
87

88 89 90 91 92 93 94
        #User input URL with incorrect format
        self.video.set_url_field('http://goo.gl/pxxZrg', 1)
        self.video.set_url_field('http://goo.gl/pxxZrg', 2)
        self.assertEqual(self.video.message('error'), 'Links should be unique.')
        self.assertEqual(self.video.url_field_status(1, 3).values(), [False, False])
        self.video.clear_fields()
        self.assertEqual(self.video.url_field_status().values(), [True, True, True])
95

96 97 98 99 100 101 102 103
        self.video.set_url_field('http://youtu.be/t_not_exist', 1)
        self.assertEqual(self.video.message('error'), '')
        self.assertEqual(self.video.url_field_status().values(), [True, True, True])

    def test_youtube_server_interaction(self):
        """
        Scenario: Testing interaction with test youtube server
        Given I have created a Video component with subtitles
104

105 106 107
        And I enter a "http://youtu.be/t__eq_exist" source to field number 1
        Then I see status message "No EdX Timed Transcript"
        And I see button "import"
108

109 110 111 112 113 114 115
        And I enter a "http://youtu.be/t_not_exist" source to field number 1
        Then I see status message "No Timed Transcript"
        And I do not see button "import"
        And I see button "disabled_download_to_edit"
        """
        self._create_video_component(subtitles=True)
        self.edit_component()
116

117 118 119 120 121
        # first part of url will be substituted by mock_youtube_server address
        # for t__eq_exist id server will respond with transcripts
        self.video.set_url_field('http://youtu.be/t__eq_exist', 1)
        self.assertEqual(self.video.message('status'), 'No EdX Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('import'))
122

123 124 125 126 127 128 129 130 131
        self.video.set_url_field('http://youtu.be/t_not_exist', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.assertFalse(self.video.is_transcript_button_visible('import'))
        self.assertTrue(self.video.is_transcript_button_visible('disabled_download_to_edit'))

    def test_youtube_id_w_found_state(self):
        """
        Scenario: Youtube id only: check "Found" state
        Given I have created a Video component with subtitles "t_not_exist"
132

133 134 135 136 137 138
        And I enter a "http://youtu.be/t_not_exist" source to field number 1
        Then I see status message "Timed Transcript Found"
        And I see value "t_not_exist" in the field "Default Timed Transcript"
        """
        self._create_video_component(subtitles=True, subtitle_id='t_not_exist')
        self.edit_component()
139

140 141 142 143 144 145 146 147 148
        self.video.set_url_field('http://youtu.be/t_not_exist', 1)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 't_not_exist'))

    def test_youtube_id_w_same_local_server_subs(self):
        """
        Scenario: Youtube id only: check "Found" state when user sets youtube_id with same local and server subs
        Given I have created a Video component with subtitles "t__eq_exist"
149

150 151 152 153 154 155
        And I enter a "http://youtu.be/t__eq_exist" source to field number 1
        And I see status message "Timed Transcript Found"
        And I see value "t__eq_exist" in the field "Default Timed Transcript"
        """
        self._create_video_component(subtitles=True, subtitle_id='t__eq_exist')
        self.edit_component()
156

157 158 159 160 161 162 163 164 165
        self.video.set_url_field('http://youtu.be/t__eq_exist', 1)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 't__eq_exist'))

    def test_youtube_id_w_different_local_server_sub(self):
        """
        Scenario: Youtube id only: check "Found" state when user sets youtube_id with different local and server subs
        Given I have created a Video component with subtitles "t_neq_exist"
166

167 168 169 170 171 172 173 174 175
        And I enter a "http://youtu.be/t_neq_exist" source to field number 1
        And I see status message "Timed Transcript Conflict"
        And I see button "replace"
        And I click transcript button "replace"
        And I see status message "Timed Transcript Found"
        And I see value "t_neq_exist" in the field "Default Timed Transcript"
        """
        self._create_video_component(subtitles=True, subtitle_id='t_neq_exist')
        self.edit_component()
176

177 178 179
        self.video.set_url_field('http://youtu.be/t_neq_exist', 1)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Conflict')
        self.assertTrue(self.video.is_transcript_button_visible('replace'))
180
        self.video.click_button_subtitles()
181 182 183 184 185 186 187 188
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 't_neq_exist'))

    def test_html5_source_w_not_found_state(self):
        """
        Scenario: html5 source only: check "Not Found" state
        Given I have created a Video component
189

190 191 192 193 194 195
        And I enter a "t_not_exist.mp4" source to field number 1
        Then I see status message "No Timed Transcript"
        And I see value "" in the field "Default Timed Transcript"
        """
        self._create_video_component()
        self.edit_component()
196

197 198 199 200 201 202 203 204 205
        self.video.set_url_field('t_not_exist.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', ''))

    def test_html5_source_w_found_state(self):
        """
        Scenario: html5 source only: check "Found" state
        Given I have created a Video component with subtitles "t_not_exist"
206

207 208 209 210 211 212
        And I enter a "t_not_exist.mp4" source to field number 1
        Then I see status message "Timed Transcript Found"
        And I see value "t_not_exist" in the field "Default Timed Transcript"
        """
        self._create_video_component(subtitles=True, subtitle_id='t_not_exist')
        self.edit_component()
213

214 215 216 217 218 219 220 221 222
        self.video.set_url_field('t_not_exist.mp4', 1)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 't_not_exist'))

    def test_set_youtube_id_wo_server(self):
        """
        Scenario: User sets youtube_id w/o server but with local subs and one html5 link w/o subs
        Given I have created a Video component with subtitles "t_not_exist"
223

224 225 226 227 228 229 230 231
        urls = ['http://youtu.be/t_not_exist', 'test_video_name.mp4']
        for each url in urls do the following
            Enter `url` to field number n
            Status message "Timed Transcript Found" is shown
        And I see value "t_not_exist" in the field "Default Timed Transcript"
        """
        self._create_video_component(subtitles=True, subtitle_id='t_not_exist')
        self.edit_component()
232

233 234 235 236 237 238 239 240 241 242 243 244 245
        urls = ['http://youtu.be/t_not_exist', 'test_video_name.mp4']
        for index, url in enumerate(urls, 1):
            self.video.set_url_field(url, index)
            self.assertEqual(self.video.message('status'), 'Timed Transcript Found')

        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 't_not_exist'))

    def test_set_youtube_id_wo_local(self):
        """
        Scenario: User sets youtube_id w/o local but with server subs and one html5 link w/o
                  transcripts w/o import action, then another one html5 link w/o transcripts
        Given I have created a Video component
246

247 248 249 250 251 252 253 254
        urls = ['http://youtu.be/t__eq_exist', 't_not_exist.mp4', 't_not_exist.webm']
        for each url in urls do the following
            Enter `url` to field number `n`
            Status message `No EdX Timed Transcript` is shown
            `import` and `upload_new_timed_transcripts` are shown
        """
        self._create_video_component()
        self.edit_component()
255

256 257 258 259 260 261
        urls = ['http://youtu.be/t__eq_exist', 't_not_exist.mp4', 't_not_exist.webm']
        for index, url in enumerate(urls, 1):
            self.video.set_url_field(url, index)
            self.assertEqual(self.video.message('status'), 'No EdX Timed Transcript')
            self.assertTrue(self.video.is_transcript_button_visible('import'))
            self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
262 263 264 265 266

    def test_youtube_no_import(self):
        """
        Scenario: Entering youtube (no importing), and 2 html5 sources without transcripts - "Not Found"
        Given I have created a Video component
267

268 269 270 271 272 273 274 275
        urls = ['http://youtu.be/t_not_exist', 't_not_exist.mp4', 't_not_exist.webm']
        for each url in urls do the following
            Enter `url` to field number `n`
            Status message `No Timed Transcript` is shown
            `disabled_download_to_edit` and `upload_new_timed_transcripts` buttons are shown
        """
        self._create_video_component()
        self.edit_component()
276

277 278 279 280 281 282 283 284 285 286 287
        urls = ['http://youtu.be/t_not_exist', 't_not_exist.mp4', 't_not_exist.webm']
        for index, url in enumerate(urls, 1):
            self.video.set_url_field(url, index)
            self.assertEqual(self.video.message('status'), 'No Timed Transcript')
            self.assertTrue(self.video.is_transcript_button_visible('disabled_download_to_edit'))
            self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))

    def test_youtube_with_import(self):
        """
        Scenario: Entering youtube with imported transcripts, and 2 html5 sources without transcripts - "Found"
        Given I have created a Video component
288

289 290 291 292 293 294
        And I enter a "http://youtu.be/t__eq_exist" source to field number 1
        Then I see status message "No EdX Timed Transcript"
        And I see button "import"
        And I click transcript button "import"
        Then I see status message "Timed Transcript Found"
        And I see button "upload_new_timed_transcripts"
295

296 297 298 299 300 301 302 303
        urls = ['t_not_exist.mp4', 't_not_exist.webm']
        for each url in urls do the following
            Enter `url` to field number `n`
            Status message `Timed Transcript Found` is shown
            `download_to_edit` and `upload_new_timed_transcripts` buttons are shown
        """
        self._create_video_component()
        self.edit_component()
304

305 306 307 308 309 310
        self.video.set_url_field('http://youtu.be/t__eq_exist', 1)
        self.assertEqual(self.video.message('status'), 'No EdX Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('import'))
        self.video.click_button('import')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
311

312 313 314 315 316 317 318 319 320 321 322
        urls = ['t_not_exist.mp4', 't_not_exist.webm']
        for index, url in enumerate(urls, 2):
            self.video.set_url_field(url, index)
            self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
            self.assertTrue(self.video.is_transcript_button_visible('download_to_edit'))
            self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))

    def test_youtube_wo_transcripts(self):
        """
        Scenario: Entering youtube w/o transcripts - html5 w/o transcripts - html5 with transcripts
        Given I have created a Video component with subtitles "t_neq_exist"
323

324 325 326 327 328 329 330 331 332 333 334 335
        urls = ['http://youtu.be/t_not_exist', 't_not_exist.mp4']
        for each url in urls do the following
            Enter `url` to field number `n`
            Status message `No Timed Transcript` is shown
            `disabled_download_to_edit` and `upload_new_timed_transcripts` buttons are shown

        And I enter a "t_neq_exist.webm" source to field number 3
        Then I see status message "Timed Transcript Found"
        `download_to_edit` and `upload_new_timed_transcripts` buttons are shown
        """
        self._create_video_component(subtitles=True, subtitle_id='t_neq_exist')
        self.edit_component()
336

337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
        urls = ['http://youtu.be/t_not_exist', 't_not_exist.mp4']
        for index, url in enumerate(urls, 1):
            self.video.set_url_field(url, index)
            self.assertEqual(self.video.message('status'), 'No Timed Transcript')
            self.assertTrue(self.video.is_transcript_button_visible('disabled_download_to_edit'))
            self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))

        self.video.set_url_field('t_neq_exist.webm', 3)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.assertTrue(self.video.is_transcript_button_visible('download_to_edit'))
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))

    def test_youtube_wo_imported_transcripts(self):
        """
        Scenario: Entering youtube w/o imported transcripts - html5 w/o transcripts w/o import - html5 with transcripts
        Given I have created a Video component with subtitles "t_neq_exist"
353

354 355 356 357 358 359 360 361
        urls = ['http://youtu.be/t__eq_exist', 't_not_exist.mp4', 't_neq_exist.webm']
        for each url in urls do the following
            Enter `url` to field number `n`
            Status message `No EdX Timed Transcript` is shown
            `import` and `upload_new_timed_transcripts` buttons are shown
        """
        self._create_video_component(subtitles=True, subtitle_id='t_neq_exist')
        self.edit_component()
362

363 364 365 366 367 368 369 370 371 372 373
        urls = ['http://youtu.be/t__eq_exist', 't_not_exist.mp4', 't_neq_exist.webm']
        for index, url in enumerate(urls, 1):
            self.video.set_url_field(url, index)
            self.assertEqual(self.video.message('status'), 'No EdX Timed Transcript')
            self.assertTrue(self.video.is_transcript_button_visible('import'))
            self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))

    def test_youtube_wo_imported_transcripts2(self):
        """
        Scenario: Entering youtube w/o imported transcripts - html5 with transcripts - html5 w/o transcripts w/o import
        Given I have created a Video component with subtitles "t_neq_exist"
374

375 376 377 378 379 380 381 382
        urls = ['http://youtu.be/t__eq_exist', 't_neq_exist.mp4', 't_not_exist.webm']
        for each url in urls do the following
            Enter `url` to field number `n`
            Status message `No EdX Timed Transcript` is shown
            `import` and `upload_new_timed_transcripts` buttons are shown
        """
        self._create_video_component(subtitles=True, subtitle_id='t_neq_exist')
        self.edit_component()
383

384 385 386 387 388 389 390 391 392 393 394
        urls = ['http://youtu.be/t__eq_exist', 't_neq_exist.mp4', 't_not_exist.webm']
        for index, url in enumerate(urls, 1):
            self.video.set_url_field(url, index)
            self.assertEqual(self.video.message('status'), 'No EdX Timed Transcript')
            self.assertTrue(self.video.is_transcript_button_visible('import'))
            self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))

    def test_youtube_w_imported_transcripts(self):
        """
        Scenario: Entering youtube with imported transcripts - html5 with transcripts - html5 w/o transcripts
        Given I have created a Video component with subtitles "t_neq_exist"
395

396 397 398 399 400 401
        And I enter a "http://youtu.be/t__eq_exist" source to field number 1
        Then I see status message "No EdX Timed Transcript"
        And I see button "import"
        And I click transcript button "import"
        Then I see status message "Timed Transcript Found"
        And I see button "upload_new_timed_transcripts"
402

403 404 405 406 407 408 409 410
        urls = ['t_neq_exist.mp4', 't_not_exist.webm']
        for each url in urls do the following
            Enter `url` to field number `n`
            Status message `Timed Transcript Found` is shown
            `download_to_edit` and `upload_new_timed_transcripts` buttons are shown
        """
        self._create_video_component(subtitles=True, subtitle_id='t_neq_exist')
        self.edit_component()
411

412 413 414 415 416 417
        self.video.set_url_field('http://youtu.be/t__eq_exist', 1)
        self.assertEqual(self.video.message('status'), 'No EdX Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('import'))
        self.video.click_button('import')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
418

419 420 421 422 423 424 425 426 427 428 429
        urls = ['t_neq_exist.mp4', 't_not_exist.webm']
        for index, url in enumerate(urls, 2):
            self.video.set_url_field(url, index)
            self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
            self.assertTrue(self.video.is_transcript_button_visible('download_to_edit'))
            self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))

    def test_youtube_w_imported_transcripts2(self):
        """
        Scenario: Entering youtube with imported transcripts - html5 w/o transcripts - html5 with transcripts
        Given I have created a Video component with subtitles "t_neq_exist"
430

431 432 433 434 435 436
        And I enter a "http://youtu.be/t__eq_exist" source to field number 1
        Then I see status message "No EdX Timed Transcript"
        And I see button "import"
        And I click transcript button "import"
        Then I see status message "Timed Transcript Found"
        And I see button "upload_new_timed_transcripts"
437

438 439 440 441 442 443 444 445
        urls = ['t_not_exist.mp4', 't_neq_exist.webm']
        for each url in urls do the following
            Enter `url` to field number `n`
            Status message `Timed Transcript Found` is shown
            `download_to_edit` and `upload_new_timed_transcripts` buttons are shown
        """
        self._create_video_component(subtitles=True, subtitle_id='t_neq_exist')
        self.edit_component()
446

447 448 449 450 451 452
        self.video.set_url_field('http://youtu.be/t__eq_exist', 1)
        self.assertEqual(self.video.message('status'), 'No EdX Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('import'))
        self.video.click_button('import')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
453

454 455 456 457 458 459 460 461 462 463 464
        urls = ['t_not_exist.mp4', 't_neq_exist.webm']
        for index, url in enumerate(urls, 2):
            self.video.set_url_field(url, index)
            self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
            self.assertTrue(self.video.is_transcript_button_visible('download_to_edit'))
            self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))

    def test_html5_with_transcripts(self):
        """
        Scenario: Entering html5 with transcripts - upload - youtube w/o transcripts
        Given I have created a Video component with subtitles "t__eq_exist"
465

466 467 468 469 470 471 472
        And I enter a "t__eq_exist.mp4" source to field number 1
        Then I see status message "Timed Transcript Found"
        `download_to_edit` and `upload_new_timed_transcripts` buttons are shown
        And I upload the transcripts file "uk_transcripts.srt"
        Then I see status message "Timed Transcript Uploaded Successfully"
        `download_to_edit` and `upload_new_timed_transcripts` buttons are shown
        And I see value "t__eq_exist" in the field "Default Timed Transcript"
473

474 475 476
        And I enter a "http://youtu.be/t_not_exist" source to field number 2
        Then I see status message "Timed Transcript Found"
        `download_to_edit` and `upload_new_timed_transcripts` buttons are shown
477

478 479 480 481 482
        And I enter a "uk_transcripts.webm" source to field number 3
        Then I see status message "Timed Transcript Found"
        """
        self._create_video_component(subtitles=True, subtitle_id='t__eq_exist')
        self.edit_component()
483

484 485 486 487 488 489 490 491 492 493 494
        self.video.set_url_field('t__eq_exist.mp4', 1)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.assertTrue(self.video.is_transcript_button_visible('download_to_edit'))
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
        self.video.upload_transcript('uk_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.assertTrue(self.video.is_transcript_button_visible('download_to_edit'))
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 't__eq_exist'))
        self.open_basic_tab()
495

496 497 498 499
        self.video.set_url_field('http://youtu.be/t_not_exist', 2)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.assertTrue(self.video.is_transcript_button_visible('download_to_edit'))
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
500

501 502 503 504 505 506 507
        self.video.set_url_field('uk_transcripts.webm', 3)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')

    def test_two_html5_sources_w_transcripts(self):
        """
        Scenario: Enter 2 HTML5 sources with transcripts, they are not the same, choose
        Given I have created a Video component with subtitles "t_not_exist"
508

509 510 511 512 513 514
        And I enter a "uk_transcripts.mp4" source to field number 1
        Then I see status message "No Timed Transcript"
        `download_to_edit` and `upload_new_timed_transcripts` buttons are shown
        And I upload the transcripts file "uk_transcripts.srt"
        Then I see status message "Timed Transcript Uploaded Successfully"
        And I see value "uk_transcripts" in the field "Default Timed Transcript"
515

516 517 518 519 520 521 522 523
        And I enter a "t_not_exist.webm" source to field number 2
        Then I see status message "Timed Transcript Conflict"
        `Timed Transcript from uk_transcripts.mp4` and `Timed Transcript from t_not_exist.webm` buttons are shown
        And I click transcript button "Timed Transcript from t_not_exist.webm"
        And I see value "uk_transcripts|t_not_exist" in the field "Default Timed Transcript"
        """
        self._create_video_component(subtitles=True, subtitle_id='t_not_exist')
        self.edit_component()
524

525 526 527 528 529 530 531 532 533
        self.video.set_url_field('uk_transcripts.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('download_to_edit'))
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
        self.video.upload_transcript('uk_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'uk_transcripts'))
        self.open_basic_tab()
534

535 536 537 538 539 540 541 542 543
        self.video.set_url_field('t_not_exist.webm', 2)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Conflict')
        self.assertTrue(
            self.video.is_transcript_button_visible('choose', button_text='Timed Transcript from uk_transcripts.mp4'))
        self.assertTrue(self.video.is_transcript_button_visible('choose', index=1,
                                                                button_text='Timed Transcript from t_not_exist.webm'))

    def test_one_field_only(self):
        """
544 545 546 547
        Scenario: Work with 1 field only: Enter HTML5 source with transcripts - save -> change it to another one
                  HTML5 source w/o transcripts - click on use existing ->  change it to another one HTML5 source
                  w/o transcripts - do not click on use existing -> change it to another one HTML5 source w/o
                  transcripts - click on use existing
548
        Given I have created a Video component with subtitles "t_not_exist"
549

550 551 552 553
        If i enter "t_not_exist.mp4" source to field number 1 Then I see status message "Timed Transcript Found"
        `download_to_edit` and `upload_new_timed_transcripts` buttons are shown
        And I see value "t_not_exist" in the field "Default Timed Transcript"
        And I save changes And then edit the component
554

555 556 557
        If i enter "video_name_2.mp4" source to field number 1 Then I see status message "Confirm Timed Transcript"
        I see button "use_existing" And I click on it
        And I see value "video_name_2" in the field "Default Timed Transcript"
558

559 560
        If i enter "video_name_3.mp4" source to field number 1 Then I see status message "Confirm Timed Transcript"
        And I see button "use_existing"
561

562 563 564 565 566 567
        If i enter a "video_name_4.mp4" source to field number 1 Then I see status message "Confirm Timed Transcript"
        I see button "use_existing" And I click on it
        And I see value "video_name_4" in the field "Default Timed Transcript"
        """
        self._create_video_component(subtitles=True, subtitle_id='t_not_exist')
        self.edit_component()
568

569 570 571 572 573 574 575 576 577
        self.video.set_url_field('t_not_exist.mp4', 1)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.assertTrue(self.video.is_transcript_button_visible('download_to_edit'))
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 't_not_exist'))
        self.open_basic_tab()
        self.save_unit_settings()
        self.edit_component()
578

579 580 581 582 583 584 585 586
        self.video.set_url_field('video_name_2.mp4', 1)
        self.assertEqual(self.video.message('status'), 'Confirm Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('use_existing'))
        self.video.click_button('use_existing')
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'video_name_2'))
        self.open_basic_tab()
587

588 589 590
        self.video.set_url_field('video_name_3.mp4', 1)
        self.assertEqual(self.video.message('status'), 'Confirm Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('use_existing'))
591

592 593 594 595 596 597 598 599 600 601
        self.video.set_url_field('video_name_4.mp4', 1)
        self.assertEqual(self.video.message('status'), 'Confirm Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('use_existing'))
        self.video.click_button('use_existing')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'video_name_4'))

    def test_two_fields_only(self):
        """
        Scenario: Work with 2 fields: Enter HTML5 source with transcripts - save -> change it to another one HTML5
602 603
                  source w/o transcripts - do not click on use existing ->  add another one HTML5 source w/o
                  transcripts - click on use existing
604
        Given I have created a Video component with subtitles "t_not_exist"
605

606 607 608 609 610
        And I enter a "t_not_exist.mp4" source to field number 1
        Then I see status message "Timed Transcript Found"
       `download_to_edit` and `upload_new_timed_transcripts` buttons are shown
        And I save changes
        And I edit the component
611

612 613 614
        And I enter a "video_name_2.mp4" source to field number 1
        Then I see status message "Confirm Timed Transcript"
        And I see button "use_existing"
615

616 617 618 619 620 621 622 623
        And I enter a "video_name_3.webm" source to field number 2
        Then I see status message "Confirm Timed Transcript"
        And I see button "use_existing"
        And I click transcript button "use_existing"
        And I see value "video_name_3" in the field "Default Timed Transcript"
        """
        self._create_video_component(subtitles=True, subtitle_id='t_not_exist')
        self.edit_component()
624

625 626 627 628 629 630
        self.video.set_url_field('t_not_exist.mp4', 1)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.assertTrue(self.video.is_transcript_button_visible('download_to_edit'))
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
        self.save_unit_settings()
        self.edit_component()
631

632 633 634
        self.video.set_url_field('video_name_2.mp4', 1)
        self.assertEqual(self.video.message('status'), 'Confirm Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('use_existing'))
635

636 637 638 639 640 641 642 643 644 645 646
        self.video.set_url_field('video_name_3.webm', 2)
        self.assertEqual(self.video.message('status'), 'Confirm Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('use_existing'))
        self.video.click_button('use_existing')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'video_name_3'))

    def test_upload_subtitles(self):
        """
        Scenario: File name and name of subs are different (Uploading subtitles with different file name than file)
        Given I have created a Video component
647

648 649 650 651 652 653 654 655 656 657 658 659
        And I enter a "video_name_1.mp4" source to field number 1
        And I see status message "No Timed Transcript"
        And I upload the transcripts file "uk_transcripts.srt"
        Then I see status message "Timed Transcript Uploaded Successfully"
        And I see value "video_name_1" in the field "Default Timed Transcript"
        And I save changes
        Then when I view the video it does show the captions
        And I edit the component
        Then I see status message "Timed Transcript Found"
        """
        self._create_video_component()
        self.edit_component()
660

661 662 663 664 665 666 667 668 669 670 671 672 673 674
        self.video.set_url_field('video_name_1.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.video.upload_transcript('uk_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'video_name_1'))
        self.save_unit_settings()
        self.video.is_captions_visible()
        self.edit_component()
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')

    def test_video_wo_subtitles(self):
        """
        Scenario: Video w/o subs - another video w/o subs - Not found message
675 676 677
                  Video can have filled item.sub, but doesn't have subs file.
                  In this case, after changing this video by another one without subs
                  `No Timed Transcript` message should appear ( not 'Confirm Timed Transcript').
678
        Given I have created a Video component
679

680 681 682 683 684
        And I enter a "video_name_1.mp4" source to field number 1
        Then I see status message "No Timed Transcript"
        """
        self._create_video_component()
        self.edit_component()
685

686 687
        self.video.set_url_field('video_name_1.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058

    def test_subtitles_copy(self):
        """
        Scenario: Subtitles are copied for every html5 video source
        Given I have created a Video component

        After I enter a "video_name_1.mp4" source to field number 1 Then I see status message "No Timed Transcript"

        After I enter a "video_name_2.webm" source to field number 2 Then I see status message "No Timed Transcript"
        After uploading transcript "uk_transcripts.srt" I should see message "Timed Transcript Uploaded Successfully"
        And I see value "video_name_2" in the field "Default Timed Transcript"
        When I clear field number 1 Then I see status message "Timed Transcript Found"
        And I see value "video_name_2" in the field "Default Timed Transcript"
        """
        self._create_video_component()
        self.edit_component()

        self.video.set_url_field('video_name_1.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')

        self.video.set_url_field('video_name_2.webm', 2)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.video.upload_transcript('uk_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'video_name_2'))
        self.open_basic_tab()
        self.video.clear_field(1)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'video_name_2'))

    def test_upload_button_w_youtube(self):
        """
        Scenario: Upload button for single youtube id
        Given I have created a Video component

        After I enter a "http://youtu.be/t_not_exist" source to field number 1 I see message "No Timed Transcript"
        And I see button "upload_new_timed_transcripts"
        After I upload the transcripts file "uk_transcripts.srt" I see message "Timed Transcript Uploaded Successfully"
        After saving the changes video captions should be visible
        When I edit the component Then I see status message "Timed Transcript Found"
        """
        self._create_video_component()
        self.edit_component()

        self.video.set_url_field('http://youtu.be/t_not_exist', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
        self.video.upload_transcript('uk_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.save_unit_settings()
        self.assertTrue(self.video.is_captions_visible())
        self.edit_component()
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')

    def test_upload_button_w_html5_ids(self):
        """
        Scenario: Upload button for youtube id with html5 ids
        Given I have created a Video component

        After I enter a "http://youtu.be/t_not_exist" source to field number 1 I see message "No Timed Transcript"
        And I see button "upload_new_timed_transcripts"

        After I enter a "video_name_1.mp4" source to field number 2 Then I see status message "No Timed Transcript"
        And I see button "upload_new_timed_transcripts"
        After I upload the transcripts file "uk_transcripts.srt"I see message "Timed Transcript Uploaded Successfully"
        When I clear field number 1 Then I see status message "Timed Transcript Found"
        And I see value "video_name_1" in the field "Default Timed Transcript"
        After saving the changes video captions should be visible
        When I edit the component Then I see status message "Timed Transcript Found"
        """
        self._create_video_component()
        self.edit_component()

        self.video.set_url_field('http://youtu.be/t_not_exist', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))

        self.video.set_url_field('video_name_1.mp4', 2)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.assertTrue(self.video.is_transcript_button_visible('upload_new_timed_transcripts'))
        self.video.upload_transcript('uk_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.video.clear_field(1)
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'video_name_1'))
        self.save_unit_settings()
        self.assertTrue(self.video.is_captions_visible())
        self.edit_component()
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')

    def test_advanced_tab_transcript_fields(self):
        """
        Scenario: Change transcripts field in Advanced tab
        Given I have created a Video component with subtitles "t_not_exist"

        After I enter a "video_name_1.mp4" source to field number 1  Then I see status message "No Timed Transcript"
        Open tab "Advanced" and set value "t_not_exist" to the field "Default Timed Transcript"
        After saving the changes video captions should be visible
        When I edit the component Then I see status message "Timed Transcript Found"
        And I see value "video_name_1" in the field "Default Timed Transcript"
        """
        self._create_video_component(subtitles=True, subtitle_id='t_not_exist')
        self.edit_component()

        self.video.set_url_field('video_name_1.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.open_advanced_tab()
        self.video.set_field_value('Default Timed Transcript', 't_not_exist')
        self.save_unit_settings()
        self.assertTrue(self.video.is_captions_visible())
        self.edit_component()
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'video_name_1'))

    def test_non_ascii_transcripts(self):
        """
        Scenario: Check non-ascii (chinese) transcripts
        Given I have created a Video component

        After I enter a "video_name_1.mp4" source to field number 1 Then I see status message "No Timed Transcript"
        After I upload the transcripts "chinese_transcripts.srt" I see message "Timed Transcript Uploaded Successfully"
        After saving the changes video captions should be visible
        """
        self._create_video_component()
        self.edit_component()

        self.video.set_url_field('video_name_1.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.video.upload_transcript('chinese_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.save_unit_settings()
        self.assertTrue(self.video.is_captions_visible())

    def test_module_metadata_save(self):
        """
        Scenario: Check saving module metadata on switching between tabs
        Given I have created a Video component with subtitles "t_not_exist"

        After I enter a "video_name_1.mp4" source to field number 1 I should see status message "No Timed Transcript"
        Open tab "Advanced" and set value "t_not_exist" to the field "Default Timed Transcript"
        When I open tab "Basic" Then I see status message "Timed Transcript Found"
        After saving the changes video captions should be visible
        When I edit the component I should see status message "Timed Transcript Found"
        And I see value "video_name_1" in the field "Default Timed Transcript"
        """
        self._create_video_component(subtitles=True, subtitle_id='t_not_exist')
        self.edit_component()

        self.video.set_url_field('video_name_1.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.open_advanced_tab()
        self.video.set_field_value('Default Timed Transcript', 't_not_exist')
        self.open_basic_tab()
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.save_unit_settings()
        self.assertTrue(self.video.is_captions_visible())
        self.edit_component()
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'video_name_1'))

    def test_clearing_transcripts_wo_save(self):
        """
        Scenario: After clearing Transcripts field in the Advanced tab "not found" message should be visible w/o saving
        Given I have created a Video component

        After I enter a "t_not_exist.mp4" source to field number 1 I should see status message "No Timed Transcript"
        After uploading transcripts "chinese_transcripts.srt" I see message "Timed Transcript Uploaded Successfully"
        Open tab "Advanced" and set value "" to the field "Default Timed Transcript"
        When I open tab "Basic" I see status message "No Timed Transcript"
        After saving the changes video captions should not be visible
        When I edit the component I should see status message "No Timed Transcript"
        And I see value "" in the field "Default Timed Transcript"
        """
        self._create_video_component()
        self.edit_component()

        self.video.set_url_field('t_not_exist.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.video.upload_transcript('chinese_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.open_advanced_tab()
        self.video.set_field_value('Default Timed Transcript', '')
        self.open_basic_tab()
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.save_unit_settings()
        self.assertFalse(self.video.is_captions_visible())
        self.edit_component()
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', ''))

    def test_clearing_transcripts_w_save(self):
        """
        Scenario: After clearing Transcripts field in the Advanced tab "not found" message should be visible with saving
        Given I have created a Video component

        After I enter a "t_not_exist.mp4" source to field number 1 I see status message "No Timed Transcript"
        After uploading the transcripts "chinese_transcripts.srt" I see message "Timed Transcript Uploaded Successfully"
        After saving changes I see "好 各位同学" text in the captions
        And I edit the component
        Open tab "Advanced" I set value "" to the field "Default Timed Transcript"
        When I open tab "Basic" I see status message "No Timed Transcript"
        After saving the changes video captions should not be visible
        After I edit the component I should see status message "No Timed Transcript"
        And I see value "" in the field "Default Timed Transcript"
        """
        self._create_video_component()
        self.edit_component()

        self.video.set_url_field('t_not_exist.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.video.upload_transcript('chinese_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.save_unit_settings()
        unicode_text = "好 各位同学".decode('utf-8')
        self.assertIn(unicode_text, self.video.captions_text)
        self.edit_component()
        self.open_advanced_tab()
        self.video.set_field_value('Default Timed Transcript', '')
        self.open_basic_tab()
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.save_unit_settings()
        self.assertFalse(self.video.is_captions_visible())
        self.edit_component()
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', ''))

    def test_video_w_existing_subtitles(self):
        """
        Scenario: Video with existing subs - Advanced tab - change to another one subs -
                  Basic tab - Found message - Save - see correct subs
        Given I have created a Video component with subtitles "t_not_exist"

        After I enter a "video_name_1.mp4" source to field number 1 I see status message "No Timed Transcript"
        After uploading the transcripts "chinese_transcripts.srt" I see message "Timed Transcript Uploaded Successfully"
        After saving the changes video captions should be visible
        And I see "好 各位同学" text in the captions
        And I edit the component
        Open tab "Advanced" And set value "t_not_exist" to the field "Default Timed Transcript"
        When I open tab "Basic" I should see status message "Timed Transcript Found"
        After saving the changes video captions should be visible
        And I see "LILA FISHER: Hi, welcome to Edx." text in the captions
        """
        self._create_video_component(subtitles=True, subtitle_id='t_not_exist')
        self.edit_component()

        self.video.set_url_field('video_name_1.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.video.upload_transcript('chinese_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.save_unit_settings()
        self.assertTrue(self.video.is_captions_visible())
        unicode_text = "好 各位同学".decode('utf-8')
        self.assertIn(unicode_text, self.video.captions_text)
        self.edit_component()
        self.open_advanced_tab()
        self.video.set_field_value('Default Timed Transcript', 't_not_exist')
        self.open_basic_tab()
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')
        self.save_unit_settings()
        self.assertTrue(self.video.is_captions_visible())
        self.assertIn('LILA FISHER: Hi, welcome to Edx.', self.video.captions_text)

    def test_reverting_transcripts(self):
        """
        Scenario: After reverting Transcripts field in the Advanced tab "not found" message should be visible
        Given I have created a Video component

        After I enter a "t_not_exist.mp4" source to field number 1 Then I see status message "No Timed Transcript"
        After uploading transcripts "chinese_transcripts.srt" I see message "Timed Transcript Uploaded Successfully"
        After saving the changes I should see "好 各位同学" text in the captions
        After I edit the component I open tab "Advanced"
        And I revert the transcript field "Default Timed Transcript"
        After saving the changes video captions should not be visible
        After I edit the component I should see status message "No Timed Transcript"
        """
        self._create_video_component()
        self.edit_component()

        self.video.set_url_field('t_not_exist.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.video.upload_transcript('chinese_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.save_unit_settings()
        unicode_text = "好 各位同学".decode('utf-8')
        self.assertIn(unicode_text, self.video.captions_text)
        self.edit_component()
        self.open_advanced_tab()
        self.video.revert_field('Default Timed Transcript')
        self.save_unit_settings()
        self.assertFalse(self.video.is_captions_visible())
        self.edit_component()
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')

    def test_upload_subtitles_w_different_names2(self):
        """
        Scenario: File name and name of subs are different -- Uploading subtitles for file with periods
                  in it should properly set the transcript name and keep the periods
        Given I have created a Video component

        After I enter a "video_name_1.1.2.mp4" source to field number 1, I see status message "No Timed Transcript"
        After I upload the transcripts file "uk_transcripts.srt" I see message "Timed Transcript Uploaded Successfully"
        And I see value "video_name_1.1.2" in the field "Default Timed Transcript"
        After saving the changes video captions should be visible
        After I edit the component I should see status message "Timed Transcript Found"
        """
        self._create_video_component()
        self.edit_component()

        self.video.set_url_field('video_name_1.1.2.mp4', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.video.upload_transcript('uk_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'video_name_1.1.2'))
        self.save_unit_settings()
        self.assertTrue(self.video.is_captions_visible())
        self.edit_component()
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')

    def test_upload_subtitles_w_different_names3(self):
        """
        Scenario: Shortened link: File name and name of subs are different
        Given I have created a Video component

        After I enter a "http://goo.gl/pxxZrg" source to field number 1 Then I see status message "No Timed Transcript"
        After I upload the transcripts file "uk_transcripts.srt" I see message "Timed Transcript Uploaded Successfully"
        And I see value "pxxZrg" in the field "Default Timed Transcript"
        After saving the changes video captions should be visible
        After I edit the component I should see status message "Timed Transcript Found"
        """
        self._create_video_component()
        self.edit_component()

        self.video.set_url_field('http://goo.gl/pxxZrg', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.video.upload_transcript('uk_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'pxxZrg'))
        self.save_unit_settings()
        self.assertTrue(self.video.is_captions_visible())
        self.edit_component()
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')

    def test_upload_subtitles_w_different_names4(self):
        """
        Scenario: Relative link: File name and name of subs are different
        Given I have created a Video component

        After i enter a "/gizmo.webm" source to field number 1 Then I see status message "No Timed Transcript"
        After I upload the transcripts file "uk_transcripts.srt" I see message "Timed Transcript Uploaded Successfully"
        And I see value "gizmo" in the field "Default Timed Transcript"
        After saving the changes video captions should be visible
        After I edit the component I should see status message "Timed Transcript Found"
        """
        self._create_video_component()
        self.edit_component()

        self.video.set_url_field('/gizmo.webm', 1)
        self.assertEqual(self.video.message('status'), 'No Timed Transcript')
        self.video.upload_transcript('uk_transcripts.srt')
        self.assertEqual(self.video.message('status'), 'Timed Transcript Uploaded Successfully')
        self.open_advanced_tab()
        self.assertTrue(self.video.verify_field_value('Default Timed Transcript', 'gizmo'))
        self.save_unit_settings()
        self.assertTrue(self.video.is_captions_visible())
        self.edit_component()
        self.assertEqual(self.video.message('status'), 'Timed Transcript Found')