@@ -4,39 +4,46 @@ import fs from "fs";
44import JSZip from "jszip" ;
55test . describe . configure ( { mode : "parallel" } ) ;
66
7- test ( "should edit alignment and words (editor)" , async ( { page } ) => {
7+ test ( "should edit alignment and words (editor)" , async ( { page, isMobile } ) => {
88 await expect ( async ( ) => {
9- await editorDefaultBeforeEach ( page ) ;
9+ await editorDefaultBeforeEach ( page , isMobile ) ;
1010 } ) . toPass ( ) ;
1111 await page . locator ( "#t0b0d0p0s0" ) . waitFor ( { state : "visible" } ) ;
1212 //first handle
1313 const handle = await page . getByTitle ( "-1.070" ) . locator ( "handle" ) . first ( ) ;
1414 await handle . scrollIntoViewIfNeeded ( ) ;
1515 const segment = await page . getByTitle ( "0.840-1.070" ) ;
1616 await segment . click ( ) ;
17+ await page . locator ( "#wavesurferContainer" ) . hover ( ) ;
18+ if ( isMobile ) {
19+ await page . mouse . wheel ( - 130 , 0 ) ;
20+ }
21+
1722 const segBoxPreChange = await segment . boundingBox ( ) ;
1823 //move the handle to the left to about 0.5
1924 await handle . hover ( ) ;
2025 await page . mouse . down ( ) ;
2126 if ( segBoxPreChange )
2227 await page . mouse . move ( segBoxPreChange . x - 100 , segBoxPreChange . y ) ;
2328 await page . mouse . up ( ) ;
29+
2430 //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 ( ) ;
3036 if ( segBoxPostChange && segBoxPreChange )
3137 expect (
3238 segBoxPostChange . width ,
3339 "should be wider than the original segment" ,
3440 ) . toBeGreaterThan ( segBoxPreChange . width ) ;
35- await page . getByTitle ( "0.506-1.070" ) . click ( ) ;
41+ await page . locator ( "segment.wavesurfer-segment" ) . first ( ) . click ( ) ;
3642 await expect (
3743 page . getByTitle ( "-2.360" ) . locator ( "div" ) ,
3844 "should contain word `Sentence`" ,
3945 ) . toContainText ( "Sentence" ) ;
46+
4047 const text = await page . getByTitle ( "-2.360" ) . locator ( "div" ) ;
4148 await text . scrollIntoViewIfNeeded ( ) ;
4249 await text . click ( ) ;
@@ -46,6 +53,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
4653 "should now contain word `Sentences`" ,
4754 ) . toContainText ( "Sentences" ) ;
4855
56+ const newStartTime = await page
57+ . locator ( "segment.wavesurfer-segment" )
58+ . first ( )
59+ . evaluate ( ( seg ) => ( seg as HTMLElement ) . title . substring ( 0 , 4 ) ) ;
60+
4961 //check web bundle output
5062 await page . locator ( "#mat-select-value-3" ) . click ( ) ;
5163 await page . getByRole ( "option" , { name : "Web Bundle" } ) . click ( ) ;
@@ -68,8 +80,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
6880 "readalong file should reflect new spelling" ,
6981 ) . toMatch ( / > S e n t e n c e s < / ) ;
7082 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+" ` ) ) ;
7388
7489 //check SRT
7590 await page . locator ( "#mat-select-value-3" ) . click ( ) ;
@@ -86,8 +101,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
86101 / S e n t e n c e s / ,
87102 ) ;
88103 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-->` ) ) ;
91109 //check WEBVTT
92110 await page . locator ( "#mat-select-value-3" ) . click ( ) ;
93111 await page . getByRole ( "option" , { name : "WebVTT Subtitles" } ) . click ( ) ;
@@ -100,8 +118,11 @@ test("should edit alignment and words (editor)", async ({ page }) => {
100118 / S e n t e n c e s / ,
101119 ) ;
102120 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-->` ) ) ;
105126 //check PRAAT
106127 await page . locator ( "#mat-select-value-3" ) . click ( ) ;
107128 await page . getByRole ( "option" , { name : "Praat TextGrid" } ) . click ( ) ;
@@ -114,8 +135,13 @@ test("should edit alignment and words (editor)", async ({ page }) => {
114135 / t e x t = " S e n t e n c e s " / ,
115136 ) ;
116137 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+ ) ;
119145 //check elan
120146 await page . locator ( "#mat-select-value-3" ) . click ( ) ;
121147 await page . getByRole ( "option" , { name : "Elan File" } ) . click ( ) ;
@@ -128,6 +154,9 @@ test("should edit alignment and words (editor)", async ({ page }) => {
128154 / < 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 > / ,
129155 ) ;
130156 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+" ` ) ) ;
133162} ) ;
0 commit comments