Skip to content

Commit 9b6780e

Browse files
committed
fix(ga): issue #606 - update unit test and code
1 parent 1c97730 commit 9b6780e

File tree

11 files changed

+118
-95
lines changed

11 files changed

+118
-95
lines changed

packages/webapp/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"format": "prettier --write '**/*.{js,json,ts,tsx,yaml,yml}' --ignore-path ../../.prettierignore",
1515
"lint": "eslint . --ext .ts,.tsx",
1616
"watch": "node esbuild.js --watch",
17-
"test": "jest --maxWorkers=2 --silent"
17+
"test": "jest --maxWorkers=2 --silent --update-snapshot"
1818
},
1919
"devDependencies": {
2020
"@reduxjs/toolkit": "1.9.5",
@@ -27,6 +27,7 @@
2727
"@types/react-dom": "17.0.20",
2828
"@types/react-redux": "7.1.33",
2929
"@types/redux-mock-store": "1.0.6",
30+
"@types/uuid": "10.0.0",
3031
"autoprefixer": "10.4.16",
3132
"esbuild": "0.19.11",
3233
"esbuild-css-modules-plugin": "3.1.0",
@@ -52,7 +53,7 @@
5253
"@fluentui/react-focus": "8.8.37",
5354
"@fluentui/style-utilities": "8.10.1",
5455
"@fluentui/utilities": "8.13.23",
55-
"@sap-ux/ui-components": "1.17.5",
56+
"@sap-ux/ui-components": "1.17.9",
5657
"react-copy-to-clipboard": "5.1.0",
5758
"react-infinite-scroll-component": "6.1.0"
5859
}

packages/webapp/src/webview/ui/components/Header/SearchField/SearchField.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from 'react';
2-
2+
import { v4 as uuidv4 } from 'uuid';
33
import { UISearchBox } from '@sap-ux/ui-components';
44

