Closed haneslinger closed 4 months ago
How odd....any networking errors?
@perryr16 @axelstudios How do I fix the front end tests?
@haneslinger typically I hit localhost/angular_js_tests/
then debug in dev tools based on the errors, in your case
/memebrs_controller.spec.js
"Expected spy update_role to have been called with [ 2, 4, 'viewer' ] but actual calls were [ 2, 4, undefined ]"
~looks like there is an issue with the controller creation in the beforeEach
, specifically the mock_organization_service
function update_role
. Might have to update what its resolving.~
To rerun I've experienced some caching issues and have to comment out the spec in the AngularJSTests.html
file, and rerun before it recognizes changes at localhost/angular_js_tests/
I can take a look
Update:
just needed to update the test to call $scope.update_role
with the new role
arg
How odd....any networking errors?
No network errors...everything appears successful but the change doesn't "take".
The issue seems related to simultaneous promise execution. By calling update_role
and update_ali
back to back the user.access_level_instance
can be overwritten to its original if update_role
is slower than update_ali
.
The simplest way to fix this is to call them asyncronously
$scope.update_user = (user, user_edits) => {
// 1. update role
// 2. update ali
organization_service.update_role(user.user_id, $scope.org.id, user_edits.role)
.then(() => {
refreshRoleStatus();
return organization_service.update_ali(user.user_id, $scope.org.id, user_edits.access_level_instance.id)
})
.catch((data) => {
$scope.$emit('app_error', data);
})
}
It'd be a bit of a refactor but I'd consider merging this logic into a single OrganizationUser
update endpoint.
#4045