-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: LEAP-1892: [FE] Deeply nested Choices are visible when their parents are hidden #7180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7cdd89e
fix: LEAP-1892: [FE] Deeply nested Choices are visible when their par…
nass600 435eccc
Added integration tests
nass600 31baf75
Linting fixes
nass600 1fcb092
Merge branch 'develop' into 'fb-leap-1892/deeply-nested-choices'
nass600 fed93f1
Expanding tests to cover more cases
nass600 219ffcd
Merge branch 'develop' into 'fb-leap-1892/deeply-nested-choices'
nass600 88b8841
Adding tests for perregion cases
nass600 65369ca
Leaving perregion use cases out of the scope of this bug
nass600 2cae947
Linting fixes
nass600 0125db9
Improved tests and remove from scope choice-unselected
nass600 f24f9bd
Reducing the scope of the changes to avoid risk
nass600 db76ad7
Merge branch 'develop' into 'fb-leap-1892/deeply-nested-choices'
MihajloHoma d41921a
Sync Follow Merge dependencies
robot-ci-heartex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
web/libs/editor/tests/integration/data/control_tags/visibility.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
export const simpleVisibleWhenConfig = `<View> | ||
<Text name="text" value="$text"/> | ||
|
||
<View name="Level 1"> | ||
<Header value="Level 1"/> | ||
<Choices name="level1" toName="text" choice="single" showInLine="true"> | ||
<Choice value="1A"/> | ||
<Choice value="1B"/> | ||
</Choices> | ||
</View> | ||
|
||
<Choices | ||
name="level2" toName="text" choice="single" showInLine="true" | ||
visibleWhen="choice-selected" | ||
whenTagName="level1" | ||
whenChoiceValue="1A" | ||
> | ||
<Choice value="2A"/> | ||
<Choice value="2B"/> | ||
</Choices> | ||
|
||
<Choices | ||
name="level3" toName="text" choice="single" showInLine="true" | ||
visibleWhen="choice-selected" | ||
whenTagName="level2" | ||
whenChoiceValue="2A" | ||
> | ||
<Choice value="3A"/> | ||
<Choice value="3B"/> | ||
</Choices> | ||
</View>`; | ||
|
||
export const multipleChainedViewsConfig = `<View> | ||
<Text name="text" value="$text"/> | ||
|
||
<View name="Level 1"> | ||
<Header value="Level 1"/> | ||
<Choices name="level1" toName="text" choice="single" showInLine="true"> | ||
<Choice value="1A"/> | ||
<Choice value="1B"/> | ||
</Choices> | ||
</View> | ||
|
||
<!-- Level 2 --> | ||
<View | ||
name="Level 2" | ||
visibleWhen="choice-selected" | ||
whenTagName="level1" | ||
whenChoiceValue="1A" | ||
> | ||
<Header value="Level 2"/> | ||
<Choices name="level2" toName="text" choice="single" showInLine="true"> | ||
<Choice value="2A"/> | ||
<Choice value="2B"/> | ||
</Choices> | ||
</View> | ||
|
||
<!-- Level 3A --> | ||
<View | ||
name="Level 3A" | ||
visibleWhen="choice-selected" | ||
whenTagName="level2" | ||
whenChoiceValue="2A" | ||
> | ||
<Header value="Level 3A"/> | ||
<Choices name="level3A" toName="text" choice="single" showInLine="true"> | ||
<Choice value="3X"/> | ||
<Choice value="3Y"/> | ||
</Choices> | ||
</View> | ||
|
||
<!-- Level 3B --> | ||
<View | ||
name="Level 3B" | ||
visibleWhen="choice-selected" | ||
whenTagName="level2" | ||
whenChoiceValue="2B" | ||
> | ||
<Header value="Level 3B"/> | ||
<Choices name="level3B" toName="text" choice="single" showInLine="true"> | ||
<Choice value="3Q"/> | ||
<Choice value="3W"/> | ||
</Choices> | ||
</View> | ||
</View>`; | ||
|
||
export const visibilityTextData = { | ||
text: "This text exists for no reason", | ||
}; |
84 changes: 84 additions & 0 deletions
84
web/libs/editor/tests/integration/e2e/control_tags/visibility.cy.ts
nass600 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { useChoices, LabelStudio } from "@humansignal/frontend-test/helpers/LSF"; | ||
import { | ||
multipleChainedViewsConfig, | ||
simpleVisibleWhenConfig, | ||
visibilityTextData, | ||
} from "../../data/control_tags/visibility"; | ||
|
||
const checkVisibility = (visibleIndexes: number[], totalIndexes: number) => { | ||
Array.from({ length: totalIndexes }).forEach((_, i) => { | ||
cy.get(`.lsf-choices:eq(${i})`).should(visibleIndexes.includes(i) ? "be.visible" : "not.be.visible"); | ||
}); | ||
}; | ||
|
||
describe("Visibility", () => { | ||
it("Ensure correct visibility of conditionally selected choices", () => { | ||
LabelStudio.params().config(simpleVisibleWhenConfig).data(visibilityTextData).withResult([]).init(); | ||
|
||
const l1Choice = useChoices("&:eq(0)"); | ||
const l2Choice = useChoices("&:eq(1)"); | ||
const l3Choice = useChoices("&:eq(2)"); | ||
checkVisibility([0], 3); | ||
|
||
l1Choice.findChoice("1A").click(); | ||
checkVisibility([0, 1], 3); | ||
|
||
l2Choice.findChoice("2A").click(); | ||
checkVisibility([0, 1, 2], 3); | ||
|
||
LabelStudio.serialize().then((result) => { | ||
expect(result).to.have.lengthOf(2); | ||
expect(result[0]).to.include({ from_name: "level1" }); | ||
expect(result[0].value.choices).to.have.lengthOf(1); | ||
expect(result[0]).to.nested.include({ "value.choices[0]": "1A" }); | ||
expect(result[1]).to.include({ from_name: "level2" }); | ||
expect(result[1].value.choices).to.have.lengthOf(1); | ||
expect(result[1]).to.nested.include({ "value.choices[0]": "2A" }); | ||
}); | ||
|
||
l1Choice.findChoice("1B").click(); | ||
checkVisibility([0], 3); | ||
|
||
LabelStudio.serialize().then((result) => { | ||
expect(result).to.have.lengthOf(1); | ||
expect(result[0].from_name).to.equal("level1"); | ||
expect(result[0].value.choices).to.have.lengthOf(1); | ||
expect(result[0].value.choices[0]).to.equal("1B"); | ||
}); | ||
}); | ||
|
||
it("Ensure correct visibility of conditionally selected choices with parent visibility restrictions", () => { | ||
LabelStudio.params().config(multipleChainedViewsConfig).data(visibilityTextData).withResult([]).init(); | ||
|
||
const l1Choice = useChoices("&:eq(0)"); | ||
const l2Choice = useChoices("&:eq(1)"); | ||
const l3AChoice = useChoices("&:eq(2)"); | ||
checkVisibility([0], 4); | ||
|
||
l1Choice.findChoice("1A").click(); | ||
checkVisibility([0, 1], 4); | ||
|
||
l2Choice.findChoice("2A").click(); | ||
checkVisibility([0, 1, 2], 4); | ||
|
||
LabelStudio.serialize().then((result) => { | ||
expect(result).to.have.lengthOf(2); | ||
expect(result[0]).to.include({ from_name: "level1" }); | ||
expect(result[0].value.choices).to.have.lengthOf(1); | ||
expect(result[0]).to.nested.include({ "value.choices[0]": "1A" }); | ||
expect(result[1]).to.include({ from_name: "level2" }); | ||
expect(result[1].value.choices).to.have.lengthOf(1); | ||
expect(result[1]).to.nested.include({ "value.choices[0]": "2A" }); | ||
}); | ||
|
||
l3AChoice.findChoice("3X").click(); | ||
checkVisibility([0, 1, 2], 4); | ||
|
||
l1Choice.findChoice("1A").click(); | ||
checkVisibility([0], 4); | ||
|
||
LabelStudio.serialize().then((result) => { | ||
expect(result).to.have.lengthOf(0); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.