-
-
Notifications
You must be signed in to change notification settings - Fork 868
Description
Description:
The file EvalAI/frontend/src/js/controllers/profileCtrls.js
currently has 66.51% test coverage according to the latest Codecov report. Key functions such as editprofileDialog()
and changePassword()
remain either untested or partially tested, leaving important UI and security-related workflows vulnerable to regressions.
This issue proposes targeted unit tests using Jasmine and Karma, aiming to validate all control paths, UI interactions, and error handling logic.
✅ Target Functions for Testing
1. editprofileDialog(ev)
This method configures and opens a modal dialog based on the clicked field. It uses a switch-case
block driven by ev.currentTarget.id
.
-
Simulate DOM click events with different
id
s (e.g.first_name
,github_url
) -
Validate that:
vm.titleInput
andvm.editid
are set correctly$mdDialog.show()
is called with correct arguments
-
Use
spyOn($mdDialog, 'show')
to assert modal behavior
2. changePassword()
This function submits an API request to change the user's password and handles validation errors for different fields.
-
Mock
utilities.sendRequest()
to simulate:-
Success case: test
$rootScope.notify()
and$state.go()
-
Error cases for individual fields:
old_password
new_password1
new_password2
-
Generic/unexpected errors
-
-
Validate that:
vm.FormError
is updated correctly- Error messages are passed properly to
$rootScope.notify()
🧪 Testing Strategy
-
Implement tests using Jasmine + Karma
-
Use mocking/spying for:
$mdDialog.show()
utilities.sendRequest()
$state.go()
and$rootScope.notify()
📈 Goal
Increase test coverage of profileCtrl.js
to 90%+ by covering all key logic paths, modal workflows, and API result handling.