[APM] Avoid crashing transaction details page if trace duration is 0 (#31799) (#31851)

* [APM] Avoid crashing transaction details page if trace duration is 0

* Remove snapshot
This commit is contained in:
Søren Louv-Jansen 2019-02-23 00:33:37 +01:00 committed by GitHub
parent cf89c22149
commit 307e20a6a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

View file

@ -73,7 +73,7 @@ function TimelineAxis({ plotValues, agentMarks, traceRootDuration }) {
}}
/>
{traceRootDuration && (
{traceRootDuration > 0 && (
<LastTickValue
x={xScale(traceRootDuration)}
value={tickFormat(traceRootDuration)}

View file

@ -47,7 +47,7 @@ class VerticalLines extends PureComponent {
style={{ stroke: colors.gray3 }}
/>
{traceRootDuration && (
{traceRootDuration > 0 && (
<VerticalGridLines
tickValues={[traceRootDuration]}
style={{ stroke: colors.gray3 }}

View file

@ -44,4 +44,28 @@ describe('Timeline', () => {
expect(toJson(wrapper)).toMatchSnapshot();
});
it('should not crash if traceRootDuration is 0', () => {
const props = {
traceRootDuration: 0,
width: 1000,
duration: 0,
height: 116,
margins: {
top: 100,
left: 50,
right: 50,
bottom: 0
}
};
const mountTimeline = () =>
mount(
<StickyContainer>
<Timeline {...props} />
</StickyContainer>
);
expect(mountTimeline).not.toThrow();
});
});