cyntaria/UniPal-Backend

[GET] All Reactions Of A Post

arafaysaleem opened this issue · 0 comments

Summary

As a student, I should be able to get reactions of a post, so that I can see who feels what.

Acceptance Criteria

Scenario 1: Get All Reactions Of A Post

GIVEN an student is requesting reactions of a post in the app
WHEN the app hits the /posts/:id/reactions endpoint with a valid GET request, containing the path parameter:

  • :id, the unique id of the entity for which the reactions are needed.

THEN the app should receive a status 200
AND in the response, the following information should be returned:

  • headers
  • list of post reactions

Sample Request/Sample Response
For e.g. we are requesting all reactions of a post with post_id=1

headers: {
    error: 0,
    message: "..."
}
body: [
    {
      reaction_type_id: 1,
      post_id: 1
      student_erp: 17855,
      reacted_at: 09-09-2021 11:33:21,
    },
    {
      reaction_type_id: 2,
      post_id: 1
      student_erp: 17918,
      reacted_at: 09-09-2021 11:33:21,
    },
]

Resources

  • Development URL: {Here goes a URL to the feature on development API}
  • Production URL: {Here goes a URL to the feature on production API}

Dev Notes

This endpoint is accessible by and serves the admin in the same way.

Testing Notes

Scenario 1: GET request is successful

GIVEN a student is requesting reactions of a post in the app
WHEN the app hits the /posts/:id/reactions endpoint with a valid GET request, containing the path parameter:

  • :id

THEN the app should receive a status 200
AND the body should be an array
AND the first item of the array should be an object containing the following fields:

  • student_erp
  • post_id
  • reaction_type_id
  • reacted_at

AND the post_id of each item should be equal to the path parameter :id

Scenario 2: GET request is unsuccessful due to unknown post_id

GIVEN a student is requesting reactions of a post in the app
WHEN the app hits the /posts/:id/reactions endpoint with a valid GET request, containing the path parameter:

  • :id, a non-existent id

THEN the app should receive a status 404
AND the response headers' code parameter should contain "NotFoundException"
AND the response headers' message parameter should contain "Post not found"

Scenario 3: GET request is unsuccessful due to zero reactions

GIVEN a student is requesting reactions of a post in the app
AND no reactions of that post exist yet
WHEN the app hits the /posts/:id/reactions endpoint with a valid GET request, containing the path parameter:

  • :id

THEN the app should receive a status 404
AND the response headers' code parameter should contain "NotFoundException"
AND the response headers' message parameter should contain "Post reactions not found"

Scenario 4: GET request is unauthorized

GIVEN a student is requesting reactions of a post in the app
WHEN the app hits the /posts/:id/reactions endpoint with a valid GET request
AND the request contains no authorization token
THEN the app should receive a status 401
AND the response headers' code parameter should contain "TokenMissingException"