Skip to content

Commit 3e2676a

Browse files
committed
feat: snapshot tests for image search
1 parent 608e704 commit 3e2676a

4 files changed

Lines changed: 2380 additions & 60 deletions

File tree

packages/web/src/components/search/SearchBox.js

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,8 +1669,13 @@ const SearchBox = (props) => {
16691669

16701670
// Set testing environment
16711671
useEffect(() => {
1672-
if (props.testMode) {
1672+
const { testMode, __showImageDropdown } = props;
1673+
1674+
if (testMode) {
16731675
setIsOpen(true);
1676+
if (__showImageDropdown) {
1677+
handleShowImageDropdown(new MouseEvent('click'), true);
1678+
}
16741679
if (props.enableAI) {
16751680
setShowAIScreen(true);
16761681
}
@@ -2234,8 +2239,11 @@ const SearchBox = (props) => {
22342239
{ suppressRefError: true },
22352240
)}
22362241
>
2237-
<InputGroup searchBox ref={_inputGroupRef} isOpen={isOpen || showImageDropdown}>
2238-
2242+
<InputGroup
2243+
searchBox
2244+
ref={_inputGroupRef}
2245+
isOpen={isOpen || showImageDropdown}
2246+
>
22392247
<ActionContainer>
22402248
{renderLeftIcons()}
22412249
{renderInputAddonBefore()}
@@ -2295,18 +2303,22 @@ const SearchBox = (props) => {
22952303
</ActionContainer>
22962304
</InputGroup>
22972305

2298-
{showImageDropdown ? <ImageDropdown
2299-
imageValue={currentImageValue}
2300-
onChange={v => setCurrentImageValue(v)}
2301-
onOutsideClick={(e) => {
2302-
// When the user is clicking on the camera
2303-
// icon which is outside the image modal
2304-
if (showImageDropdown) {
2305-
handleShowImageDropdown(e, false);
2306+
{showImageDropdown ? (
2307+
<ImageDropdown
2308+
__testMode={props.testMode}
2309+
imageValue={
2310+
!props.testMode ? currentImageValue : props.__dummyImage
23062311
}
2307-
}}
2308-
/> : null}
2309-
2312+
onChange={v => setCurrentImageValue(v)}
2313+
onOutsideClick={(e) => {
2314+
// When the user is clicking on the camera
2315+
// icon which is outside the image modal
2316+
if (showImageDropdown) {
2317+
handleShowImageDropdown(e, false);
2318+
}
2319+
}}
2320+
/>
2321+
) : null}
23102322

23112323
{props.expandSuggestionsContainer
23122324
&& renderSuggestionsDropdown(
@@ -2526,6 +2538,8 @@ SearchBox.propTypes = {
25262538
removeAIResponse: types.func,
25272539
// This is an internal prop just for testing
25282540
testMode: types.bool,
2541+
__showImageDropdown: types.bool,
2542+
__dummyImage: types.string,
25292543
};
25302544

25312545
SearchBox.defaultProps = {

0 commit comments

Comments
 (0)