Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Fofang 07 E2E #163

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2cb7952
Added HTML sub-tab to FD2 School Tab
anemervontage Sep 15, 2023
0ed148b
Added content to HTML.html file
anemervontage Sep 15, 2023
342d26c
Added italics and breaks to HTML.html file
anemervontage Sep 15, 2023
43a64ad
Added Title and Buttom to HTML.html
anemervontage Sep 15, 2023
f88991c
Added crops dropdown to HTML.html
anemervontage Sep 15, 2023
0ac4be5
Added area dropdown to HTML.html
anemervontage Sep 15, 2023
df9ae6e
Added start and end date ranges to HTML.html
anemervontage Sep 15, 2023
6ab5105
Added table to HTML.html
anemervontage Sep 15, 2023
6868f93
Added Vue1 subtab and Vue1.html file
anemervontage Sep 22, 2023
537e9f9
Made sample report title text dynamic
anemervontage Sep 24, 2023
15cbffa
Made startdate, enddate, and crop dropdowns dynamic
anemervontage Sep 24, 2023
ad131ea
Added Temp text for title if empty
anemervontage Sep 27, 2023
1026af4
populated crops and areas dropdown using arrays in vue
anemervontage Sep 27, 2023
afd054f
populated table using data from objects in vue
anemervontage Sep 27, 2023
6cd591e
added vue dev tools
anemervontage Sep 27, 2023
665aa67
Added Vue2 subtab and Vue2.html file
anemervontage Sep 29, 2023
1167fb5
Added click event on button to generate table
anemervontage Sep 29, 2023
6102cf4
created function for generating table
anemervontage Sep 29, 2023
e97b052
added row column to table with index
anemervontage Sep 29, 2023
d558d41
made table show only if generated and added message when empty
anemervontage Sep 29, 2023
3d59e01
made start and end dates consistent
anemervontage Sep 29, 2023
c0ee99d
Added API subtab to FarmData
anemervontage Oct 29, 2023
fa6ca08
added data fields for farm, language and user in vue
anemervontage Oct 30, 2023
081b54b
Generate button generateds data for farm, language, user
anemervontage Oct 30, 2023
cab4009
Added Axios APi to html page
anemervontage Oct 31, 2023
5acd265
made farm, user, and language data be grabbed from api
anemervontage Oct 31, 2023
d3077a4
populated crop dropdown with data from api
anemervontage Oct 31, 2023
8cc3feb
Added API2 subtab to HTML
anemervontage Oct 31, 2023
b2b273f
Added script to pull harvest logs from API into array in HTML
anemervontage Oct 31, 2023
1d3dd48
Populated report table with harvest log info from API
anemervontage Oct 31, 2023
321ec50
completed cypress tutorial
anemervontage Nov 1, 2023
98a1346
Added E2E subtab to HTML
anemervontage Nov 3, 2023
8aa8a1f
Created Farmdata E2E test using Cypress
anemervontage Nov 3, 2023
503eb83
Created Farmdata E2E test for start and end date default values
anemervontage Nov 3, 2023
9e38006
Created Farmdata E2E test for crop dropdown element
anemervontage Nov 3, 2023
c7cef9e
Created Farmdata E2E test for Generate Button
anemervontage Nov 3, 2023
4430ca8
Update Farmdata E2E test for Generate Button to include tests for rep…
anemervontage Nov 3, 2023
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
152 changes: 152 additions & 0 deletions farmdata2/farmdata2_modules/fd2_school/API/api.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<html>

<div id="vue_spike2" v-cloak>
<body>
<p>
<h1>Harvest Report</h1>
<p>This page is a <i>mockup</i> of a simplified harvest report.</p>


<label for="title">Title:</label>
<input v-model="title" type="text" id="title" name="title"/>

<br>

<div>
<label for="startdate">Start:</label>
<input type="date" id="startdate" name="start_date"
v-model ="startDate" min="2014-01-01" :max="endDate"/>
<label for="enddate">End:</label>
<input type="date" id="enddate" name="end_date"
v-model ="endDate" :min="startDate" max="2022-01-01"/>
</div>

<br>

<div>
<label for="crops">Crop:</label>
<select v-model="crops" id="crops" name="crops">
<option v-for="crops in cropNames">{{ crops }}</option>
</select>