55
import { fetchTreesData } from '../../../../features/Trees/Trees.utils';
@@ -26,6 +26,7 @@ export const SearchField: React.FC = (): JSX.Element => {
2626
const activeSearch: string = useAppSelector(getSearchQuery);
2727

2828
const [searchTerm, setSearchTerm] = useState<string>(activeSearch);
29+
const [uuidKey, setUuidKey] = useState<any>(uuidv4);
2930

3031
const onClear = (): void => {
3132
if (activeSearch !== '') {
@@ -43,9 +44,11 @@ export const SearchField: React.FC = (): JSX.Element => {
4344
};
4445

4546
useEffect(() => {
46-
if (activeSearch !== searchTerm) {
47+
if (activeScreen === 'HOME' && activeSearch === '') {
48+
setSearchTerm('');
49+
setUuidKey(uuidv4);
50+
} else if (activeSearch !== searchTerm) {
4751
setSearchTerm(activeSearch);
48-
4952
fetchTreesData(
5053
activeSearch,
5154
{
@@ -61,7 +64,7 @@ export const SearchField: React.FC = (): JSX.Element => {
6164
}, [activeSearch]);
6265

6366
return (
64-
<div className="guided-answer__header__searchField" id="search-field-container">
67+
<div className="guided-answer__header__searchField" id="search-field-container" key={uuidKey}>
6568
<UISearchBox
6669
className="tree-search-field"
6770
defaultValue={searchTerm}

packages/webapp/test/FeedbackSection/__snapshots__/FeedbackSection.test.tsx.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ exports[`Feedback Section component Should render a FeedbackSection component 1`
99
Please tell us if this answer was helpful
1010
</h3>
1111
<div
12-
class="ms-FocusZone css-109 feedback-subcontainer"
12+
class="ms-FocusZone css-110 feedback-subcontainer"
1313
data-focuszone-id="FocusZone0"
1414
role="tree"
1515
>

packages/webapp/test/GuidedAnswerNode/__snapshots__/GuidedAnswerNode.test.tsx.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exports[`<GuidedAnswerNode /> Should render a GuidedAnswerNode component 1`] = `
1515
class="guided-answer__node__commands"
1616
>
1717
<div
18-
class="ms-FocusZone css-109"
18+
class="ms-FocusZone css-110"
1919
data-focuszone-id="FocusZone0"
2020
/>
2121
</div>

packages/webapp/test/GuidedAnswerNode/__snapshots__/Middle.test.tsx.snap

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exports[`<Middle /> Should render a Middle component 1`] = `
1717
id="hr"
1818
/>
1919
<div
20-
class="ms-FocusZone css-109"
20+
class="ms-FocusZone css-110"
2121
data-focuszone-id="FocusZone0"
2222
>
2323
<div
@@ -35,7 +35,7 @@ exports[`<Middle /> Should render a Middle component 1`] = `
3535
</p>
3636
</div>
3737
<div
38-
class="ms-FocusZone css-109"
38+
class="ms-FocusZone css-110"
3939
data-focuszone-id="FocusZone1"
4040
>
4141
<div
@@ -84,7 +84,7 @@ exports[`<Middle /> Should render a Middle component with FeedbackDialogBox 1`]
8484
id="hr"
8585
/>
8686
<div
87-
class="ms-FocusZone css-109"
87+
class="ms-FocusZone css-110"
8888
data-focuszone-id="FocusZone37"
8989
>
9090
<div
@@ -102,7 +102,7 @@ exports[`<Middle /> Should render a Middle component with FeedbackDialogBox 1`]
102102
</p>
103103
</div>
104104
<div
105-
class="ms-FocusZone css-109"
105+
class="ms-FocusZone css-110"
106106
data-focuszone-id="FocusZone38"
107107
>
108108
<div
@@ -164,7 +164,7 @@ exports[`<Middle /> Should render a Middle component with NotSolvedMessage 1`] =
164164
class="guided-answer__node"
165165
>
166166
<div
167-
class="ms-FocusZone css-109 guided-answer__node"
167+
class="ms-FocusZone css-110 guided-answer__node"
168168
data-focuszone-id="FocusZone36"
169169
>
170170
<div
@@ -244,7 +244,7 @@ exports[`<Middle /> Should render a Middle component with enhancedBody 1`] = `
244244
id="hr"
245245
/>
246246
<div
247-
class="ms-FocusZone css-109"
247+
class="ms-FocusZone css-110"
248248
data-focuszone-id="FocusZone18"
249249
>
250250
<span
@@ -260,7 +260,7 @@ exports[`<Middle /> Should render a Middle component with enhancedBody 1`] = `
260260
</p>
261261
</div>
262262
<div
263-
class="ms-FocusZone css-109"
263+
class="ms-FocusZone css-110"
264264
data-focuszone-id="FocusZone19"
265265
>
266266
<div

packages/webapp/test/Header/__snapshots__/Filters.test.tsx.snap

+18-18
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,37 @@ exports[`<Filters /> Should render a Filters component - Open components filter
88
id="filters"
99
>
1010
<button
11-
class="ms-Button ms-Button--icon filter-button root-124"
11+
class="ms-Button ms-Button--icon filter-button root-125"
1212
data-is-focusable="true"
1313
id="filter-products"
1414
title="Filter Products"
1515
type="button"
1616
>
1717
<span
18-
class="ms-Button-flexContainer flexContainer-110"
18+
class="ms-Button-flexContainer flexContainer-111"
1919
data-automationid="splitbuttonprimary"
2020
>
2121
<i
2222
aria-hidden="true"
23-
class="ms-Icon root-105 ms-Button-icon icon-125"
23+
class="ms-Icon root-105 ms-Button-icon icon-126"
2424
data-icon-name="Table"
2525
/>
2626
</span>
2727
</button>
2828
<button
29-
class="ms-Button ms-Button--icon filter-button root-124"
29+
class="ms-Button ms-Button--icon filter-button root-125"
3030
data-is-focusable="true"
3131
id="filter-components"
3232
title="Filter Components"
3333
type="button"
3434
>
3535
<span
36-
class="ms-Button-flexContainer flexContainer-110"
36+
class="ms-Button-flexContainer flexContainer-111"
3737
data-automationid="splitbuttonprimary"
3838
>
3939
<i
4040
aria-hidden="true"
41-
class="ms-Icon root-105 ms-Button-icon icon-125"
41+
class="ms-Icon root-105 ms-Button-icon icon-126"
4242
data-icon-name="IdTag"
4343
/>
4444
</span>
@@ -58,37 +58,37 @@ exports[`<Filters /> Should render a Filters component - Open products filter di
5858
id="filters"
5959
>
6060
<button
61-
class="ms-Button ms-Button--icon filter-button root-124"
61+
class="ms-Button ms-Button--icon filter-button root-125"
6262
data-is-focusable="true"
6363
id="filter-products"
6464
title="Filter Products"
6565
type="button"
6666
>
6767
<span
68-
class="ms-Button-flexContainer flexContainer-110"
68+
class="ms-Button-flexContainer flexContainer-111"
6969
data-automationid="splitbuttonprimary"
7070
>
7171
<i
7272
aria-hidden="true"
73-
class="ms-Icon root-105 ms-Button-icon icon-125"
73+
class="ms-Icon root-105 ms-Button-icon icon-126"
7474
data-icon-name="Table"
7575
/>
7676
</span>
7777
</button>
7878
<button
79-
class="ms-Button ms-Button--icon filter-button root-124"
79+
class="ms-Button ms-Button--icon filter-button root-125"
8080
data-is-focusable="true"
8181
id="filter-components"
8282
title="Filter Components"
8383
type="button"
8484
>
8585
<span
86-
class="ms-Button-flexContainer flexContainer-110"
86+
class="ms-Button-flexContainer flexContainer-111"
8787
data-automationid="splitbuttonprimary"
8888
>
8989
<i
9090
aria-hidden="true"
91-
class="ms-Icon root-105 ms-Button-icon icon-125"
91+
class="ms-Icon root-105 ms-Button-icon icon-126"
9292
data-icon-name="IdTag"
9393
/>
9494
</span>
@@ -107,40 +107,40 @@ exports[`<Filters /> Should render a Filters component 1`] = `
107107
>
108108
<button
109109
aria-disabled="true"
110-
class="ms-Button ms-Button--icon is-disabled filter-button root-109"
110+
class="ms-Button ms-Button--icon is-disabled filter-button root-110"
111111
data-is-focusable="false"
112112
disabled=""
113113
id="filter-products"
114114
title="Filter Products"
115115
type="button"
116116
>
117117
<span
118-
class="ms-Button-flexContainer flexContainer-110"
118+
class="ms-Button-flexContainer flexContainer-111"
119119
data-automationid="splitbuttonprimary"
120120
>
121121
<i
122122
aria-hidden="true"
123-
class="ms-Icon root-105 ms-Button-icon icon-112"
123+
class="ms-Icon root-105 ms-Button-icon icon-113"
124124
data-icon-name="Table"
125125
/>
126126
</span>
127127
</button>
128128
<button
129129
aria-disabled="true"
130-
class="ms-Button ms-Button--icon is-disabled filter-button root-109"
130+
class="ms-Button ms-Button--icon is-disabled filter-button root-110"
131131
data-is-focusable="false"
132132
disabled=""
133133
id="filter-components"
134134
title="Filter Components"
135135
type="button"
136136
>
137137
<span
138-
class="ms-Button-flexContainer flexContainer-110"
138+
class="ms-Button-flexContainer flexContainer-111"
139139
data-automationid="splitbuttonprimary"
140140
>
141141
<i
142142
aria-hidden="true"
143-
class="ms-Icon root-105 ms-Button-icon icon-112"
143+
class="ms-Icon root-105 ms-Button-icon icon-113"
144144
data-icon-name="IdTag"
145145
/>
146146
</span>

0 commit comments

Comments
 (0)