-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Synthetics] Improve loading state for metric items (#192930)
## Summary There are some cases where the latest addition to the overview grid causes metric items not to load for very small numbers of monitors. This PR aims to fix that issue, and to add a more robust loading state to the individual items to make it easier to track when there is a request in-flight. Additionally, it adds a type guard to the server code and an io-ts codec for verifying the safety of the code we use to generate our server responses. ## Testing Ensure that you see metric items load their duration graphs for small numbers (3 or less) of monitors, and that scrolling etc., continues working for larger ones. --------- Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit 7a7888b)
- Loading branch information
1 parent
c9c3e89
commit b47b3dc
Showing
11 changed files
with
315 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...thetics/components/monitors_page/overview/overview/metric_item/metric_item_extra.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render } from '../../../../../utils/testing/rtl_helpers'; | ||
import { MetricItemExtra } from './metric_item_extra'; | ||
import { fireEvent, waitFor } from '@testing-library/dom'; | ||
|
||
describe('<MetricItemExtra />', () => { | ||
it('renders the tooltip when there is content', async () => { | ||
const { getByText } = render( | ||
<MetricItemExtra | ||
stats={{ medianDuration: 10, avgDuration: 10, minDuration: 5, maxDuration: 15 }} | ||
/> | ||
); | ||
expect(getByText('Duration')).toBeInTheDocument(); | ||
fireEvent.mouseOver(getByText('Info')); | ||
await waitFor(() => expect(getByText('Median duration of last 50 checks')).toBeInTheDocument()); | ||
}); | ||
|
||
it('renders the empty tooltip when there is no content', async () => { | ||
const { getByText } = render( | ||
<MetricItemExtra | ||
stats={{ | ||
medianDuration: null, | ||
avgDuration: null, | ||
minDuration: null, | ||
maxDuration: null, | ||
}} | ||
/> | ||
); | ||
expect(getByText('Duration')).toBeInTheDocument(); | ||
fireEvent.mouseOver(getByText('Info')); | ||
await waitFor(() => expect(getByText('Metric data is not available')).toBeInTheDocument()); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.