1
1
const assert = require ( 'assert' ) ;
2
+ const { FFlagMatrix, FFlagScenario } = require ( '../../utils/feature-flags' ) ;
2
3
3
4
Feature ( 'Sync: Audio Paragraphs' ) ;
4
5
@@ -25,29 +26,33 @@ const data = {
25
26
url : 'https://htx-misc.s3.amazonaws.com/opensource/label-studio/examples/audio/barradeen-emotional.mp3' ,
26
27
text : [
27
28
{
28
- 'end' : 5.6 ,
29
+ 'end' : 2 ,
29
30
'text' : 'Dont you hate that?' ,
30
- 'start' : 3.1 ,
31
+ 'start' : 0 ,
31
32
'author' : 'Mia Wallace' ,
32
33
} ,
33
34
{
34
35
'text' : 'Hate what?' ,
35
- 'start' : 4. 2,
36
+ 'start' : 2 ,
36
37
'author' : 'Vincent Vega:' ,
37
- 'duration' : 3.1 ,
38
+ 'duration' : 2 ,
38
39
} ,
39
40
{
40
41
'text' : 'Uncomfortable silences. Why do we feel its necessary to yak about bullshit in order to be comfortable?' ,
41
42
'author' : 'Mia Wallace:' ,
43
+ 'start' : 4 ,
44
+ 'end' : 6 ,
42
45
} ,
43
46
{
44
47
'text' : 'I dont know. Thats a good question.' ,
45
- 'start' : 90 ,
48
+ 'start' : 6 ,
49
+ 'end' : 8 ,
46
50
'author' : 'Vincent Vega:' ,
47
51
} ,
48
52
{
49
53
'text' : 'Thats when you know you found somebody really special. When you can just shut the fuck up for a minute, and comfortably share silence.' ,
50
54
'author' : 'Mia Wallace:' ,
55
+ 'start' : 8 ,
51
56
} ,
52
57
] ,
53
58
} ;
@@ -91,36 +96,87 @@ const annotations = [
91
96
92
97
const params = { annotations : [ { id : 'test' , result : annotations } ] , config, data } ;
93
98
94
- Scenario ( 'Check audio clip is played when using the new sync option' , async function ( { I, LabelStudio, AtAudioView, AtSidebar } ) {
95
- LabelStudio . setFeatureFlags ( {
96
- fflag_feat_front_dev_2461_audio_paragraphs_seek_chunk_position_short : true ,
97
- ff_front_dev_2715_audio_3_280722_short : true ,
98
- fflag_feat_front_lsdv_3012_syncable_tags_070423_short : true ,
99
+ FFlagMatrix ( [ 'fflag_feat_front_lsdv_e_278_contextual_scrolling_short' ] , function ( flags ) {
100
+ FFlagScenario ( 'Audio clip is played when selecting the play button next to a paragraph segment' , async function ( { I, LabelStudio, AtAudioView, AtSidebar } ) {
101
+ LabelStudio . setFeatureFlags ( {
102
+ ff_front_dev_2715_audio_3_280722_short : true ,
103
+ ...flags ,
104
+ } ) ;
105
+
106
+ I . amOnPage ( '/' ) ;
107
+
108
+ LabelStudio . init ( params ) ;
109
+
110
+ await AtAudioView . waitForAudio ( ) ;
111
+ await AtAudioView . lookForStage ( ) ;
112
+
113
+ AtSidebar . seeRegions ( 2 ) ;
114
+
115
+ const [ { currentTime : startingAudioTime } , { currentTime : startingParagraphAudioTime } ] = await AtAudioView . getCurrentAudio ( ) ;
116
+
117
+ assert . equal ( startingAudioTime , startingParagraphAudioTime ) ;
118
+ assert . equal ( startingParagraphAudioTime , 0 ) ;
119
+
120
+ I . click ( '[aria-label="play-circle"]' ) ;
121
+ I . wait ( 1 ) ;
122
+
123
+ I . click ( '[aria-label="pause-circle"]' ) ;
124
+ I . wait ( 1 ) ;
125
+
126
+ const [ { currentTime : seekAudioTime } , { currentTime : seekParagraphAudioTime } ] = await AtAudioView . getCurrentAudio ( ) ;
127
+
128
+ assert . notEqual ( seekAudioTime , 0 ) ;
129
+ I . assertTimesInSync ( seekAudioTime , seekParagraphAudioTime , `Expected seek time to be ${ seekAudioTime } but was ${ seekParagraphAudioTime } ` ) ;
99
130
} ) ;
100
131
101
- I . amOnPage ( '/' ) ;
132
+ if ( flags [ 'fflag_feat_front_lsdv_e_278_contextual_scrolling_short' ] ) {
133
+ FFlagScenario ( 'Playback button states continually change over time according to the paragraph segment which is being played' , async function ( { I, LabelStudio, AtAudioView, AtSidebar } ) {
102
134
103
- LabelStudio . init ( params ) ;
135
+ LabelStudio . setFeatureFlags ( {
136
+ ff_front_dev_2715_audio_3_280722_short : true ,
137
+ ...flags ,
138
+ } ) ;
104
139
105
- await AtAudioView . waitForAudio ( ) ;
106
- await AtAudioView . lookForStage ( ) ;
140
+ I . amOnPage ( '/' ) ;
107
141
108
- AtSidebar . seeRegions ( 2 ) ;
142
+ LabelStudio . init ( params ) ;
109
143
110
- const [ { currentTime : startingAudioTime } , { currentTime : startingParagraphAudioTime } ] = await AtAudioView . getCurrentAudio ( ) ;
144
+ await AtAudioView . waitForAudio ( ) ;
145
+ await AtAudioView . lookForStage ( ) ;
111
146
112
- assert . equal ( startingAudioTime , startingParagraphAudioTime ) ;
113
- assert . equal ( startingParagraphAudioTime , 0 ) ;
147
+ AtSidebar . seeRegions ( 2 ) ;
114
148
115
- I . click ( '[aria-label="play-circle"]' ) ;
116
- I . wait ( 1 ) ;
149
+ const [ { currentTime : startingAudioTime } , { currentTime : startingParagraphAudioTime } ] = await AtAudioView . getCurrentAudio ( ) ;
117
150
118
- I . click ( '[aria-label="pause-circle"]' ) ;
119
- I . wait ( 1 ) ;
151
+ assert . equal ( startingAudioTime , startingParagraphAudioTime ) ;
152
+ assert . equal ( startingParagraphAudioTime , 0 ) ;
120
153
121
- const [ { currentTime : seekAudioTime } , { currentTime : seekParagraphAudioTime } ] = await AtAudioView . getCurrentAudio ( ) ;
154
+ AtAudioView . clickPauseButton ( ) ;
122
155
123
- assert . notEqual ( seekAudioTime , 0 ) ;
124
- I . assertTimesInSync ( seekAudioTime , seekParagraphAudioTime , `Expected seek time to be ${ seekAudioTime } but was ${ seekParagraphAudioTime } ` ) ;
125
- } ) ;
156
+ // Plays the first paragraph segment when the audio interface is played
157
+ I . seeElement ( '[data-testid="phrase:0"] [aria-label="pause-circle"]' ) ;
158
+ I . seeElement ( '[data-testid="phrase:1"] [aria-label="play-circle"]' ) ;
159
+ I . seeElement ( '[data-testid="phrase:2"] [aria-label="play-circle"]' ) ;
160
+ I . seeElement ( '[data-testid="phrase:3"] [aria-label="play-circle"]' ) ;
161
+ I . seeElement ( '[data-testid="phrase:4"] [aria-label="play-circle"]' ) ;
162
+
163
+ I . wait ( 2 ) ;
126
164
165
+ // Plays the second paragraph segment when the audio progresses to the second paragraph segment
166
+ I . seeElement ( '[data-testid="phrase:1"] [aria-label="pause-circle"]' ) ;
167
+ I . seeElement ( '[data-testid="phrase:0"] [aria-label="play-circle"]' ) ;
168
+ I . seeElement ( '[data-testid="phrase:2"] [aria-label="play-circle"]' ) ;
169
+ I . seeElement ( '[data-testid="phrase:3"] [aria-label="play-circle"]' ) ;
170
+ I . seeElement ( '[data-testid="phrase:4"] [aria-label="play-circle"]' ) ;
171
+
172
+ I . wait ( 2 ) ;
173
+
174
+ // Plays the third paragraph segment when the audio progresses to the third paragraph segment
175
+ I . seeElement ( '[data-testid="phrase:2"] [aria-label="pause-circle"]' ) ;
176
+ I . seeElement ( '[data-testid="phrase:0"] [aria-label="play-circle"]' ) ;
177
+ I . seeElement ( '[data-testid="phrase:1"] [aria-label="play-circle"]' ) ;
178
+ I . seeElement ( '[data-testid="phrase:3"] [aria-label="play-circle"]' ) ;
179
+ I . seeElement ( '[data-testid="phrase:4"] [aria-label="play-circle"]' ) ;
180
+ } ) ;
181
+ }
182
+ } ) ;
0 commit comments