Skip to content

Commit 1d35edc

Browse files
fix(imagehotspots): support testcases by watching mouseevent for ctrl
1 parent 04a88b0 commit 1d35edc

6 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/components/HotspotEditorModal/HotspotEditorTooltipTab/__snapshots__/HotspotEditorTooltipTab.story.storyshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT Exper
326326
/>
327327
</svg>
328328
<p>
329-
Click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.
329+
Hold the CTRL key and click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.
330330
</p>
331331
</div>
332332
</div>

src/components/HotspotEditorModal/__snapshots__/HotspotEditorModal.story.storyshot

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT Exper
400400
/>
401401
</svg>
402402
<p>
403-
Click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.
403+
Hold the CTRL key and click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.
404404
</p>
405405
</div>
406406
</div>
@@ -872,7 +872,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT Exper
872872
/>
873873
</svg>
874874
<p>
875-
Click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.
875+
Hold the CTRL key and click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.
876876
</p>
877877
</div>
878878
</div>
@@ -1808,7 +1808,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT Exper
18081808
/>
18091809
</svg>
18101810
<p>
1811-
Click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.
1811+
Hold the CTRL key and click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.
18121812
</p>
18131813
</div>
18141814
</div>
@@ -2280,7 +2280,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT Exper
22802280
/>
22812281
</svg>
22822282
<p>
2283-
Click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.
2283+
Hold the CTRL key and click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.
22842284
</p>
22852285
</div>
22862286
</div>

src/components/ImageCard/ImageHotspots.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ const ImageHotspots = ({
746746
cursor,
747747
setCursor,
748748
isEditable,
749-
callback: isCtrlPressed ? onAddHotspotPosition : undefined,
749+
callback: event.ctrlKey ? onAddHotspotPosition : undefined,
750750
});
751751
}
752752
}}

src/components/ImageCard/ImageHotspots.test.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,9 @@ describe('ImageHotspots', () => {
343343
selectedHotspots={[]}
344344
/>
345345
);
346-
347-
userEvent.click(screen.getByAltText(testImageText));
346+
userEvent.click(screen.getByAltText(testImageText), {
347+
ctrlKey: true,
348+
});
348349
expect(onAddHotspotPosition).not.toHaveBeenCalled();
349350

350351
rerender(
@@ -361,7 +362,9 @@ describe('ImageHotspots', () => {
361362
/>
362363
);
363364

364-
userEvent.click(screen.getByAltText(testImageText));
365+
userEvent.click(screen.getByAltText(testImageText), {
366+
ctrlKey: true,
367+
});
365368
// We aren't more specific about the callback param here due to
366369
// difficulties setting the event.pageX & event.pageY in the test,
367370
// which are needed for getting the position of the click correct.

src/components/ImageCard/__snapshots__/ImageHotspots.story.storyshot

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT/Image
2222
>
2323
<div
2424
onBlur={[Function]}
25+
onContextMenu={[Function]}
2526
onMouseOut={[Function]}
2627
style={
2728
Object {
@@ -45,7 +46,7 @@ exports[`Storybook Snapshot tests and console checks Storyshots Watson IoT/Image
4546
src="landscape.jpg"
4647
style={
4748
Object {
48-
"cursor": "crosshair",
49+
"cursor": "auto",
4950
"height": "auto",
5051
"left": undefined,
5152
"objectFit": null,

src/utils/__tests__/__snapshots__/publicAPI.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18379,7 +18379,7 @@ Map {
1837918379
"descriptionTextareaPlaceholderText": "Enter description for the tooltip",
1838018380
"iconDropdownLabelText": "Select an icon",
1838118381
"iconDropdownTitleText": "Icon",
18382-
"infoMessageText": "Click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.",
18382+
"infoMessageText": "Hold the CTRL key and click a position on the image to add a hotspot, or set the X and Y coordinates using dataitems and create hotspots at those positions.",
1838318383
"titleInputLabelText": "Title",
1838418384
"titleInputPlaceholderText": "Enter title for the tooltip",
1838518385
},
@@ -18631,7 +18631,7 @@ Map {
1863118631
"fontColorLabelText": "Font color",
1863218632
"fontSizeInvalidText": "Font Size is invalid",
1863318633
"fontSizeLabelText": "Font Size",
18634-
"infoMessageText": "Select an existing label on the image to edit it or click on an empty region to create one",
18634+
"infoMessageText": "Select an existing label on the image to edit it or hold the CTRL key and click on an empty region to create one",
1863518635
"italicLabelText": "Text Italic",
1863618636
"underlineLabelText": "Text Underline",
1863718637
},

0 commit comments

Comments
 (0)