-
Notifications
You must be signed in to change notification settings - Fork 6
Attendance Endpoint Tests #1
User Endpoints Tests #1
ATTENTION.
There was a minor bug in the GET attendance endpoint. I have handled it during testing. These tests are thus done under the branch backend/feature/attendance-fix for which the pull request is here.
Tables below show summaries of tests on endpoints. Details are available further below tables for each endpoint.
POST /api/event/:id/attendance:
Test No. | Request | Response | Status | Comments |
---|---|---|---|---|
1 | Complete request | Correct response | Test passed. | |
2 | Duplicate attendance | No error | Test failed. | A user can currently state she will attend an event twice. |
3 | Invalid user id | Error | Test passed. | |
4 | Invalid event id | Error | Test passed. | |
5 | Empty user field | Error | Test passed. | |
6 | attendanceType: "" | No error | Test failed. | A new attendance object with null attendanceType field is created. |
Test1:
Request:
{ "user":"5c0023641aac670c90bb35eb", "attendanceType": 2 }
Response:
{ "updatedAttendance": [ { "attendanceType": 2, "_id": "5c0316c74d4473137d050fd3", "user": "5c0023641aac670c90bb35eb" } ] }
Test2:
Request: { "user":"5c0023641aac670c90bb35eb", "attendanceType": 2 }
Response:
{ "updatedAttendance": [ { "attendanceType": 2, "_id": "5c0316c74d4473137d050fd3", "user": "5c0023641aac670c90bb35eb" }, { "attendanceType": 2, "_id": "5c0316d64d4473137d050fd4", "user": "5c0023641aac670c90bb35eb" } ] }
Test failed, a user can state she will attend an event twice.
Test3:
Request:
{ "user":"xxx", "attendanceType": 2 }
Test passed.
Test4:
Request: Invalid event id in request
Response:
"err": {
"message": "Cast to ObjectId failed for value \"5c03052s2a7ced70894276909\" at path \"_id\" for model \"Event\"",
"name": "CastError",
"stringValue": "\"5c03052s2a7ced70894276909\"",
"kind": "ObjectId",
"value": "5c03052s2a7ced70894276909",
"path": "_id"
}
}
Test passed.
Test5:
Request:
{ "user":"", "attendanceType": 2 }
Response: Test passed.
Test6:
Request: { "user":"5c0023641aac670c90bb35eb", "attendanceType": "" }
Response: { "updatedAttendance": [ { "attendanceType": 2, "_id": "5c0316c74d4473137d050fd3", "user": "5c0023641aac670c90bb35eb" }, { "attendanceType": 2, "_id": "5c0316d64d4473137d050fd4", "user": "5c0023641aac670c90bb35eb" }, { "attendanceType": null, "_id": "5c0317a44d4473137d050fd7", "user": "5c0023641aac670c90bb35eb" } ] }
A new attendance record with null attendanceType field is created. Test failed.
GET /api/event/:id/attendance
Test No. | Request | Response | Status | Comments |
---|---|---|---|---|
1 | Straightforward request | Correct response | Test passed. | This endpoint works after resolving the bug discussed at the beginning of this report |
2 | Invalid event ID | Error | Test passed. |
PUT /api/event/:id/attendance Currently the endpoint doesn’t work and adds new entries when a valid request to edit an attendance is sent.