<label for="area">Area:</label>
<select v-model="areas" id ="area" name="area">
<option v-for="area in areas">{{ area }}</option>
</select>
</div>

<br>

<button type="button" v-on:click="saveReport" @click='changeState("activeReport")'>Generate Report</button>

<hr>


<v-cloak><h1>{{ title ? title : "Mock Harvest Report" }}</h1></v-cloak>


<p>Details:</p>

<ul>
<li><strong>Farm:</strong> {{ farm }}</li>
<li><strong>User:</strong> {{ user }}</li>
<li><strong>Language:</strong> {{ language }}</li>
</ul>

<br>

<ul>
<li><strong>Start:</strong> {{ startDate }}</li>
<li><strong>End:</strong> {{ endDate }}</li>
<li><strong>Crop:</strong> {{ crops }}</li>
</ul>

<p v-if='state === "nullReport" || harvestLogs.length === 0'>There are no matching records</p>
<div v-if='state === "activeReport" && !(harvestLogs.length === 0)' >
<table border=1>
<tr>
<th>Row</th>
<th>Date</th>
<th>Area</th>
<th>Crop</th>
<th>Yield</th>
<th>Units</th>
</tr>
<tr v-for="(cell,index) in harvestLogs">
<td>{{ index + 1 }}</td>
<td>{{ cell.date }}</td>
<td>{{ cell.area }}</td>
<td>{{ cell.crop }}</td>
<td>{{ cell.yield }}</td>
<td>{{ cell.units }}</td>
</tr>
</table>


</div>
</body>
</div>

<script>
var vueSpike = new Vue({
el: "#vue_spike2",
data: {
farm: "",
user: "",
language: "",
state: "nullReport",
title: "My Sample Harvest Report",
startDate: "2020-05-05",
endDate: "2020-05-15",
crops: ["Kale", "Peas", "Broccoli"],
areas: ["All", "Chuau-1", "SQ7"],
harvestLogs: [
],
idToCropMap: new Map()
},
methods: {
saveReport: function(){
axios.get('/farm.json') // this line sends the request.
.then((response) => {
this.language = response.data.languages.en.name;
this.user = response.data.user.name;
this.farm = response.data.name;

})
.catch((error) => {
console.log("Error Occurred")
console.log(error)

})

this.harvestLogs.push({date:"2018-05-01", area:"Orion-3", crop:"Kale", yield:12, units:"Bunches"});

},
changeState: function(newState){
this.state = newState;
}


},

computed: {
cropNames(){
return Array.from(this.idToCropMap.values());
}
},

created() {
getIDToCropMap()
.then((theMap) => {
this.idToCropMap = theMap;
})

.catch((err) => {
console.log("error getting ID to CropMap")
})
},
})
Vue.config.devtools = true
</script>

</html>
191 changes: 191 additions & 0 deletions farmdata2/farmdata2_modules/fd2_school/API2/api2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<html>

<div id="vue_spike2" v-cloak>
<body>
<p>
<h1>Harvest Report</h1>
<p>This page is a <i>mockup</i> of a simplified harvest report.</p>


<label for="title">Title:</label>
<input v-model="title" type="text" id="title" name="title"/>

<br>

<div>
<label for="startdate">Start:</label>
<input type="date" id="startdate" name="start_date"
v-model ="startDate" min="2014-01-01" :max="endDate"/>
<label for="enddate">End:</label>
<input type="date" id="enddate" name="end_date"
v-model ="endDate" :min="startDate" max="2022-01-01"/>
</div>

<br>

<div>
<label for="crops">Crop:</label>
<select v-model="crops" id="crops" name="crops">
<option v-for="crops in cropNames">{{ crops }}</option>
</select>

<label for="area">Area:</label>
<select v-model="areas" id ="area" name="area">
<option v-for="area in areas">{{ area }}</option>
</select>
</div>

<br>

<button type="button" v-on:click="saveReport" @click='changeState("activeReport")'>Generate Report</button>

<hr>


<v-cloak><h1>{{ title ? title : "Mock Harvest Report" }}</h1></v-cloak>


<p>Details:</p>

<ul>
<li><strong>Farm:</strong> {{ farm }}</li>
<li><strong>User:</strong> {{ user }}</li>
<li><strong>Language:</strong> {{ language }}</li>
</ul>

