Skip to content

Commit e432e4c

Browse files
authored
Merge pull request #304 from atlassian/issue/ARC-3020-update-iph-server-change
update IPH server change
2 parents 0eea563 + 677019f commit e432e4c

File tree

3 files changed

+35
-23
lines changed

3 files changed

+35
-23
lines changed

app/jenkins-for-jira-ui/src/components/InProductHelpDrawer/InProductHelp.test.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@ jest.mock('algoliasearch', () => {
1616
{
1717
id: '12323445345',
1818
objectID: '12323445345',
19-
title: 'Search Results',
19+
title: 'Search Results 1',
20+
body: '',
21+
bodyText: ''
22+
},
23+
{
24+
id: '22323445345',
25+
objectID: '22323445345',
26+
title: 'Search Results 2',
2027
body: '',
2128
bodyText: ''
2229
}
30+
2331
]
2432
}))
2533
}))
@@ -188,9 +196,9 @@ describe('InProductHelpDrawer Suite', () => {
188196
<InProductHelpDrawer
189197
isDrawerOpen
190198
setIsDrawerOpen={() => {}}
191-
searchResults={[{
192-
id: '1', title: 'Result 1', body: 'Body 1', bodyText: 'Body Text 1'
193-
}]}
199+
searchResults={[
200+
{id: '1', title: 'Result 1', body: 'Body 1', bodyText: 'Body Text 1'},
201+
{id: '2', title: 'Result 2', body: 'Body 2', bodyText: 'Body Text 2'}]}
194202
isLoading={false}
195203
searchQuery=""
196204
setIsLoading={() => {}}
@@ -202,8 +210,8 @@ describe('InProductHelpDrawer Suite', () => {
202210
);
203211

204212
await waitFor(() => {
205-
expect(screen.getByText('Result 1')).toBeInTheDocument();
206-
expect(screen.getByText('Body 1')).toBeInTheDocument();
213+
expect(screen.getByText('Result 2')).toBeInTheDocument();
214+
expect(screen.getByText('Body 2')).toBeInTheDocument();
207215
});
208216
});
209217

app/jenkins-for-jira-ui/src/components/InProductHelpDrawer/InProductHelpAction.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ const ALGOLIA_APP_ID = '8K6J5OJIQW';
4141
const { ALGOLIA_API_KEY, ENVIRONMENT } = envVars;
4242

4343
enum AlgoliaEnvironmentIndicies {
44-
Development = 'product_help_dev_copsi',
45-
Staging = 'product_help_stg_copsi',
46-
Production = 'product_help_prod_copsi'
44+
Development = 'product_help_dev',
45+
Staging = 'product_help_stg',
46+
Production = 'product_help_prod'
4747
}
4848

4949
const getIndexNameForEnvironment = (): string => {

app/jenkins-for-jira-ui/src/components/InProductHelpDrawer/InProductHelpDrawer.tsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,22 @@ export const InProductHelpDrawer = ({
150150
};
151151

152152
const results = Array.isArray(searchResults) ? searchResults : searchResults.hits;
153-
154-
const {
155-
tempDiv: tempDivBody
156-
} = (!isLoading && !hasError && replaceAnchorsWithSpanElement(results[0]?.body)) as {
157-
tempDiv: HTMLDivElement;
158-
};
159-
160-
const {
161-
tempDiv: tempDivBodyText
162-
} = (!isLoading && !hasError && replaceAnchorsWithSpanElement(results[0]?.bodyText)) as {
163-
tempDiv: HTMLDivElement;
164-
};
153+
let tempDivBody: HTMLDivElement | undefined;
154+
let tempDivBodyText: HTMLDivElement | undefined;
155+
if (results.length !== 2) {
156+
setHasError(true);
157+
} else {
158+
setHasError(false);
159+
const { tempDiv: tempDivB } = (!isLoading && !hasError && replaceAnchorsWithSpanElement(results[1]?.body)) as {
160+
tempDiv: HTMLDivElement;
161+
};
162+
tempDivBody = tempDivB;
163+
const { tempDiv: tempDivBT } = (
164+
!isLoading && !hasError && replaceAnchorsWithSpanElement(results[1]?.bodyText)) as {
165+
tempDiv: HTMLDivElement;
166+
};
167+
tempDivBodyText = tempDivBT;
168+
}
165169

166170
const search = useCallback(async (searchId: string) => {
167171
setIsLoading(true);
@@ -266,10 +270,10 @@ export const InProductHelpDrawer = ({
266270
hasError
267271
? <InProductHelpDrawerError onClick={() => search(searchQuery || innerSearchQuery)} />
268272
: <div className={cx(inProductHelpDrawerContainer)}>
269-
<h3 className={cx(inProductHelpDrawerTitle)}>{results[0]?.title}</h3>
273+
<h3 className={cx(inProductHelpDrawerTitle)}>{results[1]?.title}</h3>
270274
<div
271275
dangerouslySetInnerHTML={{
272-
__html: tempDivBody.innerHTML || tempDivBodyText.innerHTML || ''
276+
__html: tempDivBody?.innerHTML || tempDivBodyText?.innerHTML || ''
273277
}}
274278
/>
275279
</div>

0 commit comments

Comments
 (0)