Skip to content

Commit

Permalink
Summary Table Timing and No Log Messages (#289)
Browse files Browse the repository at this point in the history
* Added a message when a date range contains no logs

* Summary Tables now remain invisible until the API returns

* Summary now shows a message when only direct or tray seeding is in the table

* Added Testing for the One Type Message code

* Added testing for No Logs message

* Added testing for summary table showing up after fully loaded table

* Removed redundant logins

* Replaced "before" with "beforeEach" and tests now run without 403 errors
  • Loading branch information
Batese2001 authored Oct 11, 2021
1 parent 80b4408 commit d622e8d
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 15 deletions.
57 changes: 44 additions & 13 deletions farmdata2_modules/fd2_tabs/fd2_barn_kit/seedingReport.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,49 @@ <h1 class="text-center">Seeding Report</h1>

<div data-cy="loader" class="loader center-block" v-if="stillLoading"></div>

<div v-if="seedingLogs.length != 0">
<div v-if="!stillLoading && seedingLogs.length != 0">
<br>

<div style="display: flex; width: 100%;">
<fieldset data-cy="direct-summary" class="center-block panel panel-default" style="width: 50%;" v-if="!(selectedSeeding=='Tray Seedings')">
<legend class="panel-heading" style="background-color: #d62a17; color: white;">Direct Seeding Summary</legend>
<p style="margin-left: 5%;"> Total Row/Bed Planted: <b>{{ totalRowBed }}</b></p>
<p style="margin-left: 5%;"> Total Row Feet Planted: <b>{{ totalRowFeet }}</b></p>
<p style="margin-left: 5%;">Total Bed Feet Planted: <b>{{ totalBedFeet }}</b></p>
<p style="margin-left: 5%;">Total Hours Worked: <b>{{ totalDirectSeedingHours }}</b></p>
<p style="margin-left: 5%;">Total Bed Feet per Hour: <b>{{ totalBedFeetPerHour }}</b></p>
<p style="margin-left: 5%;">Total Row Feet per Hour: <b>{{ totalRowFeetPerHour }}</b></p>
<div v-if="getTableOneType == 'Tray Seedings'">
<p style="margin-left: 5%;"> There are no Direct Seeding logs with these parameters</p>
</div>
<div v-else>
<p style="margin-left: 5%;"> Total Row/Bed Planted: <b>{{ totalRowBed }}</b></p>
<p style="margin-left: 5%;"> Total Row Feet Planted: <b>{{ totalRowFeet }}</b></p>
<p style="margin-left: 5%;">Total Bed Feet Planted: <b>{{ totalBedFeet }}</b></p>
<p style="margin-left: 5%;">Total Hours Worked: <b>{{ totalDirectSeedingHours }}</b></p>
<p style="margin-left: 5%;">Total Bed Feet per Hour: <b>{{ totalBedFeetPerHour }}</b></p>
<p style="margin-left: 5%;">Total Row Feet per Hour: <b>{{ totalRowFeetPerHour }}</b></p>
</div>
</fieldset>
<fieldset data-cy="tray-summary" class="center-block panel panel-default" style="width: 47%;" v-if="!(selectedSeeding=='Direct Seedings')">
<legend class="panel-heading" style="background-color: #d62a17; color: white;">Tray Seeding Summary</legend>
<p style="margin-left: 5%;">Total Number of Tray Seeds Planted: <b>{{ traySeedsPlanted }}</b></p>
<p style="margin-left: 5%;">Total Number of Trays: <b>{{ totalNumTrays }}</b></p>
<p style="margin-left: 5%;">Total Hours Worked: <b>{{ totalTraySeedingHours }}</b></p>
<p style="margin-left: 5%;">Average Seeds Planted per Hour: <b>{{ aveSeedsPerHour }}</b></p>
<div v-if="getTableOneType == 'Direct Seedings'">
<p style="margin-left: 5%;"> There are no Tray Seeding logs with these parameters</p>
</div>
<div v-else>
<p style="margin-left: 5%;">Total Number of Tray Seeds Planted: <b>{{ traySeedsPlanted }}</b></p>
<p style="margin-left: 5%;">Total Number of Trays: <b>{{ totalNumTrays }}</b></p>
<p style="margin-left: 5%;">Total Hours Worked: <b>{{ totalTraySeedingHours }}</b></p>
<p style="margin-left: 5%;">Average Seeds Planted per Hour: <b>{{ aveSeedsPerHour }}</b></p>
</div>
</fieldset>
</div>
</div>
<div v-if="!stillLoading && seedingLogs.length == 0">
<div class="box" data-cy="no-logs-message" style="
border: 5px solid #d62a17;
background-color: white;
padding: 20px;
margin: auto;
width: 50%;
text-align: center;
font-size: large;">
No Logs Found in These Dates
</div>
</div>
</div>
</div>
<script>
Expand Down Expand Up @@ -107,7 +128,6 @@ <h1 class="text-center">Seeding Report</h1>
getAllPages(link, this.seedingLogs).then(() => {
this.stillLoading = false
})
//Should set stillLoading to its intitial true state when finished
this.stillLoading = true
},
cropChange(selectedCrop){
Expand Down Expand Up @@ -330,6 +350,17 @@ <h1 class="text-center">Seeding Report</h1>
})
return rows
},
getTableOneType(){
let currentType = this.tableRows[0].data[3]
for (i = 0 ; i < this.tableRows.length ; i ++){
if (this.tableRows[i].data[3] == currentType){
currentType = this.tableRows[i].data[3]
}else{
return false
}
}
return currentType
},
/**
* returns a sorted array of all the crops in the current logs. If area or type of seeding does not equal 'All' then the array will only contain crops that have the selected area and/or type of seeding
*/
Expand Down
106 changes: 104 additions & 2 deletions farmdata2_modules/fd2_tabs/fd2_barn_kit/seedingReport.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ describe('Testing for the seeding report page', () => {

})
context('can see spinner at appropriate times', () => {
before(() => {
cy.login('manager1', 'farmdata2')
beforeEach(() => {
cy.visit('/farm/fd2-barn-kit/seedingReport')

})
Expand Down Expand Up @@ -93,6 +92,109 @@ describe('Testing for the seeding report page', () => {
})
})

context('can see No Logs message at appropriate times', () => {
beforeEach(() => {
cy.visit('/farm/fd2-barn-kit/seedingReport')

})

it('does not show No Logs message after input with logs', () => {
cy.get('[data-cy=start-date-select]')
.type('2019-01-01')
cy.get('[data-cy=end-date-select]')
.type('2019-03-01')
cy.get('[data-cy=generate-rpt-btn]').click()
cy.get('[data-cy=no-logs-message]').should('not.exist')
})

it('shows No Logs message after input without logs', () => {
cy.get('[data-cy=start-date-select]')
.type('2021-01-01')
cy.get('[data-cy=end-date-select]')
.type('2021-03-01')
cy.get('[data-cy=generate-rpt-btn]').click()
cy.get('[data-cy=no-logs-message]', {timeout: 30000}).should('be.visible')
})
it('shows No Logs message after input without logs reinput', () => {
cy.get('[data-cy=start-date-select]')
.type('2030-01-01')
cy.get('[data-cy=end-date-select]')
.type('2030-03-01')
cy.get('[data-cy=generate-rpt-btn]').click()
cy.get('[data-cy=no-logs-message]', {timeout: 30000}).should('be.visible')
})
})
context('can see summary tables at appropriate times', () => {
beforeEach(() => {
cy.visit('/farm/fd2-barn-kit/seedingReport')


})
it('does not immediately display summary tables', () => {
cy.get('[data-cy=start-date-select]')
.type('2019-01-01')
cy.get('[data-cy=end-date-select]')
.type('2019-03-01')
cy.get('[data-cy=generate-rpt-btn]').click()
cy.get('[data-cy=tray-summary]').should('not.exist')
cy.get('[data-cy=direct-summary]').should('not.exist')
})
it('shows summary tables after table is fully loaded', () => {

cy.get('[data-cy=report-table]', { timeout: 30000 }).find('tr').its('length').then(length =>{
expect(length).to.equal(35)
cy.get('[data-cy=tray-summary]',{ timeout: 30000 }).should('be.visible')
cy.get('[data-cy=direct-summary]').should('be.visible')
})
})


})

context('shows message when only one type', () => {
beforeEach(() => {
cy.visit('/farm/fd2-barn-kit/seedingReport')
cy.get('[data-cy=start-date-select]')
.type('2020-05-01')
cy.get('[data-cy=end-date-select]')
.type('2020-06-01')
cy.get('[data-cy=generate-rpt-btn]').click()
})


it('show direct seeding message when only tray seeding', () => {
cy.get('[data-cy=dropdown-input]', {timeout: 30000}).then(($dropdowns) => {
cy.get($dropdowns[1]).should('exist')
.select('ENDIVE')
.should('have.value', 'ENDIVE')
})
cy.get('[data-cy=direct-summary').should('have.text', 'Direct Seeding Summary There are no Direct Seeding logs with these parameters')
})

it('show tray seeding message when only direct seeding', () => {
cy.get('[data-cy=dropdown-input]', {timeout: 30000}).then(($dropdowns) => {
cy.get($dropdowns[1]).should('exist')
.select('CORN-SWEET')
.should('have.value', 'CORN-SWEET')
})
cy.get('[data-cy=tray-summary').should('have.text', 'Tray Seeding Summary There are no Tray Seeding logs with these parameters')
})

it('show both tables with two types', () => {
cy.get('[data-cy=direct-summary', {timeout: 30000}).should('be.visible')
cy.get('[data-cy=tray-summary]').should('be.visible')

})

it('show one tables with one type', () => {
cy.get('[data-cy=dropdown-input]', {timeout: 30000}).first().select('Direct Seedings').should('have.value', 'Direct Seedings')
cy.get('[data-cy=direct-summary').should('be.visible')
cy.get('[data-cy=tray-summary]').should('not.exist')

})

})

context('displays the right information in the table', () => {
before(() => {
cy.login('manager1', 'farmdata2')
Expand Down

0 comments on commit d622e8d

Please sign in to comment.