Skip to content
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

Setting dates in expected output and input files can become stale due to not being able to set expected dates when tests run. #3

Open
newtewt opened this issue Jul 17, 2019 · 4 comments

Comments

@newtewt
Copy link
Contributor

newtewt commented Jul 17, 2019

@binokaryg found this issue.

Calculating anything based on now ( which is equal to Date.now() in some projects) in contact-summary-extras.js and then using static expected json file will eventually fail. As this is a cli I guess we could pass a parameter in to change the date or maybe get rid of the cli and make it a framework that's imported. Then use it within mocha or maybe there's some other magic in JS that could happen. @abbyad is there a reason we went CLI? I personally think it would be an easy change to set now to whatever the expected date was if we used it more in a framework style.

This would be an issue in standard config for the immunizations contact summary. The contacts birth is set to "2018-01-03" and immunizations checks that DOB in months to be less than 144. Eventually that contact would be over 144 months old.

In CHT config we are comparing lmpDate > now - 294 * MS_IN_DAY to insure that the pregnancy is within 9 months. Once the Date.now() is past that threshold the tests would begin to fail.

@abbyad
Copy link

abbyad commented Jul 18, 2019

Seems worth making this easier to use, but I am not clear on what you mean by "framework style". Can you propose what you think it should be like, and provide an example?

@newtewt
Copy link
Contributor Author

newtewt commented Jul 18, 2019

You'd use this similar to any other npm package. As in you'd setup a standard mocha test and then require in contact-summary-testing and pass use it within mocha instead of having it loop over a folder structure.

@newtewt newtewt changed the title Need ability to set dates calculated in either contact-summary-extras.js or possibly in the supplied json files. Setting dates in expected output and input files can become stale due to not being able to set expected dates when tests run. Jul 18, 2019
@kennsippell
Copy link
Member

As in you'd setup a standard mocha test and then require in contact-summary-testing

Should we merge this into medic-conf-test-harness then? It already has functionality for mocking the expected date in xforms, tasks, and targets code. Sounds like a good fit.

@newtewt
Copy link
Contributor Author

newtewt commented Jul 18, 2019

@kennsippell I think that'd be a good idea. It'd be one less repo to manage and all testing stuff would live in one place. I know @abbyad mentioned we would want to make this more friendly for non programmer style persons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants