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

fix: DEV-3341: selected=true <Choice> attribute is not supported for Taxonomy #899

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
676b9af
fix: DEV-3341: selected=true <Choice> attribute is not supported for …
yyassi-heartex Oct 6, 2022
8e1a718
clearing out console.log
yyassi-heartex Oct 6, 2022
9152371
Merge branch 'master' into fb-dev-3341-correct
yyassi-heartex Oct 6, 2022
ee984b5
Merge remote-tracking branch 'origin/master' into fb-dev-3341-correct
yyassi-heartex Oct 6, 2022
afdda51
toggling visibility only if perRegionVisibile and item is visible
yyassi-heartex Oct 6, 2022
04cca62
adding e2e test
yyassi-heartex Oct 7, 2022
7efe2e7
tweaking the new taxonomy e2e test
yyassi-heartex Oct 7, 2022
5031bff
Merge remote-tracking branch 'origin/master' into fb-dev-3341-correct
yyassi-heartex Oct 7, 2022
8d149fd
fixing the taxonomy showFullPath e2e test
yyassi-heartex Oct 7, 2022
3780da7
updating e2e test to use codeceptjs Data
yyassi-heartex Oct 11, 2022
f72a38b
Merge remote-tracking branch 'origin/master' into fb-dev-3341-correct
yyassi-heartex Oct 13, 2022
658c42e
fixed a bug affecting taxonomy when perRegion=true and choice selecte…
yyassi-heartex Oct 14, 2022
bd30b13
adjusting e2e tests
yyassi-heartex Oct 14, 2022
d8d29a5
trying to fix the e2e test - there appears to be an issue that occurs…
yyassi-heartex Oct 18, 2022
c9bce0a
Merge branch 'master' into fb-dev-3341-correct
yyassi-heartex Oct 19, 2022
efaba54
working on fixing the e2e test
yyassi-heartex Oct 20, 2022
f1d80d8
clearing console
yyassi-heartex Oct 20, 2022
dac5458
clean up
yyassi-heartex Oct 20, 2022
318f4ab
updating the taxonomy e2e test
yyassi-heartex Oct 20, 2022
cdfe792
e2e test finally fixed
yyassi-heartex Oct 20, 2022
0d41b71
now looking for tags in the appropriate spots
yyassi-heartex Oct 21, 2022
3d967f2
e2e test cleanup
yyassi-heartex Oct 21, 2022
e43f9cf
fixing e2e test
yyassi-heartex Oct 24, 2022
1e88a9d
making sure we pick up outliner just before we use it
yyassi-heartex Oct 24, 2022
5ae69ec
fixed e2e test
yyassi-heartex Oct 24, 2022
6d9436b
making the value fix a little more dynamic
yyassi-heartex Oct 24, 2022
314cd78
switching away from Htx.annotationStore
yyassi-heartex Oct 25, 2022
523da15
refactoring the code a bit so heavy lifting happens in createResult i…
yyassi-heartex Oct 25, 2022
3268df7
Merge branch 'master' into fb-dev-3341-correct
yyassi-heartex Oct 28, 2022
ea426b5
investigating taxonomy issue
yyassi-heartex Oct 31, 2022
f679fcb
Merge branch 'master' into fb-dev-3341-correct
yyassi-heartex Nov 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
293 changes: 293 additions & 0 deletions e2e/tests/taxonomy.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
/* global Feature, Scenario, locate, DataTable, Data */

const { serialize, selectText } = require("./helpers");

const assert = require("assert");

Feature("Taxonomy");

