Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 24 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ GEM
zeitwerk (~> 2.3)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
amq-protocol (2.3.2)
amq-protocol (2.3.3)
ast (2.4.2)
base64 (0.2.0)
bcrypt (3.1.20)
Expand Down Expand Up @@ -104,16 +104,16 @@ GEM
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.5.1)
diff-lcs (1.6.0)
digest-crc (0.7.0)
rake (>= 12.0.0, < 14.0.0)
discard (1.4.0)
activerecord (>= 4.2, < 9.0)
docile (1.4.1)
e2mmap (0.1.0)
erubi (1.13.1)
factory_bot (6.5.0)
activesupport (>= 5.0.0)
factory_bot (6.5.1)
activesupport (>= 6.1.0)
factory_bot_rails (6.4.4)
factory_bot (~> 6.5)
railties (>= 5.0.0)
Expand All @@ -139,20 +139,20 @@ GEM
retriable (>= 2.0, < 4.a)
google-apis-iamcredentials_v1 (0.22.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-storage_v1 (0.49.0)
google-apis-storage_v1 (0.50.0)
google-apis-core (>= 0.15.0, < 2.a)
google-cloud-core (1.7.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (2.2.1)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.4.0)
google-cloud-storage (1.54.0)
google-cloud-storage (1.55.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-core (~> 0.13)
google-apis-iamcredentials_v1 (~> 0.18)
google-apis-storage_v1 (~> 0.38)
google-apis-storage_v1 (>= 0.42)
google-cloud-core (~> 1.6)
googleauth (~> 1.9)
mini_mime (~> 1.0)
Expand All @@ -167,10 +167,11 @@ GEM
signet (>= 0.16, < 2.a)
hashdiff (1.1.2)
hashie (4.1.0)
httpclient (2.8.3)
httpclient (2.9.0)
mutex_m
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.9.1)
json (2.10.1)
jsonapi-renderer (0.2.2)
jwt (2.10.1)
base64
Expand All @@ -186,7 +187,7 @@ GEM
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
logger (1.6.5)
logger (1.6.6)
lograge (0.14.0)
actionpack (>= 4)
activesupport (>= 4)
Expand All @@ -210,23 +211,23 @@ GEM
mutex_m (0.3.0)
net-http (0.6.0)
uri
net-imap (0.5.5)
net-imap (0.5.6)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.0)
net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.2-aarch64-linux-gnu)
nokogiri (1.18.3-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.2-x86_64-linux-gnu)
nokogiri (1.18.3-x86_64-linux-gnu)
racc (~> 1.4)
orm_adapter (0.5.0)
os (1.1.4)
parser (3.3.7.0)
parser (3.3.7.1)
ast (~> 2.4.1)
racc
passenger (6.0.23)
Expand All @@ -247,7 +248,7 @@ GEM
hashie (~> 4.1)
multi_json (~> 1.15)
racc (1.8.1)
rack (2.2.10)
rack (2.2.11)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
rack-cors (2.0.2)
Expand Down Expand Up @@ -303,13 +304,13 @@ GEM
actionpack (>= 5.2)
railties (>= 5.2)
retriable (3.1.2)
rexml (3.4.0)
rollbar (3.6.0)
rexml (3.4.1)
rollbar (3.6.1)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.2)
rspec-core (3.13.3)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
Expand All @@ -331,7 +332,7 @@ GEM
scenic (1.8.0)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
scout_apm (5.6.0)
scout_apm (5.6.1)
parser
secure_headers (7.1.0)
set (1.1.1)
Expand Down Expand Up @@ -369,13 +370,13 @@ GEM
tzinfo-data (1.2025.1)
tzinfo (>= 1.0.0)
uber (0.1.0)
uri (1.0.2)
uri (1.0.3)
valid_url (0.0.4)
addressable
rails
warden (1.2.9)
rack (>= 2.0.9)
webmock (3.24.0)
webmock (3.25.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand All @@ -384,7 +385,7 @@ GEM
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.7.1)
zeitwerk (2.7.2)

PLATFORMS
aarch64-linux
Expand Down
3 changes: 2 additions & 1 deletion frontend/__test_support__/additional_mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ window.location = {
ancestorOrigins,
pathname: "", href: "", hash: "", search: "",
hostname: "", origin: "", port: "", protocol: "", host: "",
};
} as unknown as Location & string;

console.error = jest.fn(); // enzyme

Expand Down Expand Up @@ -43,6 +43,7 @@ global.mockNavigate = jest.fn(() => jest.fn());

