Skip to content

Commit

Permalink
Merge pull request #1777 from sam-rice/#1770-v2-grower-page
Browse files Browse the repository at this point in the history
#1770: Implement V2 Grower Page
  • Loading branch information
dadiorchen authored May 30, 2024
2 parents 29b6e53 + f16cde9 commit d1a30e4
Show file tree
Hide file tree
Showing 29 changed files with 598 additions and 596 deletions.
58 changes: 32 additions & 26 deletions cypress/fixtures/capture.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
{
"id":"0c2d6e3a-d02a-4edf-bcdc-893e1f7a4817",
"reference_id":"999940",
"tree_id":"da4d3ed8-8655-44c5-a7ba-d4c45a0dfb10",
"image_url":"https://treetracker-production-images.s3.eu-central-1.amazonaws.com/2023.02.17.11.59.47_38.364922414000006_-122.51189396800001_a906ab31-5169-421c-8df3-be43f24d4d9c_IMG_20230217_111351_7976264471450881710.jpg","lat":"38.364922414000000","lon":"-122.51189396800000",
"estimated_geometric_location":"0101000020E610000019E5EADEC2A05EC08BDA14C7B52E4340",
"gps_accuracy":null,
"morphology":null,
"age":0,"note":"",
"attributes":null,
"domain_specific_data":null,
"created_at":"2023-07-31T02:24:26.446Z",
"updated_at":"2023-07-31T02:24:26.446Z",
"estimated_geographic_location":"0101000020E610000019E5EADEC2A05EC08BDA14C7B52E4340",
"device_configuration_id":"23d77b5b-2b87-42c7-93c3-8eb837541052",
"session_id":"39ab7585-6360-4d6a-9efa-52f0e35c4eaf",
"status":"active",
"grower_account_id":"c82cc807-8e35-418b-88ce-fda398cf4e89",
"planting_organization_id":null,"species_id":null,
"captured_at":"2023-02-17T19:15:19.000Z","token_id":null,"token_issued":null,
"tags":null,
"device_identifier":"something",
"wallet":"wallet10@test",
"grower_reference_id":null,
"wallet_name":null,
"wallet_token_id":null
}
"id": "0c2d6e3a-d02a-4edf-bcdc-893e1f7a4817",
"reference_id": "999940",
"tree_id": "da4d3ed8-8655-44c5-a7ba-d4c45a0dfb10",
"image_url": "https://treetracker-production-images.s3.eu-central-1.amazonaws.com/2023.02.17.11.59.47_38.364922414000006_-122.51189396800001_a906ab31-5169-421c-8df3-be43f24d4d9c_IMG_20230217_111351_7976264471450881710.jpg",
"lat": "38.364922414000000",
"lon": "-122.51189396800000",
"estimated_geometric_location": "0101000020E610000019E5EADEC2A05EC08BDA14C7B52E4340",
"gps_accuracy": null,
"morphology": null,
"age": 0,
"note": "",
"attributes": null,
"domain_specific_data": null,
"created_at": "2023-07-31T02:24:26.446Z",
"updated_at": "2023-07-31T02:24:26.446Z",
"estimated_geographic_location": "0101000020E610000019E5EADEC2A05EC08BDA14C7B52E4340",
"device_configuration_id": "23d77b5b-2b87-42c7-93c3-8eb837541052",
"session_id": "39ab7585-6360-4d6a-9efa-52f0e35c4eaf",
"status": "active",
"grower_account_id": "c82cc807-8e35-418b-88ce-fda398cf4e89",
"planting_organization_id": null,
"species_id": null,
"captured_at": "2023-02-17T19:15:19.000Z",
"token_id": null,
"token_issued": null,
"tags": null,
"device_identifier": "something",
"wallet": "wallet10@test",
"grower_reference_id": null,
"wallet_name": null,
"wallet_token_id": null
}
Binary file added cypress/fixtures/images/grower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 60 additions & 61 deletions cypress/fixtures/oldTree.json
Original file line number Diff line number Diff line change
@@ -1,63 +1,62 @@
{
"id": 186734,
"time_created": "2020-10-19T06:46:40.000Z",
"time_updated": "2020-10-19T06:46:40.000Z",
"missing": false,
"priority": false,
"cause_of_death_id": null,
"planter_id": 940,
"primary_location_id": null,
"settings_id": null,
"override_settings_id": null,
"dead": 0,
"photo_id": null,
"image_url": "https://treetracker-dev-images.s3.eu-central-1.amazonaws.com/2020.10.19.09.50.38_-5.508172399749922_38.98146973686408_6bebe71e-5369-4ae0-8c47-9eeff6599fb0_IMG_20201019_094615_7537040365910944885.jpg",
"certificate_id": null,
"estimated_geometric_location": "0101000020E610000027ECE2CCA07D43407E9F76585E0816C0",
"lat": "-5.508172399749922",
"lon": "38.98146973686408",
"gps_accuracy": 4,
"active": true,
"planter_photo_url": "https://treetracker-dev-images.s3.eu-central-1.amazonaws.com/2020.10.19.09.47.53_-5.508107173727935_38.981361706266256_39f0cc9d-0f13-4547-8142-150f15cabb67_IMG_20201019_094513_6614320100195503436.jpg",
"device_id": null,
"sequence": null,
"note": "",
"verified": false,
"uuid": "38572a5b-ac5b-4a77-943a-72254376735e",
"approved": false,
"status": "planted",
"cluster_regions_assigned": true,
"species_id": null,
"planting_organization_id": 1,
"payment_id": null,
"contract_id": null,
"token_issued": false,
"morphology": null,
"age": null,
"species": null,
"capture_approval_tag": null,
"rejection_reason": null,
"matching_hash": null,
"device_identifier": "651f04008af0d91a",
"images": {},
"domain_specific_data": {},
"token_id": null,
"name": null,
"earnings_id": null,
"species_name": null,
"first_name": "Sebastian ",
"last_name": "Gaertner",
"user_image_url": "https://treetracker-production.nyc3.digitaloceanspaces.com/2019.07.10.18.32.42_b4fad89a-10b6-40cc-a134-0085d0e581d2_IMG_20190710_183201_8089920786231467340.jpg",
"token_uuid": null,
"wallet": null,
"attributes": {
"dbh": "13",
"abs_step_count": "75351",
"delta_step_count": "0",
"height_color": "yellow",
"app_build": "1.4.0",
"app_flavor": "justdiggit",
"app_version": "113"
}
"id": 186734,
"time_created": "2020-10-19T06:46:40.000Z",
"time_updated": "2020-10-19T06:46:40.000Z",
"missing": false,
"priority": false,
"cause_of_death_id": null,
"planter_id": 940,
"primary_location_id": null,
"settings_id": null,
"override_settings_id": null,
"dead": 0,
"photo_id": null,
"image_url": "https://treetracker-dev-images.s3.eu-central-1.amazonaws.com/2020.10.19.09.50.38_-5.508172399749922_38.98146973686408_6bebe71e-5369-4ae0-8c47-9eeff6599fb0_IMG_20201019_094615_7537040365910944885.jpg",
"certificate_id": null,
"estimated_geometric_location": "0101000020E610000027ECE2CCA07D43407E9F76585E0816C0",
"lat": "-5.508172399749922",
"lon": "38.98146973686408",
"gps_accuracy": 4,
"active": true,
"planter_photo_url": "https://treetracker-dev-images.s3.eu-central-1.amazonaws.com/2020.10.19.09.47.53_-5.508107173727935_38.981361706266256_39f0cc9d-0f13-4547-8142-150f15cabb67_IMG_20201019_094513_6614320100195503436.jpg",
"device_id": null,
"sequence": null,
"note": "",
"verified": false,
"uuid": "38572a5b-ac5b-4a77-943a-72254376735e",
"approved": false,
"status": "planted",
"cluster_regions_assigned": true,
"species_id": null,
"planting_organization_id": 1,
"payment_id": null,
"contract_id": null,
"token_issued": false,
"morphology": null,
"age": null,
"species": null,
"capture_approval_tag": null,
"rejection_reason": null,
"matching_hash": null,
"device_identifier": "651f04008af0d91a",
"images": {},
"domain_specific_data": {},
"token_id": null,
"name": null,
"earnings_id": null,
"species_name": null,
"first_name": "Sebastian ",
"last_name": "Gaertner",
"user_image_url": "https://treetracker-production.nyc3.digitaloceanspaces.com/2019.07.10.18.32.42_b4fad89a-10b6-40cc-a134-0085d0e581d2_IMG_20190710_183201_8089920786231467340.jpg",
"token_uuid": null,
"wallet": null,
"attributes": {
"dbh": "13",
"abs_step_count": "75351",
"delta_step_count": "0",
"height_color": "yellow",
"app_build": "1.4.0",
"app_flavor": "justdiggit",
"app_version": "113"
}
}
37 changes: 17 additions & 20 deletions cypress/fixtures/tree186734.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{
"id":"da4d3ed8-8655-44c5-a7ba-d4c45a0dfb10",
"latest_capture_id":"b74f65d8-bd25-4ca4-a4f7-8ad50ba9a936",
"image_url":"https://treetracker-production-images.s3.eu-central-1.amazonaws.com/2022.01.27.00.19.43_8.430052995999995_-13.204408322000003_8ad6e7a1-3b35-4998-80c9-faccaa9faaf1_IMG_20220125_120721_490991521.jpg",
"lat":"8.430052996",
"lon":"-13.204408322",
"estimated_geometric_location":"0101000020E61000005E0A2435A8682AC0CDBB02E82FDC2040",
"gps_accuracy":0,
"morphology":null,
"age":null,"created_at":"2022-01-25T12:06:36.000Z",
"updated_at":"2022-01-25T12:06:36.000Z",
"estimated_geographic_location":"0101000020E61000005E0A2435A8682AC0CDBB02E82FDC2040",
"status":"active",
"attributes":null,
"species_id":null,
"planter_id":940,
"name":"The Best Tree"

"id": "da4d3ed8-8655-44c5-a7ba-d4c45a0dfb10",
"latest_capture_id": "b74f65d8-bd25-4ca4-a4f7-8ad50ba9a936",
"image_url": "https://treetracker-production-images.s3.eu-central-1.amazonaws.com/2022.01.27.00.19.43_8.430052995999995_-13.204408322000003_8ad6e7a1-3b35-4998-80c9-faccaa9faaf1_IMG_20220125_120721_490991521.jpg",
"lat": "8.430052996",
"lon": "-13.204408322",
"estimated_geometric_location": "0101000020E61000005E0A2435A8682AC0CDBB02E82FDC2040",
"gps_accuracy": 0,
"morphology": null,
"age": null,
"created_at": "2022-01-25T12:06:36.000Z",
"updated_at": "2022-01-25T12:06:36.000Z",
"estimated_geographic_location": "0101000020E61000005E0A2435A8682AC0CDBB02E82FDC2040",
"status": "active",
"attributes": null,
"species_id": null,
"grower_id": 940,
"name": "The Best Tree"
}