const cases = {
taxonomy: {
config: `<View>
<Text name="text" value="$text"/>
<Labels name="label" toName="text">
<Label value="PER" background="red"/>
<Label value="ORG" background="darkorange"/>
<Label value="LOC" background="orange"/>
<Label value="MISC" background="green"/>
</Labels>
<Taxonomy name="taxonomy" toName="text" >
<Choice value="Archaea" />
<Choice value="Bacteria" />
<Choice value="Eukarya">
<Choice value="Human" />
<Choice value="Oppossum" />
<Choice value="Extraterrestial" selected="true" />
</Choice>
</Taxonomy>
</View>`,
text: `To have faith is to trust yourself to the water`,
annotations: [
{ label: 'PER', rangeStart: 0, rangeEnd: 2, text: 'To', test: {
clickTaxonomy: ['Extraterrestial', 'Archaea'],
assertTrue: [
'Archaea',
],
assertFalse: [
'Extraterrestial',
],
} },
{ label: 'PER', rangeStart: 3, rangeEnd: 7, text: 'have', test: {
clickTaxonomy: ['Archaea'],
assertTrue: [
'Archaea',
'Extraterrestial',
],
assertFalse: [],
} },
],
isPerRegion: false,
FF: {
ff_front_1170_outliner_030222_short: false,
},
},
taxonomyPerRegion: {
config: `<View>
<Text name="text" value="$text"/>
<Labels name="label" toName="text">
<Label value="PER" background="red"/>
<Label value="ORG" background="darkorange"/>
<Label value="LOC" background="orange"/>
<Label value="MISC" background="green"/>
</Labels>
<Taxonomy name="taxonomy" toName="text" perRegion="true" >
<Choice value="Archaea" />
<Choice value="Bacteria" />
<Choice value="Eukarya">
<Choice value="Human" />
<Choice value="Oppossum" />
<Choice value="Extraterrestial" selected="true" />
</Choice>
</Taxonomy>
</View>`,
text: `To have faith is to trust yourself to the water`,
annotations: [
{ label: 'PER', rangeStart: 0, rangeEnd: 2, text: 'To', test: {
clickTaxonomy: ['Extraterrestial', 'Archaea'],
assertTrue: [
'Archaea',
],
assertFalse: [
'Extraterrestial',
],
} },
{ label: 'PER', rangeStart: 3, rangeEnd: 7, text: 'have', test: {
clickTaxonomy: ['Archaea'],
assertTrue: [
'Archaea',
'Extraterrestial',
],
assertFalse: [],
} },
],
isPerRegion: true,
FF: {
ff_front_1170_outliner_030222_short: false,
},
},
taxonomyWithShowLabels: {
config: `<View>
<Text name="text" value="$text"/>
<Labels name="label" toName="text">
<Label value="PER" background="red"/>
<Label value="ORG" background="darkorange"/>
<Label value="LOC" background="orange"/>
<Label value="MISC" background="green"/>
</Labels>
<Taxonomy name="taxonomy" showfullpath="true" toName="text" perRegion="true" >
<Choice value="Archaea" />
<Choice value="Bacteria" />
<Choice value="Eukarya">
<Choice value="Human" />
<Choice value="Oppossum" />
<Choice value="Extraterrestial" selected="true" />
</Choice>
</Taxonomy>
</View>`,
text: `To have faith is to trust yourself to the water`,
annotations: [
{ label: 'PER', rangeStart: 0, rangeEnd: 2, text: 'To', test: {
clickTaxonomy: ['Human'],
assertTrue: [
'Eukarya / Extraterrestial',
'Eukarya / Human',
],
assertFalse: [
'Bacteria',
],
} },
],
isPerRegion: true,
FF: {
ff_front_1170_outliner_030222_short: false,
},
},
taxonomyOutliner: {
config: `<View>
<Text name="text" value="$text"/>
<Labels name="label" toName="text">
<Label value="PER" background="red"/>
<Label value="ORG" background="darkorange"/>
<Label value="LOC" background="orange"/>
<Label value="MISC" background="green"/>
</Labels>
<Taxonomy name="taxonomy" toName="text" perRegion="true" >
<Choice value="Archaea" />
<Choice value="Bacteria" />
<Choice value="Eukarya">
<Choice value="Human" />
<Choice value="Oppossum" />
<Choice value="Extraterrestial" selected="true" />
</Choice>
</Taxonomy>
</View>`,
text: `To have faith is to trust yourself to the water`,
annotations: [
{ label: 'PER', rangeStart: 0, rangeEnd: 2, text: 'To', test: {
clickTaxonomy: ['Extraterrestial'],
assertTrue: [
],
assertFalse: [
'Extraterrestial',
],
} },
{ label: 'PER', rangeStart: 3, rangeEnd: 7, text: 'have', test: {
clickTaxonomy: ['Archaea'],
assertTrue: [
'Archaea',
'Extraterrestial',
],
assertFalse: [],
} },
],
isPerRegion: true,
FF: {
ff_front_1170_outliner_030222_short: true,
},
},
taxonomyWithShowLabelsWithOuliner: {
config: `<View>
<Text name="text" value="$text"/>
<Labels name="label" toName="text">
<Label value="PER" background="red"/>
<Label value="ORG" background="darkorange"/>
<Label value="LOC" background="orange"/>
<Label value="MISC" background="green"/>
</Labels>
<Taxonomy name="taxonomy" showfullpath="true" toName="text" perRegion="true" >
<Choice value="Archaea" />
<Choice value="Bacteria" />
<Choice value="Eukarya">
<Choice value="Human" />
<Choice value="Oppossum" />
<Choice value="Extraterrestial" selected="true" />
</Choice>
</Taxonomy>
</View>`,
text: `To have faith is to trust yourself to the water`,
annotations: [
{ label: 'PER', rangeStart: 0, rangeEnd: 2, text: 'To', test: {
clickTaxonomy: [['Human']],
assertTrue: [
'Eukarya / Extraterrestial',
'Eukarya / Human',
],
assertFalse: [
'Bacteria',
],
} },
],
isPerRegion: true,
FF: {
ff_front_1170_outliner_030222_short: true,
},
},
};

