Skip to content

Commit

Permalink
Showing 91 changed files with 398 additions and 1,443 deletions.
1 change: 1 addition & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
config.perform_caching = false
config.public_file_server.enabled = false
config.serve_static_assets = true
config.assets.compile = false
# HACK AHEAD! Here's why:
# 1. FarmBot Inc. Uses Sendgrid for email.
# 2. FarmBot is an open source project that must be vendor neutral.
23 changes: 0 additions & 23 deletions frontend/__test_support__/user.ts

This file was deleted.

4 changes: 4 additions & 0 deletions frontend/__tests__/app_test.tsx
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@ jest.mock("../history", () => ({
push: jest.fn(),
}));

jest.mock("../hotkeys", () => ({
HotKeys: () => <div />,
}));

import React from "react";
import { RawApp as App, AppProps, mapStateToProps } from "../app";
import { mount } from "enzyme";
30 changes: 0 additions & 30 deletions frontend/__tests__/crash_page_test.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions frontend/__tests__/external_urls_test.ts
Original file line number Diff line number Diff line change
@@ -9,8 +9,6 @@ describe("ExternalUrl", () => {
.toEqual("https://raw.githubusercontent.com/FarmBot/farmbot_os/staging/FEATURE_MIN_VERSIONS.json");
expect(ExternalUrl.osReleaseNotes)
.toEqual("https://raw.githubusercontent.com/FarmBot/farmbot_os/staging/RELEASE_NOTES.md");
expect(ExternalUrl.latestRelease)
.toEqual("https://api.github.com/repos/FarmBot/farmbot_os/releases/latest");
expect(ExternalUrl.webAppRepo)
.toEqual("https://github.com/FarmBot/Farmbot-Web-App");
expect(ExternalUrl.gitHubFarmBot)
6 changes: 6 additions & 0 deletions frontend/__tests__/hotkeys_test.tsx
Original file line number Diff line number Diff line change
@@ -89,4 +89,10 @@ describe("<HotKeys />", () => {
const wrapper = shallow(<HotKeys {...fakeProps()} />);
expect(wrapper.html()).toEqual("<div class=\"hotkeys\"></div>");
});

it("renders default", () => {
mockPath = Path.mock(Path.designer());
const wrapper = shallow(<HotKeys {...fakeProps()} />);
expect(wrapper.html()).toEqual("<div class=\"hotkeys\"></div>");
});
});
20 changes: 4 additions & 16 deletions frontend/__tests__/interceptor_support_test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
jest.mock("../device", () => {
return { getDevice: () => ({ publish: jest.fn() }) };
});

import { isSafeError, inferUpdateId } from "../interceptor_support";
import { isSafeError } from "../interceptor_support";

describe("isSafeError", () => {
it("infers if it is safe to proceed", () => {
const notSafe = { response: { status: "four oh four" } };
expect(isSafeError(notSafe)).toBe(false);
const safe = { response: { status: 404 } };
expect(isSafeError(safe)).toBe(true);
});
});

describe("inferUpdateId", () => {
it("handles failure by returning `*`", () => {
expect(inferUpdateId("foo/123/456")).toBe("*");
expect(inferUpdateId(true as unknown as string)).toBe("*");
});

it("handles normal URLs", () => {
expect(inferUpdateId("foo/123")).toBe("123");
expect(isSafeError(undefined)).toBe(false);
expect(isSafeError([])).toBe(false);
expect(isSafeError({ response: "error" })).toBe(false);
});
});
2 changes: 1 addition & 1 deletion frontend/__tests__/resource_index_builder_test.ts
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ const STUB_RESOURCE: TaggedFarmEvent = {
};

