Skip to content

Commit

Permalink
Merge pull request #815 from prymitive/fix-warning
Browse files Browse the repository at this point in the history
fix(ui): fix warning progress bar in overview modal
  • Loading branch information
prymitive authored Jul 11, 2019
2 parents bc01955 + 7d7d6d5 commit f990ed7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports[`<MountedLabelWithPercent /> matches snapshot 1`] = `
</span>
</span>
<div class=\\"progress silence-progress bg-white pr-1\\">
<div class=\\"progress-bar bg-success\\"
<div class=\\"progress-bar bg-warning\\"
role=\\"progressbar\\"
style=\\"width: 50%;\\"
aria-valuenow=\\"50\\"
Expand Down
2 changes: 1 addition & 1 deletion ui/src/Components/Labels/LabelWithPercent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const LabelWithPercent = inject("alertStore")(
const progressBarBg =
percent > 66
? "bg-danger"
: percent > 66
: percent > 33
? "bg-warning"
: "bg-success";

Expand Down
39 changes: 39 additions & 0 deletions ui/src/Components/Labels/LabelWithPercent/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,43 @@ describe("<MountedLabelWithPercent />", () => {
NewUnappliedFilter("foo!=bar")
);
});

it("uses bg-danger when percent is >66", () => {
const tree = mount(
<LabelWithPercent
alertStore={alertStore}
name={"foo"}
value={"bar"}
hits={25}
percent={67}
/>
);
expect(tree.html()).toMatch(/progress-bar bg-danger/);
});

it("uses bg-warning when percent is >33", () => {
const tree = mount(
<LabelWithPercent
alertStore={alertStore}
name={"foo"}
value={"bar"}
hits={25}
percent={66}
/>
);
expect(tree.html()).toMatch(/progress-bar bg-warning/);
});

it("uses bg-success when percent is <=33", () => {
const tree = mount(
<LabelWithPercent
alertStore={alertStore}
name={"foo"}
value={"bar"}
hits={25}
percent={33}
/>
);
expect(tree.html()).toMatch(/progress-bar bg-success/);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ exports[`<OverviewModalContent /> matches snapshot with labels to show 1`] = `
</span>
</span>
<div class=\\"progress silence-progress bg-white pr-1\\">
<div class=\\"progress-bar bg-success\\"
<div class=\\"progress-bar bg-warning\\"
role=\\"progressbar\\"
style=\\"width: 50%;\\"
aria-valuenow=\\"50\\"
Expand Down

0 comments on commit f990ed7

Please sign in to comment.