<br>

<ul>
<li><strong>Start:</strong> {{ startDate }}</li>
<li><strong>End:</strong> {{ endDate }}</li>
<li><strong>Crop:</strong> {{ crops }}</li>
</ul>

<p v-if='state === "nullReport" || harvestLogs.length === 0'>There are no matching records</p>
<div v-if='state === "activeReport" && !(harvestLogs.length === 0)' >
<table border=1>
<tr>
<th>Row</th>
<th>Date</th>
<th>Area</th>
<th>Crop</th>
<th>Yield</th>
<th>Units</th>
</tr>
<tr v-for="(cell,index) in harvestReportRows">
<td>{{ index + 1 }}</td>
<td>{{ cell.date }}</td>
<td>{{ cell.area }}</td>
<td>{{ cell.crop }}</td>
<td>{{ cell.yield }}</td>
<td>{{ cell.units }}</td>
</tr>
</table>


</div>
</body>
</div>

<script>
var vueSpike = new Vue({
el: "#vue_spike2",
data: {
harvestPages: [],
harvestRequest: "",
endTimestamp: "",
startTimestamp: "",
farm: "",
user: "",
language: "",
state: "nullReport",
title: "My Sample Harvest Report",
startDate: "2020-05-05",
endDate: "2020-05-15",
crops: ["Kale", "Peas", "Broccoli"],
areas: ["All", "Chuau-1", "SQ7"],
harvestLogs: [
],
idToCropMap: new Map()
},
methods: {
saveReport: function(){
axios.get('/farm.json') // this line sends the request.
.then((response) => {
this.language = response.data.languages.en.name;
this.user = response.data.user.name;
this.farm = response.data.name;

})
.catch((error) => {
console.log("Error Occurred")
console.log(error)

})

let startTimestamp = dayjs(this.startDate).unix();
let endTimestamp = dayjs(this.endDate).unix();
console.log(startTimestamp)
console.log(endTimestamp)
let harvestRequest = "/log.json?type=farm_harvest&timestamp[ge]=" + startTimestamp
+ "&timestamp[le]=" + endTimestamp;
console.log(harvestRequest)

getAllPages(harvestRequest)
.then((res) => {
this.harvestPages = res
})
.catch((err) => {
console.log("Error Occurred Getting Pages")
console.log(error)
})



this.harvestLogs.push({date:"", area:"", crop:"", yield:"", units:""});

},
changeState: function(newState){
this.state = newState;
}


},

computed: {
cropNames(){
return Array.from(this.idToCropMap.values());
},

harvestReportRows() {
let tableRows = []
for(let log of this.harvestPages) {
let tableRow = {
date: dayjs.unix(log.timestamp).format('MM/DD/YYYY'),
area: log.area[0].name,
yield: log.quantity[0].value,
units: log.quantity[0].unit.name,
crop: this.idToCropMap.get(log.data.crop_tid)
}
tableRows.push(tableRow)
}
return tableRows
}

},

created() {
getIDToCropMap()
.then((theMap) => {
this.idToCropMap = theMap;
})

.catch((err) => {
console.log("error getting ID to CropMap")
})
},
})
Vue.config.devtools = true
</script>

</html>
40 changes: 40 additions & 0 deletions farmdata2/farmdata2_modules/fd2_school/E2E/e2e.defaults.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
describe("Test the harvest report default values", () => {
beforeEach(() => {
cy.login("manager1", "farmdata2")
cy.visit("/farm/fd2-school/e2e")
})

it("Check the page header", () => {

cy.get("[data-cy=page-header]")
.should("have.text","Harvest Report")


})

it("Check the default start and end dates", () => {

cy.get("[data-cy=start-date]")
.should("have.value", "2020-05-05")

cy.get("[data-cy=end-date]")
.should("have.value", "2020-05-15")
})


it("Check the crops in crop dropdown", () => {

cy.get("[data-cy=crop-drop]").children().eq(0)
.should("have.text", "ARUGULA")

cy.get("[data-cy=crop-drop]").children().eq(4)
.should("have.text", "BEAN-FAVA")

cy.get("[data-cy=crop-drop]").children().eq(110)
.should("have.text", "ZUCCHINI")

cy.get("[data-cy=crop-drop]").children()
.should("have.length", "111")
})

})
Loading