diff --git a/webpack/css/farm_designer/farm_designer.scss b/webpack/css/farm_designer/farm_designer.scss
index 60e1c694e..4e2ded6b0 100644
--- a/webpack/css/farm_designer/farm_designer.scss
+++ b/webpack/css/farm_designer/farm_designer.scss
@@ -38,6 +38,10 @@
overflow: visible;
}
+.drop-area-background a {
+ cursor: default !important;
+}
+
.crop-drag-info-image {
width: 100%;
background-color: $translucent;
diff --git a/webpack/farm_designer/map/__tests__/grid_test.tsx b/webpack/farm_designer/map/__tests__/grid_test.tsx
index 78c99d234..917b04c00 100644
--- a/webpack/farm_designer/map/__tests__/grid_test.tsx
+++ b/webpack/farm_designer/map/__tests__/grid_test.tsx
@@ -1,14 +1,31 @@
+const mockHistory = jest.fn();
+jest.mock("../../../history", () => ({
+ history: {
+ push: mockHistory,
+ getCurrentLocation: jest.fn()
+ .mockImplementationOnce(() => { return { pathname: "//app/plants" } })
+ .mockImplementationOnce(() => { return { pathname: "//app/plants/1/edit" } })
+ .mockImplementationOnce(() => { return { pathname: "//app/plants/1" } })
+ }
+}));
+
+
import * as React from "react";
import { Grid } from "../grid";
import { shallow } from "enzyme";
import { GridProps } from "../interfaces";
describe("", () => {
+ beforeEach(function () {
+ jest.clearAllMocks();
+ });
+
function fakeProps(): GridProps {
return {
mapTransformProps: {
quadrant: 2, gridSize: { x: 3000, y: 1500 }
- }
+ },
+ dispatch: jest.fn()
};
}
@@ -21,4 +38,21 @@ describe("", () => {
expect(wrapper.find("#axis-values").find("text").length).toEqual(43);
});
+ it("closes plant info", () => {
+ const p = fakeProps();
+ const wrapper = shallow();
+ const gridArea = wrapper.find("g").first();
+ gridArea.simulate("click") // no plant info open
+ expect(mockHistory).not.toHaveBeenCalled();
+ expect(p.dispatch).not.toHaveBeenCalled();
+ gridArea.simulate("click") // plant edit open
+ expect(mockHistory).not.toHaveBeenCalled();
+ expect(p.dispatch).not.toHaveBeenCalled();
+ gridArea.simulate("click") // plant info open
+ expect(mockHistory).toHaveBeenCalledWith("/app/designer/plants");
+ expect(p.dispatch).toHaveBeenCalledWith({
+ payload: undefined, type: "SELECT_PLANT"
+ });
+ });
+
});
diff --git a/webpack/farm_designer/map/garden_map.tsx b/webpack/farm_designer/map/garden_map.tsx
index b5038e6fd..e6983fcb2 100644
--- a/webpack/farm_designer/map/garden_map.tsx
+++ b/webpack/farm_designer/map/garden_map.tsx
@@ -247,7 +247,8 @@ export class GardenMap extends
onMouseMove={this.drag}
onClick={this.click}>
+ mapTransformProps={mapTransformProps}
+ dispatch={this.props.dispatch} />
+ return