Skip to content

Commit 2502f9e

Browse files
splitting taxonomy test into 4 files to improve test stability
1 parent f070965 commit 2502f9e

File tree

5 files changed

+390
-360
lines changed

5 files changed

+390
-360
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
import { LabelStudio, ImageView, Taxonomy, ToolBar, Modals, Sidebar } from "@humansignal/frontend-test/helpers/LSF";
2+
import {
3+
simpleMIGData,
4+
TAXONOMY_REQUIRED_WARNING,
5+
perRegionRegionsResult,
6+
perItemMIGTaxonomyConfig,
7+
perItemTaxonomyResult,
8+
requiredPerItemMIGTaxonomyConfig,
9+
} from "../../../data/control_tags/per-item";
10+
import { commonBeforeEach } from "./common";
11+
12+
beforeEach(commonBeforeEach);
13+
14+
/* <Taxonomy /> */
15+
describe("Control Tags - MIG perItem - Taxonomy", () => {
16+
it("should create result with item_index", () => {
17+
LabelStudio.params().config(perItemMIGTaxonomyConfig).data(simpleMIGData).withResult([]).init();
18+
19+
ImageView.waitForImage();
20+
21+
Taxonomy.open();
22+
Taxonomy.findItem("Choice 1").click();
23+
24+
LabelStudio.serialize().then((result) => {
25+
expect(result[0]).to.have.property("item_index", 0);
26+
});
27+
});
28+
29+
it("should load perItem result correctly", () => {
30+
LabelStudio.params().config(perItemMIGTaxonomyConfig).data(simpleMIGData).withResult(perItemTaxonomyResult).init();
31+
32+
ImageView.waitForImage();
33+
34+
Taxonomy.hasSelected("Choice 1");
35+
ImageView.paginationNextBtn.click();
36+
ImageView.waitForImage();
37+
Taxonomy.hasSelected("Choice 2");
38+
ImageView.paginationNextBtn.click();
39+
ImageView.waitForImage();
40+
Taxonomy.hasSelected("Choice 3");
41+
42+
LabelStudio.serialize().then((result) => {
43+
expect(result[0]).to.deep.include(perItemTaxonomyResult[0]);
44+
expect(result[1]).to.deep.include(perItemTaxonomyResult[1]);
45+
expect(result[2]).to.deep.include(perItemTaxonomyResult[2]);
46+
});
47+
});
48+
49+
it("should be able to create result for second item", () => {
50+
LabelStudio.params().config(perItemMIGTaxonomyConfig).data(simpleMIGData).withResult([]).init();
51+
52+
ImageView.waitForImage();
53+
54+
ImageView.paginationNextBtn.click();
55+
ImageView.waitForImage();
56+
57+
Taxonomy.open();
58+
Taxonomy.findItem("Choice 1").click();
59+
60+
LabelStudio.serialize().then((result) => {
61+
expect(result[0]).to.have.property("item_index", 1);
62+
});
63+
});
64+
65+
it("should be able to create more that one result", () => {
66+
LabelStudio.params().config(perItemMIGTaxonomyConfig).data(simpleMIGData).withResult([]).init();
67+
68+
ImageView.waitForImage();
69+
70+
Taxonomy.open();
71+
Taxonomy.findItem("Choice 1").click();
72+
73+
ImageView.paginationNextBtn.click();
74+
ImageView.waitForImage();
75+
Taxonomy.open();
76+
Taxonomy.findItem("Choice 2").click();
77+
78+
ImageView.paginationNextBtn.click();
79+
ImageView.waitForImage();
80+
Taxonomy.open();
81+
Taxonomy.findItem("Choice 3").click();
82+
83+
LabelStudio.serialize().then((result) => {
84+
expect(result[0]).to.include({ item_index: 0 });
85+
expect(result[0].value.taxonomy).to.be.deep.eq([["Choice 1"]]);
86+
87+
expect(result[1]).to.include({ item_index: 1 });
88+
expect(result[1].value.taxonomy).to.be.deep.eq([["Choice 2"]]);
89+
90+
expect(result[2]).to.include({ item_index: 2 });
91+
expect(result[2].value.taxonomy).to.be.deep.eq([["Choice 3"]]);
92+
});
93+
});
94+
95+
it("should require result", () => {
96+
LabelStudio.params()
97+
.config(requiredPerItemMIGTaxonomyConfig)
98+
.data(simpleMIGData)
99+
.withResult(perRegionRegionsResult)
100+
.init();
101+
102+
ImageView.waitForImage();
103+
104+
ToolBar.submitBtn.click();
105+
Modals.hasWarning(TAXONOMY_REQUIRED_WARNING);
106+
});
107+
108+
it("should require result for other region too", () => {
109+
LabelStudio.params()
110+
.config(requiredPerItemMIGTaxonomyConfig)
111+
.data(simpleMIGData)
112+
.withResult(perRegionRegionsResult)
113+
.init();
114+
115+
ImageView.waitForImage();
116+
117+
Taxonomy.open();
118+
Taxonomy.findItem("Choice 1").click();
119+
120+
ToolBar.submitBtn.click();
121+
Modals.hasWarning(TAXONOMY_REQUIRED_WARNING);
122+
});
123+
124+
it("should not require result if there are all of them", () => {
125+
LabelStudio.params()
126+
.config(requiredPerItemMIGTaxonomyConfig)
127+
.data(simpleMIGData)
128+
.withResult(perRegionRegionsResult)
129+
.init();
130+
131+
ImageView.waitForImage();
132+
133+
Taxonomy.open();
134+
Taxonomy.findItem("Choice 1").click();
135+
ImageView.paginationNextBtn.click();
136+
ImageView.waitForImage();
137+
138+
Taxonomy.open();
139+
Taxonomy.findItem("Choice 2").click();
140+
ImageView.paginationNextBtn.click();
141+
ImageView.waitForImage();
142+
143+
Taxonomy.open();
144+
Taxonomy.findItem("Choice 3").click();
145+
ImageView.paginationNextBtn.click();
146+
ImageView.waitForImage();
147+
148+
Taxonomy.open();
149+
Taxonomy.findItem("Choice 2").click();
150+
151+
ToolBar.submitBtn.click();
152+
Modals.hasNoWarnings();
153+
});
154+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import { LabelStudio, ImageView, Taxonomy, ToolBar, Modals, Sidebar } from "@humansignal/frontend-test/helpers/LSF";
2+
import {
3+
simpleMIGData,
4+
TAXONOMY_REQUIRED_WARNING,
5+
perRegionMIGTaxonomyConfig,
6+
perRegionRegionsResult,
7+
perRegionTaxonomyResult,
8+
requiredPerRegionMIGTaxonomyConfig,
9+
} from "../../../data/control_tags/per-item";
10+
import { commonBeforeEach } from "./common";
11+
12+
beforeEach(commonBeforeEach);
13+
14+
/* <Taxonomy /> */
15+
describe("Control Tags - MIG perRegion - Taxonomy", () => {
16+
it("should create result with item_index", () => {
17+
LabelStudio.params()
18+
.config(perRegionMIGTaxonomyConfig)
19+
.data(simpleMIGData)
20+
.withResult(perRegionRegionsResult)
21+
.init();
22+
23+
ImageView.waitForImage();
24+
Sidebar.hasRegions(2);
25+
26+
Sidebar.findRegionByIndex(0).click();
27+
28+
Taxonomy.open();
29+
Taxonomy.findItem("Choice 1").click();
30+
Taxonomy.close();
31+
32+
LabelStudio.serialize().then((result) => {
33+
expect(result.length).to.be.eq(3);
34+
expect(result[1]).to.include({
35+
type: "taxonomy",
36+
item_index: 0,
37+
});
38+
});
39+
});
40+
41+
it("should load result correctly", () => {
42+
LabelStudio.params()
43+
.config(perRegionMIGTaxonomyConfig)
44+
.data(simpleMIGData)
45+
.withResult(perRegionTaxonomyResult)
46+
.init();
47+
48+
ImageView.waitForImage();
49+
Sidebar.hasRegions(2);
50+
51+
Sidebar.findRegionByIndex(0).click();
52+
53+
Taxonomy.hasSelected("Choice 2");
54+
55+
LabelStudio.serialize().then((result) => {
56+
const { value, ...expectedResult } = perRegionTaxonomyResult[1];
57+
58+
expect(result.length).to.be.eq(3);
59+
expect(result[1]).to.deep.include(expectedResult);
60+
expect(result[1].value.taxonomy).to.be.deep.eq(value.taxonomy);
61+
});
62+
});
63+
64+
it("should require result", () => {
65+
LabelStudio.params()
66+
.config(requiredPerRegionMIGTaxonomyConfig)
67+
.data(simpleMIGData)
68+
.withResult(perRegionRegionsResult)
69+
.init();
70+
71+
ImageView.waitForImage();
72+
73+
ToolBar.submitBtn.click();
74+
Modals.hasWarning(TAXONOMY_REQUIRED_WARNING);
75+
});
76+
77+
it("should require result for other region too", () => {
78+
LabelStudio.params()
79+
.config(requiredPerRegionMIGTaxonomyConfig)
80+
.data(simpleMIGData)
81+
.withResult(perRegionRegionsResult)
82+
.init();
83+
84+
ImageView.waitForImage();
85+
86+
Sidebar.findRegionByIndex(0).click();
87+
Taxonomy.open();
88+
Taxonomy.findItem("Choice 1").click();
89+
90+
ToolBar.submitBtn.click();
91+
Modals.hasWarning(TAXONOMY_REQUIRED_WARNING);
92+
});
93+
94+
it("should not require result if there are all of them", () => {
95+
LabelStudio.params()
96+
.config(requiredPerRegionMIGTaxonomyConfig)
97+
.data(simpleMIGData)
98+
.withResult(perRegionRegionsResult)
99+
.init();
100+
101+
ImageView.waitForImage();
102+
103+
Sidebar.findRegionByIndex(0).click();
104+
Taxonomy.open();
105+
Taxonomy.findItem("Choice 1").click();
106+
107+
Sidebar.findRegionByIndex(1).click();
108+
ImageView.waitForImage();
109+
Taxonomy.open();
110+
Taxonomy.findItem("Choice 2").click();
111+
112+
ToolBar.submitBtn.click();
113+
Modals.hasNoWarnings();
114+
});
115+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { LabelStudio, ImageView, Taxonomy, ToolBar, Modals, Sidebar } from "@humansignal/frontend-test/helpers/LSF";
2+
import {
3+
perTagTaxonomyResult,
4+
perTagMIGTaxonomyConfig,
5+
simpleMIGData,
6+
requiredPerTagMIGTaxonomyConfig,
7+
TAXONOMY_REQUIRED_WARNING,
8+
} from "../../../data/control_tags/per-item";
9+
import { commonBeforeEach } from "./common";
10+
11+
beforeEach(commonBeforeEach);
12+
13+
/* <Taxonomy /> */
14+
describe("Classification - MIG perTag - Taxonomy", () => {
15+
it("should not have item_index in result", () => {
16+
LabelStudio.params().config(perTagMIGTaxonomyConfig).data(simpleMIGData).withResult([]).init();
17+
18+
ImageView.waitForImage();
19+
20+
Taxonomy.open();
21+
Taxonomy.findItem("Choice 1").click();
22+
Taxonomy.close();
23+
24+
LabelStudio.serialize().then((result) => {
25+
expect(result[0]).not.to.haveOwnProperty("item_index");
26+
});
27+
});
28+
29+
it("should load perTag result correctly", () => {
30+
LabelStudio.params().config(perTagMIGTaxonomyConfig).data(simpleMIGData).withResult(perTagTaxonomyResult).init();
31+
32+
ImageView.waitForImage();
33+
34+
Taxonomy.hasSelected("Choice 1");
35+
36+
LabelStudio.serialize().then((result) => {
37+
expect(result[0]).to.deep.include(perTagTaxonomyResult[0]);
38+
expect(result[0]).not.to.haveOwnProperty("item_index");
39+
});
40+
});
41+
42+
it("should keep value between items", () => {
43+
LabelStudio.params().config(perTagMIGTaxonomyConfig).data(simpleMIGData).withResult([]).init();
44+
45+
ImageView.waitForImage();
46+
47+
Taxonomy.open();
48+
Taxonomy.findItem("Choice 1").click();
49+
Taxonomy.close();
50+
Taxonomy.hasSelected("Choice 1");
51+
52+
ImageView.paginationNextBtn.click();
53+
54+
Taxonomy.hasSelected("Choice 1");
55+
});
56+
57+
it("should require result", () => {
58+
LabelStudio.params().config(requiredPerTagMIGTaxonomyConfig).data(simpleMIGData).withResult([]).init();
59+
60+
ImageView.waitForImage();
61+
62+
ToolBar.submitBtn.click();
63+
Modals.hasWarning(TAXONOMY_REQUIRED_WARNING);
64+
});
65+
66+
it("should not require result if there is one", () => {
67+
LabelStudio.params().config(requiredPerTagMIGTaxonomyConfig).data(simpleMIGData).withResult([]).init();
68+
69+
ImageView.waitForImage();
70+
71+
Taxonomy.open();
72+
Taxonomy.findItem("Choice 1").click();
73+
Taxonomy.close();
74+
75+
ToolBar.submitBtn.click();
76+
Modals.hasNoWarnings();
77+
});
78+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { LabelStudio, ImageView, Taxonomy, ToolBar, Modals, Sidebar } from "@humansignal/frontend-test/helpers/LSF";
2+
import {
3+
simpleImageTaxonomyConfig,
4+
simpleImageData,
5+
perTagTaxonomyResult,
6+
} from "../../../data/control_tags/per-item";
7+
import { commonBeforeEach } from "./common";
8+
9+
beforeEach(commonBeforeEach);
10+
11+
/* <Taxonomy /> */
12+
describe("Classification - single image - Taxonomy", () => {
13+
it("should create result without item_index", () => {
14+
LabelStudio.params().config(simpleImageTaxonomyConfig).data(simpleImageData).withResult([]).init();
15+
16+
ImageView.waitForImage();
17+
18+
Taxonomy.open();
19+
Taxonomy.findItem("Choice 2").click();
20+
Taxonomy.close();
21+
22+
LabelStudio.serialize().then((result) => {
23+
expect(result[0]).not.to.haveOwnProperty("item_index");
24+
});
25+
});
26+
27+
it("should load perTag result correctly", () => {
28+
LabelStudio.params()
29+
.config(simpleImageTaxonomyConfig)
30+
.data(simpleImageData)
31+
.withResult(perTagTaxonomyResult)
32+
.init();
33+
34+
ImageView.waitForImage();
35+
36+
Taxonomy.hasSelected("Choice 1");
37+
38+
LabelStudio.serialize().then((result) => {
39+
expect(result[0]).to.deep.include(perTagTaxonomyResult[0]);
40+
expect(result[0]).not.to.haveOwnProperty("item_index");
41+
});
42+
});
43+
});

0 commit comments

Comments
 (0)