Resolve "Add frontend vitest unit tests to ci and fix broken tests" - #397
nick-greenwald merged 11 commits into
Conversation
…-fix-broken-tests
d-linko
left a comment
There was a problem hiding this comment.
Attempting running the testing locally
got
Test Files 25 passed (25)
Tests 62 passed (62)
Errors 1 error
with the error HttpErrorResponse: Http failure response for http://localhost:3000/api/core/adms: 401 Unauthorized
and also in the logs im seeing
Failed to load ARIs HttpErrorResponse {
headers: HttpHeaders {
headers: undefined,
normalizedNames: Map(0) {},
lazyInit: [Function (anonymous)],
lazyUpdate: null
},
status: 401,
statusText: 'Unauthorized',
url: 'http://localhost:3000/api/build/ari/all',
ok: false,
type: undefined,
redirected: undefined,
responseType: undefined,
name: 'HttpErrorResponse',
message: 'Http failure response for http://localhost:3000/api/build/ari/all: 401 Unauthorized',
error: {
extra: null,
message: 'Unauthorized',
messageId: 'auth.unauthorized',
statusCode: 401,
traceID: ''
}
}
looks like its trying a different port is that different in the CI
…-fix-broken-tests
…-fix-broken-tests
|
The latest changes I made should fix this. I believe the issue was that the Angular dev server that vitest runs against tries to bind to port 3000, and if you have the docker containers up and running then the grafana container is already bound to that port. There were some unhandled HTTP requests being thrown out by component dependencies that should have been mocked, so that is likely why you were getting 401 unauthorized errors, as the HTTP requests being thrown out by the dev server tests were hitting running containers. The latest changes mock the dependencies that were sending out the unhandled HTTP requests so this should hopefully not be an issue anymore, but you can try to test with the ANMS containers up and down to see if you see a difference in test behavior. |
|
The test now pass when containers are up or down in either case |
…eal HTTP in tests
|
|
There was still some usage of the Http Client, which was not the correct way to mock HTTP requests. I've updated everything and those unknown HTTP errors in the test output should not longer be present. I also found that the way I stubbed some of the service dependencies for previous tests wasn't very conducive to expanding the tests in the future, so I fixed those. I also made an update that suppresses that error properly by spying on the output, as it is an expected error. I also fixed a sonarqube warning that exposed a lack of any real assertions in that status test as well, so the PR should be in a good state now. |
|
#397 (comment) |



Fixes broken skeleton unit tests for various components and adds a unit test CI job.