Refactor test parameter validation into shared helpers#1583
Refactor test parameter validation into shared helpers#1583huss merged 2 commits intoOpenEnergyDashboard:developmentfrom
Conversation
|
@KaulanSerzhanuly I see you checked the box for having completed the CLA. However, I did not find it in the OED records. If you have under a different GitHub ID or think the OED records are off then let me know. Otherwise, could you please fill it out. |
|
Hello I did sign everything tho, it was under this accounts ID. This accounts email is kaulan.2004@gmail.com and name to this account is KaulanSerzhanuly. Just in case i have resubmited it |
|
I forgot to tag you sir @huss |
|
@huss Hello again i resubmited OED record. Could you please check it again? |
huss
left a comment
There was a problem hiding this comment.
@KaulanSerzhanuly First, I'm sorry this took a few days while my efforts needed to be elsewhere. Second, thank you for this work. Overall, I like these changes. It caused me to think in a deeper way about possible centralization and I've made a number of comments about this. I want to note that I did not carefully think them through so it may be the case that it does not apply across all routes. It is also possible my modest comments are not clear enough. Please feel free to put in your thoughts and ask me about anything. I'm always here to help.
| .send(payloadWithExtra); | ||
|
|
||
| expect(res.status).to.equal(HTTP_CODE.FORBIDDEN); | ||
| await validateNoExtraFields({ |
There was a problem hiding this comment.
I'm not going to mark every one but here is one where I wonder about a wrapper function to set these values and then call the validate function as one or more params are the same across tests.
There was a problem hiding this comment.
Reasonable. I didn’t add that wrapper here to keep the diff focused; happy to add a local helper (or a tiny test util) in a follow-up if we standardize on the same forbidden + base payload shape in several tests.
|
Thanks for the thorough review and for flagging that some ideas might not fit every route—I’ll call those out where I left them for later. |
|
@huss Please check out the lastest changes I pushed |
Oops! I lost track of this. I plan to look at it in the near future. |
huss
left a comment
There was a problem hiding this comment.
@KaulanSerzhanuly Thank you for carefully and thoroughly addressing my previous comments. There are a couple unresolved but I view them as future work. I don't want perfection to be the impediment to progress. You fixed all the important cases (and then more) and this addresses creating general test code for routes. If you want to do anything else on this or something else then you are welcome to contact me. Congratulations on your first accepted pull request to OED.
Description
ParamsTest.jsfiles to use shared helpers from src/server/test/util/validationHelpers.js instead of duplicating validation logic.Details:
validationHelpers.js:compareReadingsParamsTest.jsconversionsParamsTest.jsgroupsParamsTest.jsmapsParamsTest.jsreadingsParamsTest.jsunitAddParamsTest.jsFixes #1572
Author: Kaulan Serzhanuly
(In general, OED likes to have at least one issue associated with each pull request. Replace [issue] with the OED GitHub issue number. In the preview you will see an issue description if you hover over that number. You can create one yourself before doing this pull request. This is where details are normally given on what is being addressed. Note you should not use the word "Fixes" if it does not completely address the issue since the issue would automatically be closed on merging the pull request. In that case use "Partly Addresses #[issue].)
Type of change
(Check the ones that apply by placing an "x" instead of the space in the [ ] so it becomes [x])
Checklist
(Note what you have done by placing an "x" instead of the space in the [ ] so it becomes [x]. It is hoped you do all of them.)
Limitations
(Describe any issues that remain or work that should still be done.)