electropicks / Payback

A web app to optimize your todo list
https://task-master-three.vercel.app
1 stars 0 forks source link

Test Results (Alfred Madere) #27

Open AlfredMadere opened 12 months ago

AlfredMadere commented 12 months ago

Running Existing Tests

The v1 test file points at localhost, not the render instance so I cannot run those

The following are the results from running every curl statement in order on v2. I was unable to get a single 200 response back. I tried pasting the non post commands into a browser and was able to get a response back from a few of them, I included them below. I suspect these curl statements were never run from a terminal with no configuration...

Tracking Expenses

$ curl -v -X 'POST' \
> 'http://payback-app-rjwr.onrender.com/groups/1/trips/1/add' \
> -H 'accept: application/json' \
> -H 'Content-Type: application/json' \
> -d '{ "userId": "1", "items": [ { "name": "Banana", "price": 5, "quantity": 1, "optedOut": [] } ] }'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 216.24.57.3:80...
* Connected to payback-app-rjwr.onrender.com (216.24.57.3) port 80 (#0)
> POST /groups/1/trips/1/add HTTP/1.1
> Host: payback-app-rjwr.onrender.com
> User-Agent: curl/8.1.2
> accept: application/json
> Content-Type: application/json
> Content-Length: 95
>
< HTTP/1.1 307 Temporary Redirect
< Date: Sat, 11 Nov 2023 19:09:16 GMT
< Content-Length: 0
< Connection: keep-alive
< Location: https://payback-app-rjwr.onrender.com/groups/1/trips/1/add
< CF-Ray: 8248d4231f6ffa72-SJC
< CF-Cache-Status: DYNAMIC
< Server: cloudflare
< alt-svc: h3=":443"; ma=86400
<
* Connection #0 to host payback-app-rjwr.onrender.com left intact
$ curl -v -X 'POST' \
> 'http://payback-app-rjwr.onrender.com/groups/calculate' \
> -H 'accept: application/json' \
> -H 'Content-Type: application/json' \
> -d '{ "userId": "1" }'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 216.24.57.3:80...
* Connected to payback-app-rjwr.onrender.com (216.24.57.3) port 80 (#0)
> POST /groups/calculate HTTP/1.1
> Host: payback-app-rjwr.onrender.com
> User-Agent: curl/8.1.2
> accept: application/json
> Content-Type: application/json
> Content-Length: 17
>
< HTTP/1.1 307 Temporary Redirect
< Date: Sat, 11 Nov 2023 19:10:22 GMT
< Content-Length: 0
< Connection: keep-alive
< Location: https://payback-app-rjwr.onrender.com/groups/calculate
< CF-Ray: 8248d5bd5c4bcfb0-SJC
< CF-Cache-Status: DYNAMIC
< Server: cloudflare
< alt-svc: h3=":443"; ma=86400
<
$ curl -v -X 'POST' \
> 'http://payback-app-rjwr.onrender.com/groups/3/transactions' \
> -H 'accept: application/json' \
> -H 'Content-Type: application/json' \
> -d '{ "trip_id": 1, "from_id": 1, "to_id": 2, "amount": 33, "description": "Vasanth paid Suhanth (venmo)" }'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 216.24.57.3:80...
* Connected to payback-app-rjwr.onrender.com (216.24.57.3) port 80 (#0)
> POST /groups/3/transactions HTTP/1.1
> Host: payback-app-rjwr.onrender.com
> User-Agent: curl/8.1.2
> accept: application/json
> Content-Type: application/json
> Content-Length: 103
>
< HTTP/1.1 307 Temporary Redirect
< Date: Sat, 11 Nov 2023 19:12:23 GMT
< Content-Length: 0
< Connection: keep-alive
< Location: https://payback-app-rjwr.onrender.com/groups/3/transactions
< CF-Ray: 8248d8af7b28679b-SJC
< CF-Cache-Status: DYNAMIC
< Server: cloudflare
< alt-svc: h3=":443"; ma=86400
<
* Connection #0 to host payback-app-rjwr.onrender.com left intact

When hitting the above in a browser i get back

{"transactions":[{"transaction_id":5,"from_user_id":3,"to_user_id":2,"description":"Roommate paying Test User","date":"2023-11-07T22:35:43.256608+00:00"}]}

Correcting an Error

$ curl -v -X 'GET' \
> 'http://payback-app-rjwr.onrender.com/groups/1/transactions' \
> -H 'accept: application/json'
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 216.24.57.3:80...
* Connected to payback-app-rjwr.onrender.com (216.24.57.3) port 80 (#0)
> GET /groups/1/transactions HTTP/1.1
> Host: payback-app-rjwr.onrender.com
> User-Agent: curl/8.1.2
> accept: application/json
>
< HTTP/1.1 301 Moved Permanently
< Date: Sat, 11 Nov 2023 19:13:50 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 94
< Connection: keep-alive
< Location: https://payback-app-rjwr.onrender.com/groups/1/transactions
< CF-Ray: 8248dad14d38158a-SJC
< CF-Cache-Status: DYNAMIC
< Server: cloudflare
< alt-svc: h3=":443"; ma=86400
<
<a href="https://payback-app-rjwr.onrender.com/groups/1/transactions">Moved Permanently</a>.

* Connection #0 to host payback-app-rjwr.onrender.com left intact

when hitting the above in a browser i get

{"transactions":[{"transaction_id":1,"from_user_id":1,"to_user_id":2,"description":"Paid for trip","date":"2023-11-07T10:05:52.826359+00:00"},{"transaction_id":2,"from_user_id":1,"to_user_id":1,"description":"Paid for trip","date":"2023-11-07T10:05:52.826359+00:00"}]}
$ curl -v -X 'POST' \
> 'http://payback-app-rjwr.onrender.com/groups/1/trips/1/delete' \
> -H 'accept: application/json' \
> -H 'Content-Type: application/json' \
> -d '{ "transaction_id": "5" }'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 216.24.57.253:80...
* Connected to payback-app-rjwr.onrender.com (216.24.57.253) port 80 (#0)
> POST /groups/1/trips/1/delete HTTP/1.1
> Host: payback-app-rjwr.onrender.com
> User-Agent: curl/8.1.2
> accept: application/json
> Content-Type: application/json
> Content-Length: 25
>
< HTTP/1.1 307 Temporary Redirect
< Date: Sat, 11 Nov 2023 19:14:54 GMT
< Content-Length: 0
< Connection: keep-alive
< Location: https://payback-app-rjwr.onrender.com/groups/1/trips/1/delete
< CF-Ray: 8248dc641bde22ba-SJC
< CF-Cache-Status: DYNAMIC
< Server: cloudflare
< alt-svc: h3=":443"; ma=86400
<
* Connection #0 to host payback-app-rjwr.onrender.com left intact

Suggestions for new tests

Because I wasn't able to get any of the curl statements to work I am providing expected responses not real responses.

1. Create a group and have 2 members join, then get the group details to ensure all users joined correctly. 3 users with ids 1, 2 and 3 must be prepopulated before this test.

Create group

curl -X 'POST' \
  'http://payback-app-rjwr.onrender.com/groups/register' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "userId": "1",
  "name": "Roommates"
}'

Expected Response:

{
  "group_id": [group_id]
}

First User Joins the Group

curl -X 'POST' \
  'http://payback-app-rjwr.onrender.com/groups/[group_id]/join' \
  -H 'accept: application/json' \
  -d 'user_id=2'

Expected Response (I included a descriptive message that you should include in the response):

{
  "message": "User joined the group successfully."
}

Second User Joins the Group

curl -X 'POST' \
  'http://payback-app-rjwr.onrender.com/groups/[group_id]/join' \
  -H 'accept: application/json' \
  -d 'user_id=3'
{
  "message": "User joined the group successfully."
}

Get group details

curl -X GET 'http://payback-app-rjwr.onrender.com/groups/[group_id]' \
-H 'Content-Type: application/json'

Response:

{
    "group_id": [group_id],
    "group_name": "Roomates",
    "members": [1, 2, 3]
}

2. A user leaves a group

The api is not complete and does not currently include this functionality but it definitely should. You should not rely on the groups/{id} endpoint as the only way to get the users in a group. You must have at least one user in a group for the setup of this test.

Verify User is Part of the Group

curl -X 'GET' \
  'http://payback-app-rjwr.onrender.com/groups/[group_id]/members' \
  -H 'accept: application/json'

Response

{
  "members": [
    {
      "user_id": 1,
      "name": "User1",
      "email": "user1@example.com"
    },
    {
      "user_id": 2,
      "name": "User2",
      "email": "user2@example.com"
    },
    // Remaining members, excluding the user who left
  ]
}

User Leaves the Group

curl -X 'DELETE' \
  'http://payback-app-rjwr.onrender.com/groups/[group_id]/members/[user_id]' \
  -H 'accept: application/json'

Response:

{
  "message": "User successfully removed from the group."
}

Verify Removal

curl -X 'GET' \
  'http://payback-app-rjwr.onrender.com/groups/[group_id]/members' \
  -H 'accept: application/json'

Response:

{
  "members": [
    {
      "user_id": 1,
      "name": "User1",
      "email": "user1@example.com"
    }
    // Remaining members, excluding the user who left
  ]
}

3. adding transactions to a group and then listing them.

Seeding: Must have a trip with id 1 that Users with ids 1 and 2 are a part of. Also must have a trip with id 1 belonging to the group_id. Users must be a part of group_id.

Add the first transaction

curl -X 'POST' \
  'http://payback-app-rjwr.onrender.com/groups/[group_id]/transactions' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "trip_id": 1,
  "from_id": 1,
  "to_id": 2,
  "amount": 50.0,
  "description": "Lunch"
}'

Response:

"OK"

Add the second transaction

curl -X 'POST' \
  'http://payback-app-rjwr.onrender.com/groups/[group_id]/transactions' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "trip_id": 1,
  "from_id": 2,
  "to_id": 1,
  "amount": 30.0,
  "description": "Dinner"
}'

Response:

"OK"

List transactions

curl -X 'GET' \
  'http://payback-app-rjwr.onrender.com/groups/[group_id]/transactions' \
  -H 'accept: application/json'

Response:

{
  "transactions": [
    {
      "transaction_id": [first_transaction_id],
      "from_user_id": 1,
      "to_user_id": 2,
      "description": "Lunch",
      "date": [transaction_date]
    },
    {
      "transaction_id": [second_transaction_id],
      "from_user_id": 2,
      "to_user_id": 1,
      "description": "Dinner",
      "date": [transaction_date]
    }
    // More transactions if any
  ]
}