medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
467 stars 217 forks source link

Targets config testing : mock dates #2152

Closed estellecomment closed 7 years ago

estellecomment commented 8 years ago

We have a synthetic_date in app-settings, which is useful for testing your instance config. Targets are ignoring it, so you have to set your laptop's date backwards to test targets...

Edit : synthetic_date is on the server, while the targets are computed on the client. We need a synthetic_date on the client, to avoid having to fiddle with the machine's date.

abbyad commented 8 years ago

I would have thought that the synthetic date worked only for server side dates (eg for new reports or scheduled messages) and not for client side calculations (eg as used in Task/Target rules). That is probably what you are experiencing. I am curious if it is sufficient to communicate what is client vs server side.

estellecomment commented 8 years ago

Oh, that's right. Renaming the issue then : we need an easy way to mock dates client-side for targets config testing.

mandric commented 8 years ago

Why the distinction?

estellecomment commented 8 years ago

? Not sure what you mean. To clarify, the synthetic_date is set on the server, while in 0.6 the targets are computed client-side, so the client doesn't see synthetic_date. Basically we need a synthetic_date in the browser. Does that answer your question?

mandric commented 8 years ago

App settings are replicated to the browser last I checked?

abbyad commented 8 years ago

The reason we had "synthetic date" was that it was hard for a PM or Tech Lead to test SMS schedules because they couldn't change the server date. It is easier to do it on a local machine, but not necessarily convenient. Are there cases where changing it locally does not calculate the targets properly?

mandric commented 8 years ago

If we need a synthetic date during testing I would just request a feature than expect people to modify their local machines, that can screw up all kinds of things.

estellecomment commented 8 years ago

Yes, that's my point! Setting my machine's date back sucks. Editing the original description then.

nice-snek commented 7 years ago

hi frand @SCdF, please triage before the end of this sprint. :parrot_conga::parrot_conga::parrot_conga:

SCdF commented 7 years ago

In general mocking dates at a system level is really challenging, and even more so in Javascript.

I think if there is someone who is testing around this and finds it challenging, that would be the time to look into fixing it.

mandric commented 7 years ago

Just to clarify the synthetic_date setting is app level not system level. We should never change a system's time for app testing purposes.