-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(http): basic endpoint tests #325
Conversation
@@ -286,11 +279,29 @@ export async function deleteVote(vote: Vote) { | |||
vote.user.id, | |||
]; | |||
|
|||
const [votedItemsByUserRes, votedUsersByItemRes] = await kv.getMany([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is something i stumbled upon by accident.
if we compare createVote
and deleteVote
, we were missing a check for the votedItemsByUserKey
and votedUsersByItemKey
results.
as the deletion for a non-existent key doesn't throw (anymore?), the mutation on the vote.item.score
would've been abused via api calls.
this is why an explicit check for these keys and their respective results has been introduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Though, next time, let's keep the objectives per PR to 1 🙂
I half expected this - test coverage has taken a significant hit now that more files are included in the tested list. What to do... |
Let's ignore test coverage for We're more concerned with test coverage of logic, which lies in the |
2afbb0f
to
67fdbfb
Compare
added the didn't came to mind to check the coverage, yet it makes sense that we took this big hit. as for the now ignored dirs it might make sense to introduce e2e tests at some point, wdyt? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for this 🙏🏾
@@ -286,11 +279,29 @@ export async function deleteVote(vote: Vote) { | |||
vote.user.id, | |||
]; | |||
|
|||
const [votedItemsByUserRes, votedUsersByItemRes] = await kv.getMany([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Though, next time, let's keep the objectives per PR to 1 🙂
Yep! In fact, what if we move the newly created e2e tests from this PR to the root of the folder and name it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for this!
closes #315.
this pr adds a bunch of simple tests to have some coverage on our endpoints.
as described in the issue, it simply follows the guide as described here.
additionally it tweaks the
deleteVote
function, as theoretically, one could've downvoted an item into oblivion.