-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: LEAP-1191: Fix drawing tools scenarios with ctrl pressed (#6056)
Co-authored-by: Gondragos <[email protected]> Co-authored-by: hlomzik <[email protected]> Co-authored-by: triklozoid <[email protected]>
- Loading branch information
1 parent
027401e
commit 0d980a2
Showing
9 changed files
with
240 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
10 changes: 10 additions & 0 deletions
10
web/libs/editor/tests/integration/data/image_segmentation/ctrl.ts
This file contains 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,10 @@ | ||
export const imageToolsConfig = ` | ||
<View> | ||
<Image name="image" value="$image" /> | ||
<Rectangle name="rect" toName="image" /> | ||
<Ellipse name="ellipse" toName="image" /> | ||
<Polygon name="polygon" toName="image" /> | ||
</View>`; | ||
|
||
export const image = | ||
"https://htx-pub.s3.us-east-1.amazonaws.com/examples/images/nick-owuor-astro-nic-visuals-wDifg5xc9Z4-unsplash.jpg"; |
162 changes: 162 additions & 0 deletions
162
web/libs/editor/tests/integration/e2e/image_segmentation/ctrl.cy.ts
This file contains 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,162 @@ | ||
import { ImageView, LabelStudio, Sidebar } from "@humansignal/frontend-test/helpers/LSF"; | ||
import { image, imageToolsConfig } from "../../data/image_segmentation/ctrl"; | ||
|
||
describe("Image Segmentation - Drawing with ctrl pressed", () => { | ||
it("should add region to selection when something selected - Rectangle", () => { | ||
LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init(); | ||
|
||
ImageView.waitForImage(); | ||
ImageView.selectRectangleToolByButton(); | ||
cy.log("Prepare 2 rectangles"); | ||
ImageView.drawRectRelative(0.1, 0.1, 0.4, 0.8); | ||
ImageView.drawRectRelative(0.55, 0.1, 0.4, 0.8); | ||
cy.log("Select first rectangle"); | ||
ImageView.clickAtRelative(0.3, 0.3); | ||
cy.log("Add second rectangle to selection with ctrl pressed"); | ||
ImageView.clickAtRelative(0.7, 0.3, { metaKey: true }); | ||
Sidebar.hasSelectedRegions(2); | ||
}); | ||
|
||
it("should add region to selection when something selected - Ellipse", () => { | ||
LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init(); | ||
|
||
ImageView.waitForImage(); | ||
ImageView.selectEllipseToolByButton(); | ||
cy.log("Prepare 2 ellipses"); | ||
ImageView.drawRectRelative(0.25, 0.5, 0.2, 0.4); | ||
ImageView.drawRectRelative(0.75, 0.5, 0.2, 0.4); | ||
cy.log("Select first ellipse"); | ||
ImageView.clickAtRelative(0.25, 0.5); | ||
cy.log("Add second ellipse to selection with ctrl pressed"); | ||
ImageView.clickAtRelative(0.75, 0.5, { metaKey: true }); | ||
Sidebar.hasSelectedRegions(2); | ||
}); | ||
|
||
it("should add region to selection when something selected - Polygon", () => { | ||
LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init(); | ||
|
||
ImageView.waitForImage(); | ||
ImageView.selectPolygonToolByButton(); | ||
cy.log("Prepare 2 polygons"); | ||
ImageView.drawPolygonRelative( | ||
[ | ||
[0.1, 0.1], | ||
[0.4, 0.1], | ||
[0.25, 0.9], | ||
], | ||
true, | ||
); | ||
ImageView.drawPolygonRelative( | ||
[ | ||
[0.6, 0.1], | ||
[0.9, 0.1], | ||
[0.75, 0.9], | ||
], | ||
true, | ||
); | ||
cy.log("Select first polygon"); | ||
ImageView.clickAtRelative(0.25, 0.5); | ||
cy.log("Add second polygon to selection with ctrl pressed"); | ||
ImageView.clickAtRelative(0.75, 0.5, { metaKey: true }); | ||
Sidebar.hasSelectedRegions(2); | ||
}); | ||
|
||
it("should draw region through other region - Rectangle", () => { | ||
LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init(); | ||
|
||
ImageView.waitForImage(); | ||
ImageView.selectRectangleToolByButton(); | ||
cy.log("Prepare 2 rectangles"); | ||
ImageView.drawRectRelative(0.1, 0.1, 0.4, 0.8); | ||
ImageView.drawRectRelative(0.55, 0.1, 0.4, 0.8); | ||
cy.log("Draw rectangle through other rectangle with ctrl pressed"); | ||
ImageView.drawRectRelative(0.3, 0.3, 0.4, 0.4, { metaKey: true }); | ||
Sidebar.hasSelectedRegions(0); | ||
Sidebar.hasRegions(3); | ||
}); | ||
|
||
it("should draw region through other region - Ellipse", () => { | ||
LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init(); | ||
|
||
ImageView.waitForImage(); | ||
ImageView.selectEllipseToolByButton(); | ||
cy.log("Prepare 2 ellipses"); | ||
ImageView.drawRectRelative(0.25, 0.5, 0.2, 0.4); | ||
ImageView.drawRectRelative(0.75, 0.5, 0.2, 0.4); | ||
cy.log("Draw ellipse through other ellipse with ctrl pressed"); | ||
ImageView.drawRectRelative(0.25, 0.5, 0.4, 0.4, { metaKey: true }); | ||
Sidebar.hasSelectedRegions(0); | ||
Sidebar.hasRegions(3); | ||
}); | ||
|
||
it("should draw region through other region - Polygon", () => { | ||
LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init(); | ||
|
||
ImageView.waitForImage(); | ||
ImageView.selectPolygonToolByButton(); | ||
cy.log("Prepare 2 polygons"); | ||
ImageView.drawPolygonRelative( | ||
[ | ||
[0.1, 0.1], | ||
[0.4, 0.1], | ||
[0.25, 0.9], | ||
], | ||
true, | ||
); | ||
ImageView.drawPolygonRelative( | ||
[ | ||
[0.6, 0.1], | ||
[0.9, 0.1], | ||
[0.75, 0.9], | ||
], | ||
true, | ||
); | ||
cy.log("Draw polygon through other polygon with ctrl pressed"); | ||
ImageView.drawPolygonRelative( | ||
[ | ||
[0.25, 0.2], | ||
[0.75, 0.2], | ||
[0.75, 0.3], | ||
[0.25, 0.3], | ||
], | ||
true, | ||
{ metaKey: true }, | ||
); | ||
Sidebar.hasSelectedRegions(0); | ||
Sidebar.hasRegions(3); | ||
}); | ||
|
||
it("should add region to selection when something selected - MoveTool", () => { | ||
LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init(); | ||
|
||
ImageView.waitForImage(); | ||
ImageView.selectRectangleToolByButton(); | ||
cy.log("Prepare 2 rectangles"); | ||
ImageView.drawRectRelative(0.1, 0.1, 0.4, 0.8); | ||
ImageView.drawRectRelative(0.55, 0.1, 0.4, 0.8); | ||
cy.log("Switch to MoveTool"); | ||
ImageView.selectMoveToolByButton(); | ||
cy.log("Select first rectangle"); | ||
ImageView.clickAtRelative(0.3, 0.3); | ||
cy.log("Add second rectangle to selection with ctrl pressed"); | ||
ImageView.clickAtRelative(0.7, 0.3, { metaKey: true }); | ||
Sidebar.hasSelectedRegions(2); | ||
}); | ||
|
||
it("should add region to selection from scratch - MoveTool", () => { | ||
LabelStudio.params().config(imageToolsConfig).data({ image }).withResult([]).init(); | ||
|
||
ImageView.waitForImage(); | ||
ImageView.selectRectangleToolByButton(); | ||
cy.log("Prepare 2 rectangles"); | ||
ImageView.drawRectRelative(0.1, 0.1, 0.4, 0.8); | ||
ImageView.drawRectRelative(0.55, 0.1, 0.4, 0.8); | ||
cy.log("Switch to MoveTool"); | ||
ImageView.selectMoveToolByButton(); | ||
cy.log("Select first rectangle"); | ||
ImageView.clickAtRelative(0.3, 0.3, { metaKey: true }); | ||
cy.log("Add second rectangle to selection with ctrl pressed"); | ||
ImageView.clickAtRelative(0.7, 0.3, { metaKey: true }); | ||
Sidebar.hasSelectedRegions(2); | ||
}); | ||
}); |
This file contains 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