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

Commit cea99c6

Browse files
juliosgarbibmartel
andauthored
chore: LSDV-4592: Add tests to validate if ghost regions are created on AudioV3 (#1195)
* fix: LSDV-4592: Add tests to validate if ghost regions are created on AudioV3 * Update e2e/fragments/AtAudioView.js Co-authored-by: bmartel <[email protected]> * Update e2e/tests/audio/audio-regions.test.js Co-authored-by: bmartel <[email protected]> --------- Co-authored-by: bmartel <[email protected]>
1 parent 85fb7c9 commit cea99c6

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

e2e/fragments/AtAudioView.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module.exports = {
2222
_seekBackwardButtonSelector: '.lsf-audio-tag .lsf-timeline-controls__main-controls > .lsf-timeline-controls__group:nth-child(2) > button:nth-child(1)',
2323
_playButtonSelector: '.lsf-audio-tag .lsf-timeline-controls__main-controls > .lsf-timeline-controls__group:nth-child(2) > button:nth-child(2)',
2424
_seekForwardButtonSelector: '.lsf-audio-tag .lsf-timeline-controls__main-controls > .lsf-timeline-controls__group:nth-child(2) > button:nth-child(3)',
25+
_choiceSelector: '.lsf-choices.lsf-choices_layout_inline',
2526

2627
_stageBbox: { x: 0, y: 0, width: 0, height: 0 },
2728

@@ -137,6 +138,12 @@ module.exports = {
137138
I.click(this._playButtonSelector);
138139
},
139140

141+
async dontSeeGhostRegion() {
142+
const selectedChoice = await I.grabTextFrom(this._choiceSelector);
143+
144+
assert.equal(selectedChoice, 'Positive');
145+
},
146+
140147
async seeIsPlaying(playing) {
141148
const isPaused = await I.grabAttributeFrom(this._audioElementSelector, 'paused');
142149

e2e/tests/audio/audio-regions.test.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ const config = `
2222
</View>
2323
`;
2424

25+
const configSpeech = `
26+
<View>
27+
<AudioPlus name="audio" value="$url"></AudioPlus>
28+
<Labels name="label" toName="audio">
29+
<Label value="Speech"/>
30+
<Label value="Noise" background="grey"/>
31+
</Labels>
32+
<TextArea name="transcription" toName="audio"
33+
perRegion="true" whenTagName="label" whenLabelValue="Speech"
34+
displayMode="region-list"/>
35+
<Choices name="sentiment" toName="audio" showInline="true"
36+
perRegion="true" whenTagName="label" whenLabelValue="Speech">
37+
<Choice value="Positive" html="&lt;span style='font-size: 45px; vertical-align: middle;'&gt; &#128512; &lt;/span&gt;"/>
38+
<Choice value="Neutral" html="&lt;span style='font-size: 45px; vertical-align: middle;'&gt; &#128528; &lt;/span&gt;"/>
39+
<Choice value="Negative" html="&lt;span style='font-size: 45px; vertical-align: middle;'&gt; &#128577; &lt;/span&gt;"/>
40+
</Choices>
41+
</View>
42+
`;
43+
2544
const data = {
2645
url: 'https://htx-misc.s3.amazonaws.com/opensource/label-studio/examples/audio/barradeen-emotional.mp3',
2746
};
@@ -54,6 +73,7 @@ const annotations = [
5473
];
5574

5675
const params = { annotations: [{ id: 'test', result: annotations }], config, data };
76+
const paramsSpeech = { annotations: [{ id: 'test', result: [] }], config: configSpeech, data };
5777

5878
Scenario('Check if regions are selected', async function({ I, LabelStudio, AtAudioView, AtSidebar }) {
5979
LabelStudio.setFeatureFlags({
@@ -88,6 +108,47 @@ Scenario('Check if regions are selected', async function({ I, LabelStudio, AtAud
88108
AtSidebar.dontSeeSelectedRegion();
89109
});
90110

111+
Scenario('Check if there are ghost regions', async function({ I, LabelStudio, AtAudioView, AtSidebar }) {
112+
LabelStudio.setFeatureFlags({
113+
ff_front_dev_2715_audio_3_280722_short: true,
114+
});
115+
I.amOnPage('/');
116+
117+
LabelStudio.init(paramsSpeech);
118+
119+
await AtAudioView.waitForAudio();
120+
121+
I.waitForDetached('loading-progress-bar', 10);
122+
123+
await AtAudioView.lookForStage();
124+
125+
for (let i = 0; i < 20; i++) {
126+
// creating a new region
127+
I.pressKey('1');
128+
AtAudioView.dragAudioRegion((40 * i) + 10,30);
129+
AtAudioView.clickAt((40 * i) + 20);
130+
I.pressKey('2');
131+
I.pressKey('1');
132+
I.pressKey('u');
133+
}
134+
135+
AtSidebar.seeRegions(20);
136+
137+
for (let i = 0; i < 20; i++) {
138+
// creating a new region
139+
AtAudioView.clickAt((40 * i) + 20);
140+
AtSidebar.seeSelectedRegion();
141+
AtAudioView.dontSeeGhostRegion();
142+
I.pressKey('u');
143+
}
144+
145+
AtSidebar.seeRegions(20);
146+
147+
I.pressKey('u');
148+
149+
AtSidebar.dontSeeSelectedRegion();
150+
});
151+
91152
Scenario('Delete region by pressing delete hotkey', async function({ I, LabelStudio, AtAudioView, AtSidebar }) {
92153
LabelStudio.setFeatureFlags({
93154
ff_front_dev_2715_audio_3_280722_short: true,

0 commit comments

Comments
 (0)