Merge pull request #1615 from gabrielburnworth/staging

Fix Farmware ENV bug
pull/1616/head v8.2.4
Rick Carlino 2019-12-06 13:41:11 -06:00 committed by GitHub
commit 13b3971daf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -1,10 +1,5 @@
const mockDevice = { setUserEnv: jest.fn(() => Promise.resolve({})) };
jest.mock("../../../device", () => ({
getDevice: () => {
return mockDevice;
}
}));
jest.mock("../../../device", () => ({ getDevice: () => mockDevice }));
jest.mock("../actions", () => ({ scanImage: jest.fn() }));
jest.mock("../../images/actions", () => ({ selectImage: jest.fn() }));
@ -90,4 +85,14 @@ describe("<CameraCalibration/>", () => {
expect(p.saveFarmwareEnv)
.toHaveBeenCalledWith("CAMERA_CALIBRATION_camera_offset_x", "10");
});
it("saves string WeedDetectorConfig changes: API", () => {
const p = fakeProps();
p.shouldDisplay = () => true;
const wrapper = shallow(<CameraCalibration {...p} />);
wrapper.find("WeedDetectorConfig")
.simulate("change", "CAMERA_CALIBRATION_image_bot_origin_location", 4);
expect(p.saveFarmwareEnv).toHaveBeenCalledWith(
"CAMERA_CALIBRATION_image_bot_origin_location", "\"BOTTOM_LEFT\"");
});
});

View File

@ -12,6 +12,7 @@ import { WeedDetectorConfig } from "../weed_detector/config";
import { Feature } from "../../devices/interfaces";
import { namespace } from "../weed_detector";
import { t } from "../../i18next_wrapper";
import { formatEnvKey } from "../weed_detector/remote_env/translators";
export class CameraCalibration extends
React.Component<CameraCalibrationProps, {}> {
@ -23,7 +24,8 @@ export class CameraCalibration extends
saveEnvVar = (key: WDENVKey, value: number) =>
this.props.shouldDisplay(Feature.api_farmware_env)
? this.props.dispatch(this.props.saveFarmwareEnv(key, "" + value))
? this.props.dispatch(this.props.saveFarmwareEnv(
key, JSON.stringify(formatEnvKey(key, value))))
: envSave(key, value)
render() {