Conversation
…e_id" This reverts commit ce01ce9.
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
I'll add unit test for the new helper method I forgot |
…em-and-get-stock-to-the-clans-to-which-they-belong
|
One question before merging: has this been tested via the backend on Postman/Bruno/the terminal (in-memory testing/other methods)? @constf03 |
Sorry I should have asked about this before but how to properly test authenticated routes in postman? Is there a seeder script that populates the local docker db tables with test data or do I have to manually do the flow of creating 2 players, then login via /auth, create 2 clans and their respective Stock and Item objects? |
|
I've always done it manually, and hated it. The auth is valid for a longer-than-average time period, but setting up is a PITA. That's why in smaller issues I've resorted to this: This method is called isolated script testing (or in-memory testing). It should be applicable here as well. On the seeder script, that's a good "nosto", I'll remember to bring it up or create an issue for it, since currently the setup is indeed time-consuming and tedious if you want to go the full Postman/Bruno route. |
👍Good to know thanks, I'll try something like this or manually do it on Postman, until then this PR can wait |
|
@CapoMK25 Tested it in-memory and seems to work as intended, results in the PR description |
…em-and-get-stock-to-the-clans-to-which-they-belong
Brief description
Restricts read access to endpoints GET /item/:id and GET /stock/:id to logged-in Players who belong in the same Clan as the Item and Stock objects (same clan_id).
Change list
ItemHelperService.getItemClanId())errorsarray and @ LoggedUser() parameter decoratorTests
Tested the GET /item/:id and GET /stock/:id routes via in-memory testing. The script initializes MongoMemoryServer and required Item, Stock, Player modules and runs the Item controller and Stock controller get() methods with result logs. Below is the script and result.
Script:
Result:
I didn't write it inline because there was module/import errors however running the script from a temporary .ts file worked (hence the ./test.ts). Also for the "missing" status it shows n/a instead of 404 because the Item controller and Stock controller do not directly build a 404 error instead it comes from BasicService.readOneById.