Skip to content

Commit

Permalink
Grass curing column change (#3389)
Browse files Browse the repository at this point in the history
Don't autofill over existing values upon MoreCast load
  • Loading branch information
brettedw authored Feb 8, 2024
1 parent 5e6a915 commit 5e5abf7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions web/src/features/moreCast2/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,13 @@ const rows = [
]

describe('fillGrassCuring', () => {
it('should map the most recent grass curing value for each station to each forecast', () => {
it('should map the most recent grass curing value for each station to each forecast, without overwriting existing submitted values', () => {
forecast1A.grassCuringForecast!.value = 60
forecast1B.grassCuringForecast!.value = 50
fillGrassCuring(rows)
expect(forecast1A.grassCuringForecast!.value).toBe(80)
expect(forecast1A.grassCuringForecast!.value).toBe(60)
expect(forecast1B.grassCuringForecast!.value).toBe(50)
expect(forecast1C.grassCuringForecast!.value).toBe(50)
expect(forecast2A.grassCuringForecast!.value).toBe(70)
expect(forecast3A.grassCuringForecast!.value).toBe(NaN)
})
Expand All @@ -265,7 +269,7 @@ describe('fillStationGrassCuringForward', () => {
forecast1B.grassCuringForecast!.value = 43
fillStationGrassCuringForward(forecast1B, rows)
expect(forecast1C.grassCuringForecast!.value).toBe(43)
expect(forecast1A.grassCuringForecast!.value).toBe(80)
expect(forecast1A.grassCuringForecast!.value).toBe(60)
expect(forecast2A.grassCuringForecast!.value).toBe(70)
})
})
4 changes: 2 additions & 2 deletions web/src/features/moreCast2/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ export const fillGrassCuring = (rows: MoreCast2Row[]): MoreCast2Row[] => {

for (const row of rows) {
const stationInfo = stationGrassMap.get(row.stationCode)

if (stationInfo && row.grassCuringForecast) {
// fill the grass curing forecast value, as long as it doesn't already have a value
if (stationInfo && row.grassCuringForecast && isNaN(row.grassCuringForecast.value)) {
row.grassCuringForecast.value = stationInfo.grassCuring
}
}
Expand Down

0 comments on commit 5e5abf7

Please sign in to comment.