1
1
import { test , expect } from "@playwright/test"
2
- import { CoursePage , VideoElement } from "../util"
2
+ import { CoursePage } from "../util"
3
3
4
4
test ( "Start and end times does not exist" , async ( { page } ) => {
5
5
const course = new CoursePage ( page , "course" )
@@ -10,11 +10,16 @@ test("Start and end times does not exist", async ({ page }) => {
10
10
expect ( src ) . not . toMatch ( / .* ?e n d = .* / )
11
11
} )
12
12
13
- test ( "Start time exists" , async ( { page } ) => {
13
+ test ( "Start time exists and transcript line matches " , async ( { page } ) => {
14
14
const course = new CoursePage ( page , "course" )
15
15
await course . goto ( "resources/ocw_test_course_mit8_01f16_l01v01_360p" )
16
16
const src = await page . locator ( "iframe.vjs-tech" ) . getAttribute ( "src" )
17
17
expect ( src ) . toMatch ( / .* ?s t a r t = 1 3 .* / )
18
+
19
+ const transcriptLine = page . locator ( '.transcript-line[data-begin="12.06"]' )
20
+ await expect ( transcriptLine ) . toContainText (
21
+ "so here's our runner, and here's our road"
22
+ )
18
23
} )
19
24
20
25
test ( "End time exists" , async ( { page } ) => {
@@ -36,32 +41,3 @@ test("Start and end time exists", async ({ page }) => {
36
41
expect ( urlParams . get ( "start" ) ) . toEqual ( expectedStartTime )
37
42
expect ( urlParams . get ( "end" ) ) . toEqual ( expectedEndTime )
38
43
} )
39
-
40
- test ( "Transcripts start time matches video start time" , async ( { page } ) => {
41
- const course = new CoursePage ( page , "course" )
42
- const videoSection = new VideoElement ( page )
43
- const expectedStartTime = "13"
44
-
45
- await course . goto ( "resources/ocw_test_course_mit8_01f16_l01v01_360p" )
46
- const src = await videoSection . iframe ( ) . getAttribute ( "src" )
47
-
48
- const urlParams = new URLSearchParams ( src || "" )
49
- expect ( urlParams . get ( "start" ) ) . toEqual ( expectedStartTime )
50
-
51
- await videoSection . expectPlayerReady ( )
52
- await videoSection . playButton ( ) . click ( )
53
-
54
- const activeCaption = await videoSection . transcript
55
- . activeLine ( )
56
- . getAttribute ( "data-begin" )
57
- const nextCaption = await videoSection . transcript
58
- . nextLine ( )
59
- . getAttribute ( "data-begin" )
60
-
61
- expect ( parseFloat ( activeCaption || "0" ) ) . toBeLessThanOrEqual (
62
- parseFloat ( expectedStartTime )
63
- )
64
- expect ( parseFloat ( nextCaption || "0" ) ) . toBeGreaterThanOrEqual (
65
- parseFloat ( expectedStartTime )
66
- )
67
- } )
0 commit comments