icefoganalytics / travel-authorization

0 stars 0 forks source link

Setting dateBackToWork on Travel Authorization Causes a 500 in Travel Desk Travel Request Serializer #234

Closed klondikemarlen closed 1 month ago

klondikemarlen commented 1 month ago

Fixes https://github.com/icefoganalytics/travel-authorization/issues/233

Relates to:

Context

Describe the bug When you set a date back to work for the travel authorization if 500s when you go to the Travel Auth -> Request tab due to a bug in the serializer.

image

To Reproduce Steps to reproduce the behavior:

  1. From the Dashboard page, select "My Travel Requests" from the top dropdown nav.
  2. Create a travel authorization via the "+ Travel Authorization" button.
  3. Create a travel request between Vancouver and Whitehorse.
  4. Pick the travel dates as a short window of 3 days.
  5. Generate the estimate.
  6. Submit the travel authorization to your email as the supervisor.
  7. From the top dropdown nav, select "Manager View".
  8. Find your request in the "Pending Approval" card.
  9. Approve the request.
  10. Return to the "My Travel Requests" page via the top dropdown nav.
  11. Find your approved request in the table, and click on the "Submit travel desk request" call-to-action button.

Expected behavior Page should not 500.

Additional context This bug is caused by a bug in Sequelize 6 where fields of type DATEONLY supposedly return js Date, but actually return "string".

This issue in a bunch of models, and will need to be fixed everywhere. There will be a lot of type errors that will need to be handled after it gets fixed.

Error as text

App is running > Object
main.js:52

Failed to load resource: the server responded with a status of 500 ()
api/travel-desk-trav...%5D=237&perPage=1:1

Failed to fetch
use-travel-desk-travel-requests.js:60

travelDeskTravelRequests:
Error: Failed to retrieve travel desk requests: TypeError:
dateBackToWork.toISOString is not a function
at http-client.js:36:11
at async Le.request (Axios.js:40:7)
at async Object.list (travel-desk-travel-requests-api.js:91:13)
at async n (use-travel-desk-travel-requests.js:52:41)
at async deep (use-travel-desk-travel-requests.js:71:11)

vue.runtime.esm.js:3065
Error: Failed to retrieve travel desk requests: TypeError:
dateBackToWork.toISOString is not a function
at http-client.js:36:11
at async Le.request (Axios.js:40:7)
at async Object.list (travel-desk-travel-requests-api.js:91:13)
at async n (use-travel-desk-travel-requests.js:52:41)
at async deep (use-travel-desk-travel-requests.js:71:11)

Implementation

Fix types around Sequelize DATEONLY fields, now returns Date | string [| null]; This is an issue with Sequelize 6. The expected types should probably be string? Use better error logging in controller that through the error before; All controllers should have a better way of logging errors.

Screenshots

image

Testing Instructions

  1. Run the test suite via dev test (or dev test_api)
  2. Boot the app via dev up
  3. Log in to the app at http://localhost:8080
  4. From the Dashboard page, select "My Travel Requests" from the top dropdown nav.
  5. Create a travel authorization via the "+ Travel Authorization" button.
  6. Create a travel request between Vancouver and Whitehorse.
  7. Pick the travel dates as a short window of 3 days.
  8. Generate the estimate.
  9. Submit the travel authorization to your email as the supervisor.
  10. From the top dropdown nav, select "Manager View".
  11. Find your request in the "Pending Approval" card.
  12. Approve the request.
  13. Return to the "My Travel Requests" page via the top dropdown nav.
  14. Find your approved request in the table, and click on the "Submit travel desk request" call-to-action button.