const taxonomyTable = new DataTable(["taxonomyName"]);

for (const taxonomyName of Object.keys(cases)) {
taxonomyTable.add([taxonomyName]);
}

Data(taxonomyTable).Scenario("Check Taxonomy", async ({ I, LabelStudio, current }) => {
const { taxonomyName } = current;
const Taxonomy = cases[taxonomyName];
const { annotations, config, text, isPerRegion, FF } = Taxonomy;
const outlinerSelector = ".lsf-outliner-item__title";
const sideBarRegionSelector = "li";
const taxonomyLabelSelector = ".lsf-taxonomy__label";

I.amOnPage("/");

LabelStudio.setFeatureFlags({ ff_dev_2007_rework_choices_280322_short: true, ...FF });
LabelStudio.init({ config, data: { text } });

const isOutliner = FF.ff_front_1170_outliner_030222_short;

annotations.forEach(annotation => {
let regionEl;

if (isPerRegion) {
I.click(locate(".lsf-label__text").withText(annotation.label));
I.executeScript(selectText, {
selector: ".lsf-htx-richtext",
rangeStart: annotation.rangeStart,
rangeEnd: annotation.rangeEnd,
});

regionEl = isOutliner ? locate(outlinerSelector).withText(annotation.label) : locate(sideBarRegionSelector).withText(annotation.text);

I.seeElement(regionEl);
I.click(regionEl);
}

I.click(locate("span").withText("Click to add..."));
I.click(locate(".collapser.collapsed"));
annotation.test.clickTaxonomy.forEach(t => I.click(locate("label").withText(t)));


/* reseting clicks */
I.click(locate(".collapser.open"));
if (isPerRegion) {
I.click(regionEl);
I.click(locate(".lsf-label__text").withText(annotation.label));
} else {
I.click(locate("span").withText("Click to add..."));
}
});

const results = await I.executeScript(serialize);

results.filter(result => result.value.labels).forEach((result, index) => {
const annotation = annotations[index];
const expected = {
end: annotation.rangeEnd,
labels: [annotation.label],
start: annotation.rangeStart,
text: annotation.text,
};

assert.deepEqual(result.value, expected);

if (isPerRegion) {
const regionEl = isOutliner ? locate(outlinerSelector).withText(annotation.label) : locate(sideBarRegionSelector).withText(annotation.text);

I.click(regionEl);
}

annotation.test.assertTrue.forEach(label => I.seeElement(locate(taxonomyLabelSelector).withText(label)));
annotation.test.assertFalse.forEach(label => I.dontSeeElement(locate(taxonomyLabelSelector).withText(label)));
});

});
65 changes: 32 additions & 33 deletions src/components/Taxonomy/Taxonomy.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,38 @@
white-space: nowrap;
cursor: pointer;
}
&__selected {
display: flex;
flex-wrap: wrap;
min-height: 28px; // 24px button + 4px margin

div {
margin: 0 2px 4px 0;
background: hsl(0, 0%, 95%);
padding: 0; // all the right space should be a clickable button, so no padding
padding-left: 8px;
border-radius: 4px;
display: flex;
align-items: center;
}

input[type="button"] {
border: none;
background: none;
cursor: pointer;
width: 24px;
height: 24px;
padding: 0;
line-height: 1;
font-weight: 500;
font-size: 20px;
color: #09f;

&:hover {
color: red;
}
}
}
}

.taxonomy > span > svg {
Expand All @@ -24,39 +56,6 @@
transform: none;
}

.taxonomy__selected {
display: flex;
flex-wrap: wrap;
min-height: 28px; // 24px button + 4px margin

div {
margin: 0 2px 4px 0;
background: hsl(0, 0%, 95%);
padding: 0; // all the right space should be a clickable button, so no padding
padding-left: 8px;
border-radius: 4px;
display: flex;
align-items: center;
}

input[type="button"] {
border: none;
background: none;
cursor: pointer;
width: 24px;
height: 24px;
padding: 0;
line-height: 1;
font-weight: 500;
font-size: 20px;
color: #09f;

&:hover {
color: red;
}
}
}

.taxonomy__dropdown {
position: absolute;
z-index: 10;
Expand Down
Loading