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

Commit f98627a

Browse files
committed
Fix deep nested Choices
1 parent 798d6f5 commit f98627a

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

e2e/tests/nested.test.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,24 @@ const configComplicated = `
4747
<Choice value="Negative"/>
4848
<Choice value="Neutral"/>
4949
</Choices>
50-
<Textarea name="description" toName="my_text" perRegion="true"
51-
choice="single" showInLine="true" whenLabelValue="Person">
52-
</Textarea>
53-
<Choices name="gender" toName="my_text" perRegion="true"
54-
choice="single" showInLine="true" whenLabelValue="Person">
55-
<Choice value="Female"/>
56-
<Choice value="Male"/>
50+
<Choices name="positive" toName="my_text"
51+
visibleWhen="choice-selected"
52+
whenTagName="sentiment"
53+
whenChoiceValue="Positive">
54+
<Choice value="Smile" />
55+
<Choice value="Laughter" />
5756
</Choices>
57+
<View visibleWhen="region-selected" whenLabelValue="Person">
58+
<Header>More details about this person:</Header>
59+
<Textarea name="description" toName="my_text" perRegion="true"
60+
choice="single" showInLine="true" whenLabelValue="Person">
61+
</Textarea>
62+
<Choices name="gender" toName="my_text" perRegion="true"
63+
choice="single" showInLine="true" whenLabelValue="Person">
64+
<Choice value="Female"/>
65+
<Choice value="Male"/>
66+
</Choices>
67+
</View>
5868
<Choices name="currency" toName="my_text" perRegion="true"
5969
choice="single" showInLine="true" whenLabelValue="Money">
6070
<Choice value="USD"/>
@@ -100,6 +110,10 @@ Scenario("check good nested Choice for Text", async function(I) {
100110
I.amOnPage("/");
101111
I.executeAsyncScript(initLabelStudio, params);
102112

113+
I.click("Positive");
114+
I.see("Laughter");
115+
I.click("Laughter");
116+
103117
const personTag = locate(".ant-tag").withText("Person");
104118
I.seeElement(personTag);
105119
I.click(personTag);
@@ -113,11 +127,14 @@ Scenario("check good nested Choice for Text", async function(I) {
113127
I.click(regionInList);
114128

115129
I.see("Regions (1)");
130+
I.see("More details"); // View with visibleWhen
116131

117132
I.click("Female");
118133

119134
const result = await I.executeScript(serialize);
120-
assert.equal(result.length, 2);
121-
assert.deepEqual(result[0].value.labels, ["Person"]);
122-
assert.deepEqual(result[1].value.choices, ["Female"]);
135+
assert.equal(result.length, 4);
136+
assert.deepEqual(result[0].value.choices, ["Positive"]);
137+
assert.deepEqual(result[1].value.choices, ["Laughter"]);
138+
assert.deepEqual(result[2].value.labels, ["Person"]);
139+
assert.deepEqual(result[3].value.choices, ["Female"]);
123140
});

src/mixins/Visibility.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const VisibilityMixin = types
4444
const choicesSelected = choiceValue
4545
.split(",")
4646
.map(v => tag.findLabel(v))
47-
.some(c => c && c.selected);
47+
.some(c => c && c.sel);
4848
return choicesSelected;
4949
}
5050

0 commit comments

Comments
 (0)