56 changes: 56 additions & 0 deletions cypress/tests/integration/growers/[growerid].cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import grower from '../../../../doc/examples/growers/100.json';
import tree from '../../../fixtures/tree186734.json';
import { prepareNocks, clearNocks } from '../nockRoutes';

const getStubbedImageUrl = (image) => {
const blob = Cypress.Blob.base64StringToBlob(image, 'image/png');
return Cypress.Blob.createObjectURL(blob);
};

beforeEach(() => {
clearNocks();

const stubs = {};
cy.fixture('images/grower.png').then((image) => {
stubs.grower = { ...grower, image_url: getStubbedImageUrl(image) };
});
cy.fixture('images/trees/10.jpg').then((image) => {
stubs.tree = { ...tree, image_url: getStubbedImageUrl(image) };
});
cy.wrap(null).then(() => {
prepareNocks(stubs);
});

cy.visit(`/growers/${grower.id}`, {
failOnStatusCode: false,
});
});

describe('Grower Page', () => {
it('renders with grower data', () => {
cy.url().should('include', `/growers/${grower.id}`);
cy.get('h6').eq(2).should('contain', 'Stanley K.');
cy.get('h2').first().should('have.text', 'Stanley K.');
cy.get('h2').eq(1).should('have.text', '1');
cy.get('h2').eq(2).should('have.text', '1');
cy.get('time').should('have.text', ' April 17, 2024');
cy.get('h6').eq(5).should('have.text', 'Capture - da4d...fb10');
cy.get('p').eq(13).should('have.text', grower.about);

// check that grower and tree images are present, but stubbed
cy.get('img')
.eq(1)
.invoke('attr', 'src')
.should('include', 'blob:http://localhost:3000/');
cy.get('img')
.eq(2)
.invoke('attr', 'src')
.should('include', 'blob:http://localhost:3000/');
cy.get('img')
.eq(3)
.invoke('attr', 'src')
.should('include', 'localhost:3000/');

cy.screenshot();
});
});
4 changes: 3 additions & 1 deletion cypress/tests/integration/moneytree.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ describe('Money Tree', () => {
const path = `/trees/${tree.id}`;
prepareNocks({ tree: { ...tree, species_name: 'Money Tree' } });
// nocksIntercept for extra data that I want to show up
cy.visit(path);
cy.visit(path, {
failOnStatusCode: false,
});
// misc code to confirm changes
cy.contains(`${tree.id}`);
});
Expand Down
Loading

0 comments on commit d1a30e4

Please sign in to comment.