Skip to content

Commit

Permalink
Fix monitor tab crashing
Browse files Browse the repository at this point in the history
Signed-off-by: nofar9792 <nofar.cohen@logz.io>
  • Loading branch information
nofar9792 committed May 9, 2022
1 parent 89a6eb1 commit 3bccda9
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ exports[`<ServiceGraph> Base graph should be displayed 1`] = `
}
onMouseLeave={[Function]}
width={300}
xDomain={
Array [
1,
2,
]
}
>
<XAxis
attr="x"
Expand Down Expand Up @@ -190,6 +196,12 @@ exports[`<ServiceGraph> Base graph with custom color should be displayed 1`] = `
}
onMouseLeave={[Function]}
width={300}
xDomain={
Array [
1,
2,
]
}
>
<XAxis
attr="x"
Expand Down Expand Up @@ -300,6 +312,12 @@ exports[`<ServiceGraph> Base graph with horizontal lines should be displayed 1`]
}
onMouseLeave={[Function]}
width={300}
xDomain={
Array [
1,
2,
]
}
>
<HorizontalGridLines
attr="y"
Expand Down Expand Up @@ -414,6 +432,12 @@ exports[`<ServiceGraph> Base graph with legends should be displayed 1`] = `
}
onMouseLeave={[Function]}
width={300}
xDomain={
Array [
1,
2,
]
}
>
<XAxis
attr="x"
Expand Down Expand Up @@ -545,6 +569,12 @@ exports[`<ServiceGraph> Crosshair map test 1`] = `
}
onMouseLeave={[Function]}
width={300}
xDomain={
Array [
1,
2,
]
}
>
<XAxis
attr="x"
Expand Down Expand Up @@ -679,3 +709,34 @@ exports[`<ServiceGraph> Loading indicator is displayed 1`] = `
</div>
</div>
`;
exports[`<ServiceGraph> Loading indicator is displayed when xDomain is empty 1`] = `
<div
className="graph-container "
style={
Object {
"height": 242,
}
}
>
<h3
className="graph-header"
>
Hello Graph
</h3>
<div
className="center-placeholder"
style={
Object {
"height": 168,
"width": 300,
}
}
>
<LoadingIndicator
centered={true}
small={false}
/>
</div>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const props = {
loading: true,
marginClassName: '',
crosshairValues: [],
xDomain: [1, 2],
};

describe('<ServiceGraph>', () => {
Expand All @@ -42,6 +43,11 @@ describe('<ServiceGraph>', () => {
expect(wrapper).toMatchSnapshot();
});

it('Loading indicator is displayed when xDomain is empty', () => {
wrapper.setProps({ ...props, xDomain: [], loading: false });
expect(wrapper).toMatchSnapshot();
});

it('"No data" displayed', () => {
wrapper.setProps({ ...props, loading: false });
expect(wrapper).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class ServiceGraphImpl extends React.PureComponent<TProps> {
</XYPlot>
);

if (!loading) {
if (!loading && xDomain.length > 0) {
GraphComponent = metricsData === null ? noDataComponent : Plot;
}

Expand Down

0 comments on commit 3bccda9

Please sign in to comment.