opengovsg / checkfirst

Don't Know? CheckFirst. A tool to build eligibility checkers and calculators for Singapore Government policies
https://checkfirst.gov.sg
Other
11 stars 6 forks source link

Inconsistent calculation involving datefield component #1253

Closed prestonlimlianjie closed 2 years ago

prestonlimlianjie commented 2 years ago

Describe the bug Checkers that perform logic calculations using the datefield component can produce inconsistent results depending on whether the user has actively selected the date field or if they just used the default value.

To Reproduce Steps to reproduce the behavior:

  1. Log into Checkfirst (on any environment) and create a checker with the following configuration:
    • In the Questions tab, create
      • 1 datefield with label D1 and title Earlier date
      • 1 datefield with label D2 and title Later date
    • In the Logic tab, create
      • 1 date calculation component with label O1 and logic statement D2 - 7 days
      • 1 ifelse component with label O2 and logic statement ifelse(D1 <= O1, "YES - The later day is at least 7 days ahead of the earlier day", "NO - The later day is not more than 7 days ahead of the earlier day")
  2. Run the following 3 test cases
    • User selects later date but leaves earlier date as default
      • User refreshes the page
      • User leaves the earlier date as default (2022-02-17)
      • User selects the later date (2022-02-24)
      • User sees result "NO - The later day is not more than 7 days ahead of the earlier day"
    • User selects both earlier date and later date
      • User selects the earlier date (2022-02-17)
      • User selects the later date (2022-02-24)
      • User sees result "YES - The later day is at least 7 days ahead of the earlier day"
    • User presses the reset checker button and only selects later date but leaves earlier date as default
      • [This is after the checker has been run at least once]
      • User DOES NOT REFRESH the page
      • User clicks on reset checker
      • User leaves the earlier date as default (2022-02-17)
      • User selects the later date (2022-02-24)
      • User sees result "NO - The later day is not more than 7 days ahead of the earlier day"

https://user-images.githubusercontent.com/19917616/154446449-689661a1-a88c-44cb-b6a7-89a49d1728ec.mov

Expected behavior The result of all 3 test cases should be consistent, and the result should be "YES - The later day is at least 7 days ahead of the earlier day".