test("buildResourceIndex - base case", () => {
const result1 = buildResourceIndex(FAKE_RESOURCES);
const result1 = buildResourceIndex();
const { index } = result1;
const OK_LENGTH = FAKE_RESOURCES.length;
expect(Object.keys(index.all).length).toBe(OK_LENGTH);
16 changes: 0 additions & 16 deletions frontend/__tests__/session_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
isNumericSetting,
isBooleanSetting,
safeBooleanSetting,
safeNumericSetting,
Session,
} from "../session";
@@ -37,20 +35,6 @@ describe("isNumericSetting", () => {
});
});

describe("isBooleanSetting", () => {
it("determines boolean-ness of settings", () => {
expect(isBooleanSetting("x_axis_inverted")).toBe(true);
expect(isBooleanSetting("no")).toBe(false);
});
});

describe("safeBooleanSetting", () => {
it("safely fetches bool", () => {
expect(() => safeBooleanSetting("no")).toThrow();
expect(safeBooleanSetting("x_axis_inverted")).toBe("x_axis_inverted");
});
});

describe("safeNumericSetting", () => {
it("safely returns num", () => {
expect(() => safeNumericSetting("no")).toThrow();
32 changes: 0 additions & 32 deletions frontend/connectivity/__tests__/ping_api_test.ts

This file was deleted.

16 changes: 1 addition & 15 deletions frontend/connectivity/__tests__/ping_mqtt_test.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ jest.mock("../index", () => ({
}));

import {
readPing,
startPinging,
PING_INTERVAL,
sendOutboundPing,
@@ -17,7 +16,7 @@ import { FarmBotInternalConfig } from "farmbot/dist/config";
import { pingNO } from "../index";
import { DeepPartial } from "redux";

let state: Partial<FarmBotInternalConfig> = {
const state: Partial<FarmBotInternalConfig> = {
LAST_PING_IN: 123,
LAST_PING_OUT: 456
};
@@ -36,19 +35,6 @@ function fakeBot(): Farmbot {
}

describe("ping util", () => {
it("reads LAST_PING_(IN|OUT)", () => {
const bot = fakeBot();
expect(readPing(bot, "in")).toEqual(123);
expect(readPing(bot, "out")).toEqual(456);
});

it("handles missing LAST_PING_(IN|OUT)", () => {
state = {};
const bot = fakeBot();
expect(readPing(bot, "in")).toEqual(undefined);
expect(readPing(bot, "out")).toEqual(undefined);
});

it("binds event handlers with startPinging()", async () => {
jest.useFakeTimers();
const bot = fakeBot();
21 changes: 0 additions & 21 deletions frontend/connectivity/ping_mqtt.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { Farmbot, uuid } from "farmbot";
import {
dispatchNetworkDown,
dispatchNetworkUp,
dispatchQosStart,
pingOK,
pingNO,
} from "./index";
import { isNumber } from "lodash";
import axios from "axios";
import { API } from "../api/index";
import { FarmBotInternalConfig } from "farmbot/dist/config";
import { now } from "../devices/connectivity/qos";

export const PING_INTERVAL = 2000;
@@ -21,15 +15,6 @@ export const PING_INTERVAL = 2000;
*/
const PING_TIMEOUT = 5500;

export const LAST_IN: keyof FarmBotInternalConfig = "LAST_PING_IN";
export const LAST_OUT: keyof FarmBotInternalConfig = "LAST_PING_OUT";
type Direction = "in" | "out";

export function readPing(bot: Farmbot, direction: Direction): number | undefined {
const val = bot.getConfig(direction === "out" ? LAST_OUT : LAST_IN);
return isNumber(val) ? val : undefined;
}

export function sendOutboundPing(bot: Farmbot) {
return new Promise((resolve, reject) => {
const id = uuid();
@@ -66,9 +51,3 @@ export function startPinging(bot: Farmbot) {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
setInterval(() => beep(bot), PING_INTERVAL);
}

export function pingAPI() {
const ok = () => dispatchNetworkUp("user.api", now());
const no = () => dispatchNetworkDown("user.api", now());
return axios.get(API.current.devicePath).then(ok, no);
}
Loading

0 comments on commit 59434bd

Please sign in to comment.