mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
chore(ui): use fatal error screen if there's only 1 upstream and it's down
This commit is contained in:
@@ -25,6 +25,18 @@ const Grid = observer(
|
||||
return <FatalError message={alertStore.status.error} />;
|
||||
}
|
||||
|
||||
if (
|
||||
alertStore.data.upstreams.counters &&
|
||||
alertStore.data.upstreams.counters.total === 1 &&
|
||||
alertStore.data.upstreams.counters.healthy === 0 &&
|
||||
alertStore.data.upstreams.instances[0] &&
|
||||
alertStore.data.upstreams.instances[0].error !== ""
|
||||
) {
|
||||
return (
|
||||
<FatalError message={alertStore.data.upstreams.instances[0].error} />
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
{alertStore.data.upstreams.instances
|
||||
|
||||
@@ -33,6 +33,24 @@ describe("<Grid />", () => {
|
||||
expect(tree.text()).toBe("<AlertGrid />");
|
||||
});
|
||||
|
||||
it("renders FatalError if there's only one upstream and it's unhealthy", () => {
|
||||
alertStore.data.upstreams = {
|
||||
counters: { total: 1, healthy: 0, failed: 1 },
|
||||
instances: [{ name: "am1", uri: "http://am1", error: "error" }]
|
||||
};
|
||||
const tree = ShallowGrid();
|
||||
expect(tree.text()).toBe("<FatalError />");
|
||||
});
|
||||
|
||||
it("renders FatalError if there's only one upstream and it's unhealthy but without any error", () => {
|
||||
alertStore.data.upstreams = {
|
||||
counters: { total: 1, healthy: 0, failed: 1 },
|
||||
instances: [{ name: "am1", uri: "http://am1", error: "" }]
|
||||
};
|
||||
const tree = ShallowGrid();
|
||||
expect(tree.text()).toBe("<AlertGrid />");
|
||||
});
|
||||
|
||||
it("renders UpstreamError for each unhealthy upstream", () => {
|
||||
alertStore.data.upstreams = {
|
||||
counters: { total: 3, healthy: 1, failed: 2 },
|
||||
|
||||
Reference in New Issue
Block a user