UniversityOfSaskatchewanCMPT371 / term-project-2024-team-4

Apache License 2.0
2 stars 2 forks source link

Frontend Integration Tests not passing due to ECONNREFUSED errors #115

Closed lecegues closed 5 months ago

lecegues commented 5 months ago

Problem

Some frontend integration tests that explicitly reference localhost:3000 to [GET, POST] are giving ECONNREFUSED errors inside the CI Pipeline, causing tests to fail

Example Pipeline Failure: https://github.com/UniversityOfSaskatchewanCMPT371/term-project-2024-team-4/actions/runs/8405274261/job/23017788982

lecegues commented 5 months ago

Suspected Problem Debugging

These are some domains for which I have debugged to try and find the source of the bug

JSDOM Test Environment Handling Connectivity (e.g. Axios requests) differently

Test Timeouts

Backend was not started/accessible

IPV4 vs. IPV6 Addresses

Currently

lecegues commented 5 months ago

Update

Added a commit to create a global axios configuration file (http.js) with an IPV4 baseURL: "http://127.0.0.1:3000" to keep a constant address in all environments. This lets the test pass. Problem solved upon branch merge

Development Changes

lecegues commented 5 months ago

Update

Login feature was not working due to the different addresses; localhost resolves as 127.0.0.1 however it is not the same value (e.g. localhost != 127.0.0.1), so CORS is handled differently.

Login Bug

The encountered bug: Does not assign the signed token as a cookie to the browser upon login.

Problem/Fix

Problem: localhost != 127.0.0.1 but it resolves to it; this means that technically requests made are cross-site requests (not the same site) Fix: when assigning cookies, must use secure: true, sameSite: "None" to allow cross-site requests