@@ -4,39 +4,46 @@ import fs from "fs";
4
4
import JSZip from "jszip" ;
5
5
test . describe . configure ( { mode : "parallel" } ) ;
6
6
7
- test ( "should edit alignment and words (editor)" , async ( { page } ) => {
7
+ test ( "should edit alignment and words (editor)" , async ( { page, isMobile } ) => {
8
8
await expect ( async ( ) => {
9
- await editorDefaultBeforeEach ( page ) ;
9
+ await editorDefaultBeforeEach ( page , isMobile ) ;
10
10
} ) . toPass ( ) ;
11
11
await page . locator ( "#t0b0d0p0s0" ) . waitFor ( { state : "visible" } ) ;
12
12
//first handle
13
13
const handle = await page . getByTitle ( "-1.070" ) . locator ( "handle" ) . first ( ) ;
14
14
await handle . scrollIntoViewIfNeeded ( ) ;
15
15
const segment = await page . getByTitle ( "0.840-1.070" ) ;
16
16
await segment . click ( ) ;
17
+ await page . locator ( "#wavesurferContainer" ) . hover ( ) ;
18
+ if ( isMobile ) {
19
+ await page . mouse . wheel ( - 130 , 0 ) ;
20
+ }
21
+
17
22
const segBoxPreChange = await segment . boundingBox ( ) ;
18
23
//move the handle to the left to about 0.5
19
24
await handle . hover ( ) ;
20
25
await page . mouse . down ( ) ;
21
26
if ( segBoxPreChange )
22
27
await page . mouse . move ( segBoxPreChange . x - 100 , segBoxPreChange . y ) ;
23
28
await page . mouse . up ( ) ;
29
+
24
30
//validate the new segment width
25
- await expect (
26
- page . getByTitle ( "0.506-1.070" ) ,
27
- "should have new time code" ,
28
- ) . toHaveCount ( 1 ) ;
29
- const segBoxPostChange = await page . getByTitle ( "0.506-1.070" ) . boundingBox ( ) ;
31
+
32
+ const segBoxPostChange = await page
33
+ . locator ( "segment.wavesurfer-segment" )
34
+ . first ( )
35
+ . boundingBox ( ) ;
30
36
if ( segBoxPostChange && segBoxPreChange )
31
37
expect (
32
38
segBoxPostChange . width ,
33
39
"should be wider than the original segment" ,
34
40
) . toBeGreaterThan ( segBoxPreChange . width ) ;
35
- await page . getByTitle ( "0.506-1.070" ) . click ( ) ;
41
+ await page . locator ( "segment.wavesurfer-segment" ) . first ( ) . click ( ) ;
36
42
await expect (
37
43
page . getByTitle ( "-2.360" ) . locator ( "div" ) ,
38
44
"should contain word `Sentence`" ,
39
45
) . toContainText ( "Sentence" ) ;
46
+
40
47
const text = await page . getByTitle ( "-2.360" ) . locator ( "div" ) ;
41
48
await text . scrollIntoViewIfNeeded ( ) ;
42
49
await text . click ( ) ;
@@ -46,6 +53,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
46
53
"should now contain word `Sentences`" ,
47
54
) . toContainText ( "Sentences" ) ;
48
55
56
+ const newStartTime = await page
57
+ . locator ( "segment.wavesurfer-segment" )
58
+ . first ( )
59
+ . evaluate ( ( seg ) => ( seg as HTMLElement ) . title . substring ( 0 , 4 ) ) ;
60
+
49
61
//check web bundle output
50
62
await page . locator ( "#mat-select-value-3" ) . click ( ) ;
51
63
await page . getByRole ( "option" , { name : "Web Bundle" } ) . click ( ) ;
@@ -68,8 +80,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
68
80
"readalong file should reflect new spelling" ,
69
81
) . toMatch ( / > S e n t e n c e s < / ) ;
70
82
await expect
71
- . soft ( readalongContent , "readalong file should reflect new alignment" )
72
- . toMatch ( / t i m e = " 0 \. 5 \d + " d u r = " 0 \. 5 \d + " / ) ;
83
+ . soft (
84
+ readalongContent ,
85
+ "readalong file should reflect new alignment start time" + newStartTime ,
86
+ )
87
+ . toMatch ( new RegExp ( `time="${ newStartTime . replace ( "." , "\\." ) } \\d+" ` ) ) ;
73
88
74
89
//check SRT
75
90
await page . locator ( "#mat-select-value-3" ) . click ( ) ;
@@ -86,8 +101,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
86
101
/ S e n t e n c e s / ,
87
102
) ;
88
103
await expect
89
- . soft ( fileData , "SRT file should reflect new alignment" )
90
- . toMatch ( / 0 0 \, 5 \d + \s - - > / ) ;
104
+ . soft (
105
+ fileData ,
106
+ "SRT file should reflect new alignment start time " + newStartTime ,
107
+ )
108
+ . toMatch ( new RegExp ( `${ newStartTime . replace ( "." , "," ) } \\d+\\s-->` ) ) ;
91
109
//check WEBVTT
92
110
await page . locator ( "#mat-select-value-3" ) . click ( ) ;
93
111
await page . getByRole ( "option" , { name : "WebVTT Subtitles" } ) . click ( ) ;
@@ -100,8 +118,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
100
118
/ S e n t e n c e s / ,
101
119
) ;
102
120
await expect
103
- . soft ( fileData , "WEBVTT file should reflect new alignment" )
104
- . toMatch ( / 0 0 \. 5 \d + \s - - > / ) ;
121
+ . soft (
122
+ fileData ,
123
+ "WEBVTT file should reflect new alignment start time " + newStartTime ,
124
+ )
125
+ . toMatch ( new RegExp ( `${ newStartTime . replace ( "." , "\\." ) } \\d+\\s-->` ) ) ;
105
126
//check PRAAT
106
127
await page . locator ( "#mat-select-value-3" ) . click ( ) ;
107
128
await page . getByRole ( "option" , { name : "Praat TextGrid" } ) . click ( ) ;
@@ -114,8 +135,13 @@ test("should edit alignment and words (editor)", async ({ page }) => {
114
135
/ t e x t = " S e n t e n c e s " / ,
115
136
) ;
116
137
await expect
117
- . soft ( fileData , "PRAAT file should reflect new alignment" )
118
- . toMatch ( / x m i n = 0 \. 5 \d + / ) ;
138
+ . soft (
139
+ fileData ,
140
+ "PRAAT file should reflect new alignment start time " + newStartTime ,
141
+ )
142
+ . toMatch (
143
+ new RegExp ( `xmin\\s=\\s${ newStartTime . replace ( "." , "\\." ) } \\d+\\\s` ) ,
144
+ ) ;
119
145
//check elan
120
146
await page . locator ( "#mat-select-value-3" ) . click ( ) ;
121
147
await page . getByRole ( "option" , { name : "Elan File" } ) . click ( ) ;
@@ -128,6 +154,9 @@ test("should edit alignment and words (editor)", async ({ page }) => {
128
154
/ < A N N O T A T I O N _ V A L U E > S e n t e n c e s < \/ A N N O T A T I O N _ V A L U E > / ,
129
155
) ;
130
156
await expect
131
- . soft ( fileData , "ELAN file should reflect new alignment" )
132
- . toMatch ( / T I M E _ V A L U E = " 5 \d + " / ) ;
157
+ . soft (
158
+ fileData ,
159
+ "ELAN file should reflect new alignment start time " + newStartTime ,
160
+ )
161
+ . toMatch ( new RegExp ( `TIME_VALUE="${ newStartTime . substring ( 2 ) } \\d+" ` ) ) ;
133
162
} ) ;
0 commit comments