jest.mock("react-router", () => ({
BrowserRouter: jest.fn(({ children }) => <div>{children}</div>),
MemoryRouter: jest.fn(({ children }) => <div>{children}</div>),
Route: jest.fn(({ children }) => <div>{children}</div>),
Routes: jest.fn(({ children }) => <div>{children}</div>),
useNavigate: () => mockNavigate,
Expand Down
21 changes: 13 additions & 8 deletions frontend/__test_support__/three_d_mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as THREE from "three";
import React, { ReactNode } from "react";
import { TransitionFn, UseSpringProps } from "@react-spring/three";
import { ThreeElements } from "@react-three/fiber";
import { Cloud, Clouds, Image, Tube } from "@react-three/drei";

const GroupForTests = (props: ThreeElements["group"]) =>
// @ts-expect-error Property does not exist on type JSX.IntrinsicElements
Expand Down Expand Up @@ -612,8 +613,9 @@ jest.mock("@react-three/drei", () => {
<div className={"line"}>{name}</div>,
Trail: ({ name }: { name: string }) =>
<div className={"trail"}>{name}</div>,
Tube: ({ name, children }: { name: string, children: ReactNode }) =>
<div className={"tube" + name}>{children}</div>,
Tube: (props: React.ComponentProps<typeof Tube>) =>
// @ts-expect-error geometry props not assignable to div
<div className={"tube"} {...props}>{props.children}</div>,
Center: ({ children }: { children: ReactNode }) =>
<div className={"center"}>{children}</div>,
Text3D: ({ children }: { children: ReactNode }) =>
Expand Down Expand Up @@ -642,12 +644,15 @@ jest.mock("@react-three/drei", () => {
<div className={"stats"}>{name}</div>,
Billboard: ({ name, children }: { name: string, children: ReactNode }) =>
<div className={"billboard" + name}>{children}</div>,
Image: ({ name, url }: { name: string, url: string }) =>
<div className={"image"}>{name} {url}</div>,
Clouds: ({ name }: { name: string }) =>
<div className={"clouds"}>{name}</div>,
Cloud: ({ name }: { name: string }) =>
<div className={"cloud"}>{name}</div>,
Image: (props: React.ComponentProps<typeof Image>) =>
// @ts-expect-error geometry props not assignable to div
<div className={"image"} {...props}>{props.name} {props.url}</div>,
Clouds: (props: React.ComponentProps<typeof Clouds>) =>
// @ts-expect-error geometry props not assignable to div
<div className={"clouds"} {...props}>{props.children}</div>,
Cloud: (props: React.ComponentProps<typeof Cloud>) =>
// @ts-expect-error geometry props not assignable to div
<div className={"cloud"} {...props} />,
OrthographicCamera: ({ name }: { name: string }) =>
<div className={"orthographic-camera"}>{name}</div>,
};
Expand Down
17 changes: 7 additions & 10 deletions frontend/__tests__/hotkeys_test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const mockSyncThunk = jest.fn();
jest.mock("../devices/actions", () => ({ sync: () => mockSyncThunk }));
jest.mock("../farm_designer/map/actions", () => ({ unselectPlant: jest.fn() }));

import { fakeState } from "../__test_support__/fake_state";
const mockState = fakeState();
Expand All @@ -16,10 +15,10 @@ import {
HotKey, HotKeys, HotKeysProps, hotkeysWithActions, toggleHotkeyHelpOverlay,
} from "../hotkeys";
import { sync } from "../devices/actions";
import { unselectPlant } from "../farm_designer/map/actions";
import { save } from "../api/crud";
import { Actions } from "../constants";
import { Path } from "../internal_urls";
import { mockDispatch } from "../__test_support__/fake_dispatch";

describe("hotkeysWithActions()", () => {
beforeEach(() => {
Expand Down Expand Up @@ -59,14 +58,12 @@ describe("hotkeysWithActions()", () => {
hotkeys[HotKey.addEvent].onKeyDown?.(e);
expect(navigate).toHaveBeenCalledWith(Path.farmEvents("add"));

hotkeysSettingsPath[HotKey.backToPlantOverview].onKeyDown?.(e);
expect(navigate).toHaveBeenCalledWith(Path.plants());
expect(unselectPlant).toHaveBeenCalled();
jest.clearAllMocks();
const hotkeysPhotosPath = hotkeysWithActions(navigate, dispatch, "photos");
hotkeysPhotosPath[HotKey.backToPlantOverview].onKeyDown?.(e);
expect(navigate).not.toHaveBeenCalled();
expect(unselectPlant).not.toHaveBeenCalled();
const hotkeysWithDispatch =
hotkeysWithActions(navigate, mockDispatch(dispatch), "");
hotkeysWithDispatch[HotKey.closePanel].onKeyDown?.(e);
expect(dispatch).toHaveBeenCalledWith({
type: Actions.SET_PANEL_OPEN, payload: false,
});
});
});

Expand Down
10 changes: 0 additions & 10 deletions frontend/css/farm_designer/farm_designer_panels.scss
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,6 @@
}
}

.additional-weed-properties {
li {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
align-items: center;
margin-top: 1rem;
}
}

.panel-section {
.delete {
height: 2rem;
Expand Down
24 changes: 15 additions & 9 deletions frontend/farm_designer/__tests__/map_size_setting_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,27 @@ jest.mock("../../config_storage/actions", () => ({

import React from "react";
import { MapSizeInputs, MapSizeInputsProps } from "../map_size_setting";
import { mount } from "enzyme";
import { render, screen } from "@testing-library/react";
import { setWebAppConfigValue } from "../../config_storage/actions";
import { NumericSetting } from "../../session_keys";
import { fakeWebAppConfig } from "../../__test_support__/fake_state/resources";
import { WebAppConfig } from "farmbot/dist/resources/configs/web_app";
import { changeBlurableInputRTL } from "../../__test_support__/helpers";

describe("<MapSizeInputs />", () => {
const fakeProps = (): MapSizeInputsProps => ({
getConfigValue: () => 100,
dispatch: jest.fn(),
});
const fakeProps = (config: WebAppConfig): MapSizeInputsProps => {
return {
getConfigValue: key => config[key],
dispatch: jest.fn(),
};
};

it("changes value", () => {
const wrapper = mount(<MapSizeInputs {...fakeProps()} />);
wrapper.find("input").last().simulate("change"), {
currentTarget: { value: 100 }
};
const config = fakeWebAppConfig();
const p = fakeProps(config.body);
render(<MapSizeInputs {...p} />);
const input = screen.getByDisplayValue("" + config.body.map_size_y);
changeBlurableInputRTL(input, "100");
expect(setWebAppConfigValue).toHaveBeenCalledWith(
NumericSetting.map_size_y, "100");
});
Expand Down
6 changes: 3 additions & 3 deletions frontend/farm_designer/map_size_setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
GetWebAppConfigValue, setWebAppConfigValue,
} from "../config_storage/actions";
import { t } from "../i18next_wrapper";
import { Row } from "../ui";
import { BlurableInput, Row } from "../ui";
import { NumericSetting } from "../session_keys";
import {
NumberConfigKey as WebAppNumberConfigKey,
Expand All @@ -20,12 +20,12 @@ interface LengthInputProps {
const LengthInput = (props: LengthInputProps) =>
<Row className="grid-2-col map-size-grid">
<label>{t(props.label)}</label>
<input
<BlurableInput
type="number"
name={props.setting}
className={getModifiedClassName(props.setting)}
value={"" + props.value}
onChange={e => props.dispatch(setWebAppConfigValue(
onCommit={e => props.dispatch(setWebAppConfigValue(
props.setting, e.currentTarget.value))} />
</Row>;

Expand Down
22 changes: 9 additions & 13 deletions frontend/hotkeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React from "react";
import { getLinks } from "./nav/nav_links";
import { sync } from "./devices/actions";
import { HotkeyConfig, useHotkeys, HotkeysDialog2 } from "@blueprintjs/core";
import { unselectPlant } from "./farm_designer/map/actions";
import { getPanelPath, PANEL_BY_SLUG } from "./farm_designer/panel_header";
import {
getPanelPath, PANEL_BY_SLUG, setPanelOpen,
} from "./farm_designer/panel_header";
import { t } from "./i18next_wrapper";
import { store } from "./redux/store";
import { save } from "./api/crud";
Expand All @@ -25,7 +26,7 @@ export enum HotKey {
navigateLeft = "navigateLeft",
addPlant = "addPlant",
addEvent = "addEvent",
backToPlantOverview = "backToPlantOverview",
closePanel = "closePanel",
openGuide = "openGuide",
}

Expand Down Expand Up @@ -54,9 +55,9 @@ const HOTKEY_BASE_MAP = (): HotkeyConfigs => ({
combo: "ctrl + shift + e",
label: t("Add Event"),
},
[HotKey.backToPlantOverview]: {
[HotKey.closePanel]: {
combo: "escape",
label: t("Back to plant overview"),
label: t("Close panel"),
},
[HotKey.openGuide]: {
combo: "shift + ?",
Expand Down Expand Up @@ -106,14 +107,9 @@ export const hotkeysWithActions = (
...hotkeysBase[HotKey.addEvent],
onKeyDown: () => { navigate(Path.farmEvents("add")); },
},
[HotKey.backToPlantOverview]: {
...hotkeysBase[HotKey.backToPlantOverview],
onKeyDown: () => {
if (slug != "photos") {
navigate(Path.plants());
dispatch(unselectPlant(dispatch));
}
},
[HotKey.closePanel]: {
...hotkeysBase[HotKey.closePanel],
onKeyDown: () => { dispatch(setPanelOpen(false)); },
},
[HotKey.openGuide]: hotkeysBase[HotKey.openGuide],
};
Expand Down
Loading