Skip to content

Commit

Permalink
tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Oct 24, 2023
1 parent e204e90 commit 331ca61
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 23 deletions.
1 change: 0 additions & 1 deletion packages/kbn-search-response-warnings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export {
SearchResponseWarningsCallout,
SearchResponseWarningsEmptyPrompt,
} from './src/components/search_response_warnings';
export { ViewWarningButton } from './src/components/view_warning_button';

export { handleWarnings } from './src/handle_warnings';
export { hasUnsupportedDownsampledAggregationFailure } from './src/has_unsupported_downsampled_aggregation_failure';
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { SearchResponseWarning } from '../types';

export const searchResponseIncompleteWarningLocalCluster: SearchResponseWarning = {
type: 'incomplete',
message: 'The data might be incomplete or wrong.',
requestName: 'My request',
clusters: {
'(local)': {
status: 'partial',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
*/

import { getWarningsTitle, getWarningsDescription } from './i18n_utils';
import type { SearchResponseWarning } from '../../types';

describe('getWarningsTitle', () => {
test('Should show title for single non-successful cluster', () => {
const warnings = [
{
type: 'incomplete',
requestName: 'My request',
clusters: {
remote1: {
status: 'partial',
Expand All @@ -21,7 +23,7 @@ describe('getWarningsTitle', () => {
},
},
openInInspector: () => {},
},
} as SearchResponseWarning,
];
expect(getWarningsTitle(warnings)).toEqual('Problem with 1 cluster');
});
Expand All @@ -30,6 +32,7 @@ describe('getWarningsTitle', () => {
const warnings = [
{
type: 'incomplete',
requestName: 'My request',
clusters: {
remote1: {
status: 'partial',
Expand All @@ -43,7 +46,7 @@ describe('getWarningsTitle', () => {
},
},
openInInspector: () => {},
},
} as SearchResponseWarning,
];
expect(getWarningsTitle(warnings)).toEqual('Problem with 2 clusters');
});
Expand All @@ -52,6 +55,7 @@ describe('getWarningsTitle', () => {
const warnings = [
{
type: 'incomplete',
requestName: 'My request',
clusters: {
remote1: {
status: 'partial',
Expand All @@ -60,9 +64,10 @@ describe('getWarningsTitle', () => {
},
},
openInInspector: () => {},
},
} as SearchResponseWarning,
{
type: 'incomplete',
requestName: 'My request',
clusters: {
remote1: {
status: 'partial',
Expand All @@ -71,7 +76,7 @@ describe('getWarningsTitle', () => {
},
},
openInInspector: () => {},
},
} as SearchResponseWarning,
];
expect(getWarningsTitle(warnings)).toEqual('Problem with 1 cluster in 2 requests');
});
Expand All @@ -82,6 +87,7 @@ describe('getWarningsDescription', () => {
const warnings = [
{
type: 'incomplete',
requestName: 'My request',
clusters: {
remote1: {
status: 'partial',
Expand All @@ -90,7 +96,7 @@ describe('getWarningsDescription', () => {
},
},
openInInspector: () => {},
},
} as SearchResponseWarning,
];
expect(getWarningsDescription(warnings)).toEqual(
'This cluster had issues returning data. This might result in an incomplete visualization.'
Expand All @@ -101,6 +107,7 @@ describe('getWarningsDescription', () => {
const warnings = [
{
type: 'incomplete',
requestName: 'My request',
clusters: {
remote1: {
status: 'partial',
Expand All @@ -114,7 +121,7 @@ describe('getWarningsDescription', () => {
},
},
openInInspector: () => {},
},
} as SearchResponseWarning,
];
expect(getWarningsDescription(warnings)).toEqual(
'These clusters had issues returning data. This might result in an incomplete visualization.'
Expand All @@ -125,6 +132,7 @@ describe('getWarningsDescription', () => {
const warnings = [
{
type: 'incomplete',
requestName: 'My request',
clusters: {
remote1: {
status: 'partial',
Expand All @@ -133,7 +141,7 @@ describe('getWarningsDescription', () => {
},
},
openInInspector: () => {},
},
} as SearchResponseWarning,
];
expect(getWarningsDescription(warnings, 'table')).toEqual(
'This cluster had issues returning data. This might result in an incomplete table.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { i18n } from '@kbn/i18n';
import type { SearchResponseWarning } from '../../types';

export const viewDetailsLabel = i18n.translate('searchResponseWarnings.viewDetailsButtonLabel', {
defaultMessage: 'View details',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const ViewDetailsPopover = (props: Props) => {

if (props.warnings.length === 1) {
return (
<EuiLink color="primary" size="s" onClick={props.warnings[0].openInInspector}>
<EuiLink color="primary" onClick={props.warnings[0].openInInspector}>
{viewDetailsLabel}
</EuiLink>
);
Expand All @@ -55,7 +55,7 @@ export const ViewDetailsPopover = (props: Props) => {
<EuiPopover
id="ViewDetailsPopover"
button={
<EuiLink color="primary" size="s" onClick={() => setIsPopoverOpen(!isPopoverOpen)}>
<EuiLink color="primary" onClick={() => setIsPopoverOpen(!isPopoverOpen)}>
<>
{viewDetailsLabel} <EuiIcon type="arrowRight" size="s" />
</>
Expand Down
22 changes: 12 additions & 10 deletions packages/kbn-search-response-warnings/src/extract_warnings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ describe('extract search response warnings', () => {
aggregations: {},
};

expect(extractWarnings(response, mockInspectorService, mockRequestAdapter)).toEqual([
expect(extractWarnings(response, mockInspectorService, mockRequestAdapter, 'My request')).toEqual([
{
type: 'incomplete',
message: 'Results are partial and may be incomplete.',
requestName: 'My request',
clusters: {
'(local)': {
status: 'partial',
Expand All @@ -68,10 +68,10 @@ describe('extract search response warnings', () => {
_shards: {} as estypes.ShardStatistics,
hits: { hits: [] },
};
expect(extractWarnings(response, mockInspectorService, mockRequestAdapter)).toEqual([
expect(extractWarnings(response, mockInspectorService, mockRequestAdapter, 'My request')).toEqual([
{
type: 'incomplete',
message: 'Results are partial and may be incomplete.',
requestName: 'My request',
clusters: {
'(local)': {
status: 'partial',
Expand All @@ -97,7 +97,8 @@ describe('extract search response warnings', () => {
},
} as estypes.SearchResponse,
mockInspectorService,
mockRequestAdapter
mockRequestAdapter,
'My request',
);

expect(warnings).toEqual([]);
Expand Down Expand Up @@ -188,10 +189,10 @@ describe('extract search response warnings', () => {
aggregations: {},
};

expect(extractWarnings(response, mockInspectorService, mockRequestAdapter)).toEqual([
expect(extractWarnings(response, mockInspectorService, mockRequestAdapter, 'My request')).toEqual([
{
type: 'incomplete',
message: 'Results are partial and may be incomplete.',
requestName: 'My request',
clusters: response._clusters.details,
openInInspector: expect.any(Function),
},
Expand Down Expand Up @@ -242,10 +243,10 @@ describe('extract search response warnings', () => {
},
hits: { hits: [] },
};
expect(extractWarnings(response, mockInspectorService, mockRequestAdapter)).toEqual([
expect(extractWarnings(response, mockInspectorService, mockRequestAdapter, 'My request')).toEqual([
{
type: 'incomplete',
message: 'Results are partial and may be incomplete.',
requestName: 'My request',
clusters: response._clusters.details,
openInInspector: expect.any(Function),
},
Expand Down Expand Up @@ -297,7 +298,8 @@ describe('extract search response warnings', () => {
hits: { hits: [] },
} as estypes.SearchResponse,
mockInspectorService,
mockRequestAdapter
mockRequestAdapter,
'My request',
);

expect(warnings).toEqual([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('handleWarnings', () => {
request: {} as unknown as estypes.SearchRequest,
requestAdapter: {} as unknown as RequestAdapter,
requestId: '1234',
requestName: 'My request',
response: {
timed_out: false,
_shards: {
Expand All @@ -48,6 +49,7 @@ describe('handleWarnings', () => {
request: {} as unknown as estypes.SearchRequest,
requestAdapter: {} as unknown as RequestAdapter,
requestId: '1234',
requestName: 'My request',
response: {
took: 999,
timed_out: true,
Expand All @@ -72,6 +74,7 @@ describe('handleWarnings', () => {
request: {} as unknown as estypes.SearchRequest,
requestAdapter: {} as unknown as RequestAdapter,
requestId: '1234',
requestName: 'My request',
response: {
took: 999,
timed_out: true,
Expand All @@ -97,6 +100,7 @@ describe('handleWarnings', () => {
request: {} as unknown as estypes.SearchRequest,
requestAdapter: {} as unknown as RequestAdapter,
requestId: '1234',
requestName: 'My request',
response: {
took: 999,
timed_out: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('hasUnsupportedDownsampledAggregationFailure', () => {
expect(
hasUnsupportedDownsampledAggregationFailure({
type: 'incomplete',
message: 'The data might be incomplete or wrong.',
requestName: 'My request',
clusters: {
'(local)': {
status: 'partial',
Expand Down Expand Up @@ -49,7 +49,7 @@ describe('hasUnsupportedDownsampledAggregationFailure', () => {
expect(
hasUnsupportedDownsampledAggregationFailure({
type: 'incomplete',
message: 'The data might be incomplete or wrong.',
requestName: 'My request',
clusters: {
'(local)': {
status: 'partial',
Expand Down

0 comments on commit 331ca61

Please sign in to comment.