Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit cf56017

Browse files
authored
feat: LSDV-5298: Paragraphs must sync seek, play and pause with Audio in both directions (#1485)
* feat: LSDV-5298: Paragraphs must sync seek, play and pause with Audio in both directions * removing unused SyncMixin * Allow playingId to correctly track over time * updating tests for sync with contextual scrolling on/off * removing unused TimeSync class * adding test for contextual scrolling state change during playback
1 parent 0c80143 commit cf56017

File tree

14 files changed

+434
-1089
lines changed

14 files changed

+434
-1089
lines changed

Diff for: e2e/tests/sync/audio-paragraphs.test.js

+82-26
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const assert = require('assert');
2+
const { FFlagMatrix, FFlagScenario } = require('../../utils/feature-flags');
23

34
Feature('Sync: Audio Paragraphs');
45

@@ -25,29 +26,33 @@ const data = {
2526
url: 'https://htx-misc.s3.amazonaws.com/opensource/label-studio/examples/audio/barradeen-emotional.mp3',
2627
text: [
2728
{
28-
'end': 5.6,
29+
'end': 2,
2930
'text': 'Dont you hate that?',
30-
'start': 3.1,
31+
'start': 0,
3132
'author': 'Mia Wallace',
3233
},
3334
{
3435
'text': 'Hate what?',
35-
'start': 4.2,
36+
'start': 2,
3637
'author': 'Vincent Vega:',
37-
'duration': 3.1,
38+
'duration': 2,
3839
},
3940
{
4041
'text': 'Uncomfortable silences. Why do we feel its necessary to yak about bullshit in order to be comfortable?',
4142
'author': 'Mia Wallace:',
43+
'start': 4,
44+
'end': 6,
4245
},
4346
{
4447
'text': 'I dont know. Thats a good question.',
45-
'start': 90,
48+
'start': 6,
49+
'end': 8,
4650
'author': 'Vincent Vega:',
4751
},
4852
{
4953
'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.',
5054
'author': 'Mia Wallace:',
55+
'start': 8,
5156
},
5257
],
5358
};
@@ -91,36 +96,87 @@ const annotations = [
9196

9297
const params = { annotations: [{ id: 'test', result: annotations }], config, data };
9398

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}`);
99130
});
100131

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 }) {
102134

103-
LabelStudio.init(params);
135+
LabelStudio.setFeatureFlags({
136+
ff_front_dev_2715_audio_3_280722_short: true,
137+
...flags,
138+
});
104139

105-
await AtAudioView.waitForAudio();
106-
await AtAudioView.lookForStage();
140+
I.amOnPage('/');
107141

108-
AtSidebar.seeRegions(2);
142+
LabelStudio.init(params);
109143

110-
const [{ currentTime: startingAudioTime }, { currentTime: startingParagraphAudioTime }] = await AtAudioView.getCurrentAudio();
144+
await AtAudioView.waitForAudio();
145+
await AtAudioView.lookForStage();
111146

112-
assert.equal(startingAudioTime, startingParagraphAudioTime);
113-
assert.equal(startingParagraphAudioTime, 0);
147+
AtSidebar.seeRegions(2);
114148

115-
I.click('[aria-label="play-circle"]');
116-
I.wait(1);
149+
const [{ currentTime: startingAudioTime }, { currentTime: startingParagraphAudioTime }] = await AtAudioView.getCurrentAudio();
117150

118-
I.click('[aria-label="pause-circle"]');
119-
I.wait(1);
151+
assert.equal(startingAudioTime, startingParagraphAudioTime);
152+
assert.equal(startingParagraphAudioTime, 0);
120153

121-
const [{ currentTime: seekAudioTime }, { currentTime: seekParagraphAudioTime }] = await AtAudioView.getCurrentAudio();
154+
AtAudioView.clickPauseButton();
122155

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);
126164

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

Comments
 (0)