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

[Uptime] handle null duration on ping list #125438

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion x-pack/plugins/uptime/common/runtime_types/ping/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export type Tls = t.TypeOf<typeof TlsType>;
export const MonitorType = t.intersection([
t.type({
duration: t.type({
us: t.number,
us: t.union([t.number, t.null]),
}),
id: t.string,
status: t.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('PingList component', () => {
type: 'io',
},
monitor: {
duration: { us: 1370 },
duration: { us: null },
id: 'auto-tcp-0X81440A68E839814D',
ip: '255.255.255.0',
name: '',
Expand Down Expand Up @@ -162,7 +162,7 @@ describe('PingList component', () => {
},
"monitor": Object {
"duration": Object {
"us": 1370,
"us": null,
},
"id": "auto-tcp-0X81440A68E839814D",
"ip": "255.255.255.0",
Expand All @@ -186,6 +186,13 @@ describe('PingList component', () => {
});
});

describe('duration column', () => {
it('shows -- when duration is null', () => {
const { getByTestId } = render(<PingList />);
expect(getByTestId('ping-list-duration-unavailable-tool-tip')).toBeInTheDocument();
});
});

describe('formatDuration', () => {
it('returns zero for < 1 millisecond', () => {
expect(formatDuration(984)).toBe('0 ms');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { MouseEvent, useCallback, useEffect, useState } from 'react';
import { EuiBasicTable } from '@elastic/eui';
import { EuiBasicTable, EuiToolTip } from '@elastic/eui';
dominiqueclarke marked this conversation as resolved.
Show resolved Hide resolved
import { i18n } from '@kbn/i18n';
import moment from 'moment';
import { useHistory } from 'react-router-dom';
Expand Down Expand Up @@ -140,7 +140,18 @@ export function PingListTable({ loading, error, pings, pagination, onChange, fai
name: i18n.translate('xpack.uptime.pingList.durationMsColumnLabel', {
defaultMessage: 'Duration',
}),
render: (duration: number) => formatDuration(duration),
render: (duration: number | null) =>
duration ? (
formatDuration(duration)
) : (
<EuiToolTip
content={i18n.translate('xpack.uptime.pingList.durationColumnToolTip', {
defaultMessage: 'Duration is unavailable for journeys that do not finish executing',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this logic ever apply to lightweight checks? The content I have now is very specific to journeys

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be better to keep error not specific to journeys? Or even keep it as '--'

})}
>
<span data-test-subj="ping-list-duration-unavailable-tool-tip">{'--'}</span>
</EuiToolTip>
dominiqueclarke marked this conversation as resolved.
Show resolved Hide resolved
),
},
...(hasError
? [
Expand Down