dickinson-comp190 / GitKit-FarmData2-F23

Other
0 stars 20 forks source link

Seeding Report: Allowing Invalid Input that produces incorrect results #47

Open braughtg opened 11 months ago

braughtg commented 11 months ago

Description: The seeding report in Barnkit of FarmData2 produces incorrect results when invalid dates are entered for startDate and endDate, such as 02/31/yyyy - mm/dd/yyyy, 11/31/2021- mm/dd/yyyy (The characters in this two example can be represented by any month, date, or year). The invalid dates can only be entered by typing directly into the input box and cannot be achieved using the calendar function.

It seems like most of the errors occur because a nonexistent day in a month has been entered. Also, entering a day that has not happened yet will cause an error as well. When errors occur, the report that will be generated are all identical.

PS: The original farmdata1 might contain this issue as well. An invalid date such as February 31 can be used to search, but I cannot give a definite conclusion as I wasn't able to test further with the guest edition.

Directions to Reproduce:

  1. Open up the FarmData2 App and Log in
  2. Click on the BarnKit Tab
  3. Click on the Seeding Report Tab
  4. Enter the testing value in the start date and end date field
  5. Click on the generate report button

Expected result: Shown and described in the picture.

Error sample (expected result)

Actual result: Shown and described in the pictures.

Error sample 1 Error sample 2

Issue by WilliamC529 Friday Apr 29, 2022 at 16:45 GMT Originally opened as https://github.com/DickinsonCollege/FarmData2/issues/451

braughtg commented 11 months ago

It is likely that the fix for this should be implemented in the DateSelectionComponent and DateRangeSelectionComponent. The code for these is found in the farmdat2_modules/fd2_tabs/resources directory.


Comment by braughtg Saturday Apr 30, 2022 at 23:10 GMT

braughtg commented 11 months ago

This issue seemed to be fixed with the fixes in DateSelectionComponent and DateRangeSelectionComponent. The report no longer allows invalid date ranges. However, we can still select future dates. We might still want the users to be able to select future dates as the seeding input form currently allows users to log inputs for the future. If we decide to block future dates, we need to block users from loging future seeding input logs as well.


Comment by JingyuMarcelLee Thursday Jun 16, 2022 at 20:14 GMT

braughtg commented 11 months ago

There still seem to be issues here but they seem to be browser dependent based on how the browser implements the <input type=date> element. For example, in FireFox and chrome it is not possible to enter end dates before the start date and vice versa, but it is still possible to enter invalid dates (02/30/2022) that result in the incorrect report described above. In Chrome, the invalid date is converted back to mm/dd/yyyy when Generate Report is clicked and the incorrect report is generated.

Perhaps a solution is to use the dayjs library in the DateSelectionComponent to validate the entered dates and change them to the closest valid date if they are invalid?


Comment by braughtg Saturday Jun 18, 2022 at 15:34 GMT

braughtg commented 11 months ago

I'll be taking a look at this issue.


Comment by FutzMonitor Friday Mar 03, 2023 at 15:46 GMT