Testcases and outcomes - HoltHunter/Group-12 GitHub Wiki

[email protected] test /root/project/server mocha --exit

Server listening on port 8081

✔ Should create a new user.

Expected input: ({"firstName":"Tony","lastName":"Stark","username":"[email protected]","password":"ironman"})

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK

✔ Should create a new user.

Expected input: ({"firstName":"Steve","lastName":"Rogers","username":"[email protected]","password":"captainamerica"})

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK

✔ Should create a new user.

Expected input: ({"firstName":"Thor","lastName":"Odinson","username":"[email protected]","password":"strongestavenger"})

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK


Login (API)

✔ Should login.

Expected input: ({"username":"[email protected]","password":"ironman"})

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK

✔ Should logout.

Expected input: ({})

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK


Search for Users

✔ Should return a list of users.

Expected input: ({ userId: 1 })

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK


Make Friends

✔ Should create a friend request

Expected input: ({ "fromId": 1, "toId": 2 })

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK

✔ Should accept a friend request

Expected input: ({ "requestId": 1, "decision": true })

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK

✔ Should create a friend request

Expected input: ({ "fromId": 1, "toId": 3 })

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK

✔ Should accept a friend request

Expected input: ({ "request_id": 2, "decision": true })

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK


Make Post & Comment

✔ Should create a post

Expected input: ({ "userId": 2, "postContent": "I am Steve Rogers." })

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK

✔ Should comment on the post

Expected input: ({ "userId": 1, "postId": 1, "comment": "Can you believe this guy?" })

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK

✔ Should like the post

Expected input: ({ "userId": 3, "postId": 1 })

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK

✔ Should share a post

Expected input: ({ "userId": 3, "postContent": "See how the mortals introduce themselves? So formal.", "sharedPostId": 1 })

Expected Output: HTTP status = 200 OK

Produced Output: HTTP status = 200 OK

✔ View posts

Expected input: ({ "userId": 1 })

Expected output:

[ { id: 2, date_created: '2022-11-05T02:51:39.331Z', user_id: 3, content: 'See how the mortals introduce themselves? So formal.', likes_count: 0, first_name: 'Thor', last_name: 'Odinson', liked: false, shared_post_id: 1, date_modified: null, shared_post: { id: 1, date_created: '2022-11-05T02:51:39.321Z', user_id: 2, content: 'I am Steve Rogers.', likes_count: 1, first_name: 'Steve', last_name: 'Rogers' } }, { id: 1, date_created: '2022-11-05T02:51:39.321Z', user_id: 2, content: 'I am Steve Rogers.', likes_count: 1, first_name: 'Steve', last_name: 'Rogers', liked: false, shared_post_id: null, date_modified: '2022-11-05T02:51:39.329Z' } ]

Produced Outcome:

[ { id: 2, date_created: '2022-11-05T02:51:39.331Z', user_id: 3, content: 'See how the mortals introduce themselves? So formal.', likes_count: 0, first_name: 'Thor', last_name: 'Odinson', liked: false, shared_post_id: 1, date_modified: null, shared_post: { id: 1, date_created: '2022-11-05T02:51:39.321Z', user_id: 2, content: 'I am Steve Rogers.', likes_count: 1, first_name: 'Steve', last_name: 'Rogers' } }, { id: 1, date_created: '2022-11-05T02:51:39.321Z', user_id: 2, content: 'I am Steve Rogers.', likes_count: 1, first_name: 'Steve', last_name: 'Rogers', liked: false, shared_post_id: null, date_modified: '2022-11-05T02:51:39.329Z' } ]

✔ View post comments Expected Input: ({})

Expected Output:

[ { post_id: 1, user_id: 1, date_created: '2022-11-05T02:51:39.325Z', content: 'Can you believe this guy?', first_name: 'Tony', last_name: 'Stark' } ]

Produced Output:

[ { post_id: 1, user_id: 1, date_created: '2022-11-05T02:51:39.325Z', content: 'Can you believe this guy?', first_name: 'Tony', last_name: 'Stark' } ]


Check User Properties & Modify Properties

These 7 tests check that the profile icon & theme are modifiable by the user and are returned to the client on login, for posts, and for comments.

✔ Correct theme for logged in user

{ id: 1, username: '[email protected]', theme: 'classic', profile_icon: 'alpha' }

✔ Correct icon for logged in user

✔ Correct icon on user post

✔ Correct icon on user comment

Edit user properties

✔ Should change the icon

✔ Should change the theme

✔ Should change the icon and theme

23 passing (169ms)