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

Commit 94c62fa

Browse files
bmarteljuliosgarbi
andauthored
fix: LSDV-4542: Hiding an audio segment and select a segment below no longer works (#1213)
Co-authored-by: Julio Sgarbi <[email protected]>
1 parent a93771b commit 94c62fa

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

Diff for: e2e/fragments/AtSidebar.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module.exports = {
55
_regionGroupButton: locate('.lsf-radio-group__button'),
66
_regionsCounterLocator: locate('.lsf-entities__counter'),
77
_regionLocator: locate('.lsf-region-item'),
8+
_regionSelectedLocator: locate('[data-testid="regionitem:selected=true"]'),
9+
_regionUnselectedLocator: locate('[data-testid="regionitem:selected=false"]'),
810
_selectedRegionsLocator: locate('.lsf-entity'),
911
seeRegions(count) {
1012
if (count) {
@@ -29,8 +31,12 @@ module.exports = {
2931
dontSeeRelations() {
3032
I.dontSee('Relations', this._sideBarLocator);
3133
},
32-
seeSelectedRegion() {
33-
I.seeElement(this._selectedRegionsLocator);
34+
seeSelectedRegion(text = undefined) {
35+
if (text) {
36+
I.seeElement(this._regionSelectedLocator.withText(text));
37+
} else {
38+
I.seeElement(this._selectedRegionsLocator);
39+
}
3440
},
3541
dontSeeSelectedRegion() {
3642
I.dontSeeElement(this._selectedRegionsLocator);
@@ -50,6 +56,12 @@ module.exports = {
5056
clickRegion(text) {
5157
I.click(this._regionLocator.withText(`${text}`));
5258
},
59+
hideRegion(text) {
60+
I.click(this._regionLocator.withText(`${text}`).find('.lsf-region-item__toggle_active'));
61+
},
62+
showRegion(text) {
63+
I.click(this._regionLocator.withText(`${text}`).find('.lsf-region-item__toggle:not(.lsf-region-item__toggle_active)'));
64+
},
5365
selectTool(tool) {
5466
I.click(`[aria-label=${tool}-tool]`);
5567
},

Diff for: e2e/tests/audio/audio-regions.test.js

+40
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,46 @@ Scenario('Check if there are ghost regions', async function({ I, LabelStudio, At
147147
AtSidebar.dontSeeSelectedRegion();
148148
});
149149

150+
Scenario('Can select a region below a hidden region', async function({ I, LabelStudio, AtAudioView, AtSidebar }) {
151+
LabelStudio.setFeatureFlags({
152+
ff_front_dev_2715_audio_3_280722_short: true,
153+
});
154+
I.amOnPage('/');
155+
156+
LabelStudio.init(paramsSpeech);
157+
158+
await AtAudioView.waitForAudio();
159+
160+
I.waitForDetached('loading-progress-bar', 10);
161+
162+
await AtAudioView.lookForStage();
163+
164+
// create a new region
165+
I.pressKey('1');
166+
AtAudioView.dragAudioRegion(50, 80);
167+
I.pressKey('u');
168+
169+
AtSidebar.seeRegions(1);
170+
171+
// create a new region above the first one
172+
I.pressKey('2');
173+
AtAudioView.dragAudioRegion(49, 81);
174+
I.pressKey('u');
175+
176+
AtSidebar.seeRegions(2);
177+
178+
// click on the top-most region visible to select it
179+
AtAudioView.clickAt(50);
180+
AtSidebar.seeSelectedRegion('Noise');
181+
182+
// hide the region
183+
AtSidebar.hideRegion('Noise');
184+
185+
// click on the region below the hidden one to select it
186+
AtAudioView.clickAt(50);
187+
AtSidebar.seeSelectedRegion('Speech');
188+
});
189+
150190
Scenario('Delete region by pressing delete hotkey', async function({ I, LabelStudio, AtAudioView, AtSidebar }) {
151191
LabelStudio.setFeatureFlags({
152192
ff_front_dev_2715_audio_3_280722_short: true,

Diff for: src/components/Entities/RegionItem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const RegionItemContent = observer(({ idx, item, setDraggable }) => {
5656
}
5757
}, [item.selected]);
5858
return (
59-
<Block ref={itemElRef} name="region-item" mod={{ hidden : item.hidden }}>
59+
<Block ref={itemElRef} name="region-item" mod={{ hidden : item.hidden }} data-testid={`regionitem:selected=${item.selected}`}>
6060
<Elem name="header" tag="div">
6161
<Elem name="counter">{isDefined(idx) ? idx + 1 : ''}</Elem>
6262

Diff for: src/lib/AudioUltra/Regions/Regions.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ export class Regions {
217217
return this.regions.filter(region => region.selected);
218218
}
219219

220+
get visible() {
221+
return this.regions.filter(region => region.visible);
222+
}
223+
220224
isOverrideKeyPressed(e: MouseEvent) {
221225
return e.shiftKey;
222226
}
@@ -386,7 +390,7 @@ export class Regions {
386390
};
387391

388392
private findRegionUnderCursor(e: MouseEvent) {
389-
const region = findLast(this.regions, region => {
393+
const region = findLast(this.visible, region => {
390394
return this.cursorInRegion(e, region);
391395
});
392396

0 commit comments

Comments
 (0)