We now only expose mock_template as a helper in run_test.
This has the following advantages:
* less boilerplate at the top of the file
* more surgical control with setting exercise_templates
* no more "f" hack (or render_foo consts)
* we force devs to explicitly mock the template
See frontend_tests/zjsunit for the substantive changes.
All the changes to the tests are very mechanical in nature.
There were some changes that were lost/added by mistake
during a rebase of #17707 after #18154 was merged.
Fixes the GIF icon being hidden / displayed incorrectly
with respect to the settings.
These changes were originally part of
67527a2517 but
were lost during the rebase.
Since we can have multiple instances of `message_edit_form`, it
makes sense to have it as a class.
We track the message_edit_form by setting an id to
`form` element dependent on message_id.
We move compose.html to compose.hbs file while keeping
`#compose` still in `home.html` as a hanger
where append rest of the elements.
This will provide us with two benefits:
* We could share common elements between message_edit_form and
compose.
* We can insert compose directly in any element. We may decide to
do it for recent topics.
Use fully resolvable request paths because we need to be able to refer
to third party modules, and to increase uniformity and explicitness.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
For most functions that we were using __Rewire__ for,
it's better to just use the override helper, which
use __Rewire__ under the hood, but also resets
the reference at the end of run_tests.
Another nice thing about override() is that it reports
when you never actually needed the mock, and this
commit fixes the instances found here.
I didn't replace every call to __Rewire__. The
remaining ones fall under these categories:
* I looked for ") =>" in my code sweep,
so I missed stuff like "noop" helpers.
* Sometimes we directly update something
in a module that's not a function. This
is generally evil, and we should use setters.
* Some tests have setup() helpers or similar
that complicated this code sweep, so I
simply punted.
* Somes modules rely on intra-test leaks. We
should fix those, but I just punted for the
main code sweep.
This is a deceptively ugly diff. It makes
the actual code way more tidy.
I basically inlined some calls to mock_module
and put some statements in lexical order.
We now just use a module._load hook to inject
stubs into our code.
For conversion purposes I temporarily maintain
the API of rewiremock, apart from the enable/disable
pieces, but I will make a better wrapper in an
upcoming commit.
We can detect when rewiremock is called after
zrequire now, and I fix all the violations in
this commit, mostly by using override.
We can also detect when a mock is needlessly
created, and I fix all the violations in this
commit.
The one minor nuisance that this commit introduces
is that you can only stub out modules in the Zulip
source tree, which is now static/js. This should
not really be a problem--there are usually better
techniques to deal with third party depenencies.
In the prior commit I show a typical workaround,
which is to create a one-line wrapper in your
test code. It's often the case that you can simply
use override(), as well.
In passing I kill off `reset_modules`, and I
eliminated the second argument to zrequire,
which dates back to pre-es6 days.