Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(query assist) show error toasts if summary is disabled #1480

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('<QueryAssistInput /> spec', () => {
);
});

it('should not call summarize if disabled', async () => {
it('should call add error toast if summarize is disabled', async () => {
coreRefs.summarizeEnabled = false;
httpMock.post.mockRejectedValueOnce({ body: { statusCode: 429 } });

Expand All @@ -98,6 +98,13 @@ describe('<QueryAssistInput /> spec', () => {
body: '{"question":"test-input","index":"selected-test-index"}',
});
expect(httpMock.post).not.toBeCalledWith(QUERY_ASSIST_API.SUMMARIZE, expect.anything());
expect(coreRefs.toasts?.addError).toBeCalledWith(
{
message: 'Request is throttled. Try again later or contact your administrator',
statusCode: 429,
},
{ title: 'Failed to generate results' }
);
});

it('should call summarize for generate and run errors', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
handleTimeRangePickerRefresh: (availability?: boolean, setSummaryStatus?: boolean) => void;
handleTimePickerChange: (timeRange: string[]) => Promise<void>;
tabId: string;
setNeedsUpdate: any;

Check warning on line 53 in public/components/event_analytics/explorer/query_assist/input.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
selectedIndex: Array<EuiComboBoxOptionOption<string | number | string[] | undefined>>;
nlqInput: string;
setNlqInput: React.Dispatch<React.SetStateAction<string>>;
Expand Down Expand Up @@ -106,7 +106,7 @@
if (explorerData.total > 0 || summaryData.responseForSummaryStatus === 'failure')
generateSummary();
})();
}, [summaryData.responseForSummaryStatus]);

Check warning on line 109 in public/components/event_analytics/explorer/query_assist/input.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'dispatch', 'explorerData.total', 'generateSummary', 'props.nlqInput', and 'props.tabId'. Either include them or remove the dependency array

const [barSelected, setBarSelected] = useState(false);

Expand All @@ -125,7 +125,7 @@
} else if (queryRedux.ollyQueryAssistant.length > 0) {
setAutoRun(true);
}
}, [queryRedux.ollyQueryAssistant]);

Check warning on line 128 in public/components/event_analytics/explorer/query_assist/input.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'autoRun' and 'runAndSummarize'. Either include them or remove the dependency array

// hide if not in a tab
if (props.tabId === '') return <>{props.children}</>;
Expand Down Expand Up @@ -251,7 +251,13 @@
await props.handleTimePickerChange([QUERY_ASSIST_START_TIME, 'now']);
await props.handleTimeRangePickerRefresh(undefined, true);
} catch (error) {
generateSummary({ isError: true, response: JSON.stringify((error as ResponseError).body) });
if (coreRefs.summarizeEnabled) {
generateSummary({ isError: true, response: JSON.stringify((error as ResponseError).body) });
} else {
coreRefs.toasts?.addError(formatError(error as ResponseError), {
title: 'Failed to generate results',
});
}
} finally {
setGeneratingOrRunning(false);
}
Expand Down
Loading