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
11 changes: 6 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ commands:
command: |
mv .circleci/circle_envs .env
echo -e '\ndocker_volumes/db/pg_wal/*' >> .dockerignore
sudo docker compose build web
sudo docker compose run web gem install bundler
sudo docker compose run web bundle install
sudo docker compose run web npm install
sudo docker compose run web bundle exec rails db:create
sudo docker compose run web bundle exec rails db:migrate
sudo docker compose run web rake keys:generate
sudo docker compose run web bundle exec rake keys:generate
- run:
name: After cache update
command: |
Expand All @@ -52,11 +53,11 @@ commands:
- run:
name: Run Ruby Tests
command: |
sudo docker compose run web rspec spec --format progress --format RspecJunitFormatter --out /tmp/test-results/rspec/rspec.xml
sudo docker compose run web bundle exec rspec spec --format progress --format RspecJunitFormatter --out /tmp/test-results/rspec/rspec.xml
- run:
name: Check app coverage status
command: |
sudo docker compose run web rake check_file_coverage:api || [ $CIRCLE_BRANCH == "staging" ]
sudo docker compose run web bundle exec rake check_file_coverage:api || [ $CIRCLE_BRANCH == "staging" ]
when: always
- run:
name: Upload app coverage to Codecov
Expand Down Expand Up @@ -88,13 +89,13 @@ commands:
- run:
name: Check frontend coverage status
command: |
sudo docker compose run -e CIRCLE_SHA1="$CIRCLE_SHA1" -e CIRCLE_BRANCH="$CIRCLE_BRANCH" -e CIRCLE_PULL_REQUEST="$CIRCLE_PULL_REQUEST" web rake coverage:run || [ $CIRCLE_BRANCH == "staging" ]
sudo docker compose run -e CIRCLE_SHA1="$CIRCLE_SHA1" -e CIRCLE_BRANCH="$CIRCLE_BRANCH" -e CIRCLE_PULL_REQUEST="$CIRCLE_PULL_REQUEST" web bundle exec rake coverage:run || [ $CIRCLE_BRANCH == "staging" ]
when: always
- run:
name: Check frontend file coverage status
command: |
changed=$(git diff --name-only staging...HEAD | tr '\n' ',' | sed 's/,$//') || true
sudo docker compose run -e CHANGED_FILES="$changed" web rake check_file_coverage:fe || true
sudo docker compose run -e CHANGED_FILES="$changed" web bundle exec rake check_file_coverage:fe || true
when: always
- run:
name: Report frontend coverage to Coveralls
Expand Down
54 changes: 27 additions & 27 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GEM
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_model_serializers (0.10.15)
active_model_serializers (0.10.16)
actionpack (>= 4.1)
activemodel (>= 4.1)
case_transform (>= 0.2)
Expand All @@ -65,8 +65,8 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
addressable (2.8.8)
public_suffix (>= 2.0.2, < 8.0)
amq-protocol (2.3.4)
base64 (0.3.0)
bcrypt (3.1.20)
Expand All @@ -91,7 +91,7 @@ GEM
activerecord (>= 5.a)
database_cleaner-core (~> 2.0)
database_cleaner-core (2.0.1)
date (3.5.0)
date (3.5.1)
declarative (0.0.20)
delayed_job (4.1.13)
activesupport (>= 3.0, < 9.0)
Expand All @@ -118,16 +118,16 @@ GEM
factory_bot_rails (6.5.1)
factory_bot (~> 6.5)
railties (>= 6.1.0)
faker (3.5.2)
faker (3.5.3)
i18n (>= 1.8.11, < 2)
faraday (2.14.0)
faraday-net_http (>= 2.0, < 3.5)
json
logger
faraday-follow_redirects (0.4.0)
faraday (>= 1, < 3)
faraday-net_http (3.4.1)
net-http (>= 0.5.0)
faraday-net_http (3.4.2)
net-http (~> 0.5)
globalid (1.3.0)
activesupport (>= 6.1)
google-apis-core (1.0.2)
Expand All @@ -138,9 +138,9 @@ GEM
mini_mime (~> 1.1)
representable (~> 3.0)
retriable (~> 3.1)
google-apis-iamcredentials_v1 (0.25.0)
google-apis-iamcredentials_v1 (0.26.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-storage_v1 (0.57.0)
google-apis-storage_v1 (0.58.0)
google-apis-core (>= 0.15.0, < 2.a)
google-cloud-core (1.8.0)
google-cloud-env (>= 1.0, < 3.a)
Expand All @@ -149,7 +149,7 @@ GEM
base64 (~> 0.2)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.5.0)
google-cloud-storage (1.57.0)
google-cloud-storage (1.57.1)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-core (>= 0.18, < 2)
Expand All @@ -159,7 +159,7 @@ GEM
googleauth (~> 1.9)
mini_mime (~> 1.0)
google-logging-utils (0.2.0)
googleauth (1.15.1)
googleauth (1.16.0)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.2)
google-logging-utils (~> 0.1)
Expand All @@ -168,10 +168,10 @@ GEM
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
hashdiff (1.2.1)
hashie (4.1.0)
hashie (5.0.0)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.15.2)
json (2.17.1)
jsonapi-renderer (0.2.2)
jwt (3.1.2)
base64
Expand Down Expand Up @@ -205,13 +205,13 @@ GEM
marcel (1.1.0)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (5.26.0)
multi_json (1.17.0)
minitest (5.26.2)
multi_json (1.18.0)
mutations (0.9.1)
activesupport
mutex_m (0.3.0)
net-http (0.7.0)
uri
net-http (0.8.0)
uri (>= 0.11.1)
net-imap (0.5.12)
date
net-protocol
Expand Down Expand Up @@ -240,15 +240,15 @@ GEM
method_source (~> 1.0)
pry-rails (0.3.11)
pry (>= 0.13.0)
public_suffix (6.0.2)
rabbitmq_http_api_client (3.0.0)
public_suffix (7.0.0)
rabbitmq_http_api_client (3.2.2)
addressable (~> 2.7)
faraday (~> 2.9)
faraday-follow_redirects (~> 0.3)
hashie (~> 4.1)
hashie (>= 4.1)
multi_json (~> 1.15)
racc (1.8.1)
rack (2.2.20)
rack (2.2.21)
rack-attack (6.8.0)
rack (>= 1.0, < 4)
rack-cors (2.0.2)
Expand Down Expand Up @@ -305,7 +305,7 @@ GEM
railties (>= 5.2)
retriable (3.1.2)
rexml (3.4.4)
rollbar (3.6.2)
rollbar (3.7.0)
rspec (3.13.2)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand Down Expand Up @@ -362,14 +362,14 @@ GEM
thor (1.4.0)
thwait (0.2.0)
e2mmap
timeout (0.4.4)
timeout (0.5.0)
trailblazer-option (0.1.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2025.2)
tzinfo (>= 1.0.0)
uber (0.1.0)
uri (1.1.0)
uri (1.1.1)
valid_url (0.0.4)
addressable
rails
Expand All @@ -379,7 +379,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.9.1)
webrick (1.9.2)
websocket-driver (0.8.0)
base64
websocket-extensions (>= 0.1.0)
Expand Down Expand Up @@ -439,7 +439,7 @@ DEPENDENCIES
webmock

