diff --git a/frontend/farmware/__tests__/farmware_test.tsx b/frontend/farmware/__tests__/farmware_test.tsx
index c78fb42b3..bb5962b19 100644
--- a/frontend/farmware/__tests__/farmware_test.tsx
+++ b/frontend/farmware/__tests__/farmware_test.tsx
@@ -53,6 +53,13 @@ describe("", () => {
expect(wrapper.text()).toContain("Take Photo");
});
+ it("renders photos page by default without farmware data", () => {
+ const p = fakeProps();
+ p.farmwares = {};
+ const wrapper = mount();
+ expect(wrapper.text()).toContain("Take Photo");
+ });
+
const TEST_DATA = {
"Photos": ["Take Photo"],
"take-photo": ["Take Photo"],
diff --git a/frontend/farmware/__tests__/set_active_farmware_by_name_test.ts b/frontend/farmware/__tests__/set_active_farmware_by_name_test.ts
index 765834e32..ca0f4b43f 100644
--- a/frontend/farmware/__tests__/set_active_farmware_by_name_test.ts
+++ b/frontend/farmware/__tests__/set_active_farmware_by_name_test.ts
@@ -37,6 +37,15 @@ describe("setActiveFarmwareByName", () => {
});
});
+ it("finds a farmware by name: other match", () => {
+ mockLastUrlChunk = "weed_detector";
+ setActiveFarmwareByName(["plant_detection"]);
+ expect(store.dispatch).toHaveBeenCalledWith({
+ type: Actions.SELECT_FARMWARE,
+ payload: "plant_detection"
+ });
+ });
+
it("handles undefined farmware names", () => {
mockLastUrlChunk = "some_farmware";
setActiveFarmwareByName([undefined]);
diff --git a/frontend/farmware/farmware_list.tsx b/frontend/farmware/farmware_list.tsx
index 1f7895d5a..60e5e7703 100644
--- a/frontend/farmware/farmware_list.tsx
+++ b/frontend/farmware/farmware_list.tsx
@@ -1,5 +1,4 @@
import * as React from "react";
-
import { urlFriendly } from "../util";
import { Actions } from "../constants";
import { Farmwares } from "./interfaces";
@@ -13,6 +12,7 @@ import { ShouldDisplay, Feature } from "../devices/interfaces";
import { initSave } from "../api/crud";
import { TaggedFarmwareInstallation } from "farmbot";
import { t } from "../i18next_wrapper";
+import { getFormattedFarmwareName } from "./index";
const DISPLAY_NAMES: Dictionary = {
"Photos": t("Photos"),
@@ -27,7 +27,7 @@ const farmwareListItem = (dispatch: Function, current: string | undefined) =>
type: Actions.SELECT_FARMWARE,
payload: farmwareName
});
- const selected = (farmwareName == current)
+ const selected = (farmwareName == getFormattedFarmwareName(current || ""))
|| (!current && farmwareName == "Photos")
? "selected" : "";
const displayName = Object.keys(DISPLAY_NAMES).includes(farmwareName)
@@ -107,8 +107,7 @@ export class FarmwareList
this.props.firstPartyFarmwareNames)} />
- {["Photos", "Camera Calibration", "Weed Detector"]
- .map(farmwareListItem(dispatch, current))}
+ {Object.keys(DISPLAY_NAMES).map(farmwareListItem(dispatch, current))}