update filter status
parent
a6ff17099f
commit
9158d53021
|
@ -96,18 +96,44 @@ describe("<Logs />", () => {
|
|||
expect(wrapper.instance().state.warn).toEqual(3);
|
||||
});
|
||||
|
||||
const fakeLogsState = () => ({
|
||||
assertion: 3,
|
||||
busy: 3,
|
||||
debug: 3,
|
||||
error: 3,
|
||||
fun: 3,
|
||||
info: 3,
|
||||
success: 3,
|
||||
warn: 3,
|
||||
});
|
||||
|
||||
it("shows overall filter status", () => {
|
||||
const wrapper = mount(<Logs {...fakeProps()} />);
|
||||
wrapper.setState({
|
||||
assertion: 3,
|
||||
busy: 3,
|
||||
debug: 3,
|
||||
error: 3,
|
||||
fun: 3,
|
||||
info: 3,
|
||||
success: 3,
|
||||
warn: 3,
|
||||
});
|
||||
wrapper.setState(fakeLogsState());
|
||||
const filterBtn = wrapper.find("button").first();
|
||||
expect(filterBtn.text().toLowerCase()).toEqual("filter");
|
||||
expect(filterBtn.hasClass("gray")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("shows filtered overall filter status", () => {
|
||||
const p = fakeProps();
|
||||
p.shouldDisplay = () => true;
|
||||
const wrapper = mount(<Logs {...p} />);
|
||||
const state = fakeLogsState();
|
||||
state.assertion = 2;
|
||||
wrapper.setState(state);
|
||||
const filterBtn = wrapper.find("button").first();
|
||||
expect(filterBtn.text().toLowerCase()).toEqual("filters active");
|
||||
expect(filterBtn.hasClass("green")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("shows unfiltered overall filter status", () => {
|
||||
const p = fakeProps();
|
||||
p.shouldDisplay = () => false;
|
||||
const wrapper = mount(<Logs {...p} />);
|
||||
const state = fakeLogsState();
|
||||
state.assertion = 2;
|
||||
wrapper.setState(state);
|
||||
const filterBtn = wrapper.find("button").first();
|
||||
expect(filterBtn.text().toLowerCase()).toEqual("filter");
|
||||
expect(filterBtn.hasClass("gray")).toBeTruthy();
|
||||
|
|
|
@ -17,6 +17,7 @@ import { NumberConfigKey } from "farmbot/dist/resources/configs/web_app";
|
|||
import { t } from "../i18next_wrapper";
|
||||
import { TimeSettings } from "../interfaces";
|
||||
import { timeFormatString } from "../util";
|
||||
import { Feature } from "../devices/interfaces";
|
||||
|
||||
/** Format log date and time for display in the app. */
|
||||
export const formatLogTime =
|
||||
|
@ -75,7 +76,9 @@ export class Logs extends React.Component<LogsProps, Partial<LogsState>> {
|
|||
/** Determine if log type filters are active. */
|
||||
get filterActive() {
|
||||
const filterKeys = Object.keys(this.state)
|
||||
.filter(x => !(x === "autoscroll"));
|
||||
.filter(x => !(x === "autoscroll"))
|
||||
.filter(x => this.props.shouldDisplay(Feature.assertion_block)
|
||||
|| x !== "assertion");
|
||||
const filterValues = filterKeys
|
||||
.map((key: keyof Filters) => this.state[key]);
|
||||
// Filters active if every log type level is not equal to 3 (max verbosity)
|
||||
|
|
Loading…
Reference in New Issue