RUBY VERSION
ruby 3.4.7p58
ruby 3.4.7p58

BUNDLED WITH
2.7.2
4.0.1
11 changes: 11 additions & 0 deletions frontend/__test_support__/three_d_mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ jest.mock("../three_d_garden/components", () => ({
// @ts-expect-error Property does not exist on type JSX.IntrinsicElements
return <div {...props} />;
},
MeshPhongMaterial: (props: THREE.MeshPhongMaterial) => {
props.onBeforeCompile?.(
// eslint-disable-next-line max-len
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
{ uniforms: {}, vertexShader: "", fragmentShader: "" } as any,
// eslint-disable-next-line max-len
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
{} as any);
// @ts-expect-error Property does not exist on type JSX.IntrinsicElements
return <div {...props} />;
},
}));

jest.mock("three/examples/jsm/Addons.js", () => ({
Expand Down
15 changes: 14 additions & 1 deletion frontend/api/__tests__/crud_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { urlFor } from "../crud";
import { batchInitDirty, urlFor } from "../crud";
import { API } from "../api";
import { ResourceName } from "farmbot";
import { fakePlant } from "../../__test_support__/fake_state/resources";
import { Actions } from "../../constants";

describe("urlFor()", () => {
API.setBaseUrl("");
Expand All @@ -10,3 +12,14 @@ describe("urlFor()", () => {
.toThrow(/NewResourceWithoutURLHandler/);
});
});

describe("batchInitDirty()", () => {
it("inits", () => {
const { body } = fakePlant();
expect(batchInitDirty("Point", [body]))
.toEqual({
type: Actions.BATCH_INIT,
payload: [expect.objectContaining({ body })],
});
});
});
13 changes: 13 additions & 0 deletions frontend/api/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ export function init<T extends TaggedResource>(kind: T["kind"],
return { type: Actions.INIT_RESOURCE, payload: resource };
}

export const batchInitDirty =
<T extends TaggedResource>(kind: T["kind"], bodies: T["body"][]) => {
const resources = bodies.map(body => {
const resource = arrayUnwrap(newTaggedResource(kind, body));
resource.specialStatus = SpecialStatus.DIRTY;
return resource;
});
return {
type: Actions.BATCH_INIT,
payload: resources,
};
};

/** Initialize and save a new resource, returning the `id`.
* If you don't need the `id` returned, use `initSave` instead.
*/
Expand Down
1 change: 1 addition & 0 deletions frontend/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2446,6 +2446,7 @@ export enum Actions {
// Resources
DESTROY_RESOURCE_START = "DESTROY_RESOURCE_START",
DESTROY_RESOURCE_OK = "DESTROY_RESOURCE_OK",
BATCH_DESTROY_RESOURCE_OK = "BATCH_DESTROY_RESOURCE_OK",
INIT_RESOURCE = "INIT_RESOURCE",
BATCH_INIT = "BATCH_INIT",
SAVE_RESOURCE_OK = "SAVE_RESOURCE_OK",
Expand Down
4 changes: 2 additions & 2 deletions frontend/farm_designer/__tests__/three_d_garden_map_test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe("<ThreeDGardenMap />", () => {
label: "Strawberry Plant 1",
seed: 0,
size: 50,
spread: 0,
spread: 30,
x: 101,
y: 201,
}],
Expand Down Expand Up @@ -288,7 +288,7 @@ describe("convertPlants()", () => {
label: "Spinach",
seed: 0,
size: 50,
spread: 0,
spread: 20,
x: 110,
y: 201,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ describe("SpreadOverlapHelper functions", () => {
});

it("getContinuousColor()", () => {
expect(getContinuousColor(10, 100)).toEqual("rgba(51, 151, 0, 0.05)");
expect(getContinuousColor(20, 100)).toEqual("rgba(102, 202, 0, 0.1)");
expect(getContinuousColor(10, 100).string).toEqual("rgba(51, 151, 0, 0.05)");
expect(getContinuousColor(20, 100).string).toEqual("rgba(102, 202, 0, 0.1)");
});

it("getRadius()", () => {
Expand Down
Loading