mediawiki-extensions-Echo/modules
Timo Tijhof 5a76489be0 tests: Fix QUnit warnings and resolve complex test_NotificationBadge
== Problem 1 ==

As of I09c27a084100b223,  tests/qunit/index.js or equiv was used to
load test files asynchronously from a using() callback. This was
untracked by RL or QUnit, and thus sometimes ended up finishing after
the test runner was already done executing all tests. In CI this
means the tests are sometimes never loaded and the browser (or Node)
process already killed before they even have a chance to arrive.

Prior to QUnit 2.17, this was no way of detecting this. As of
QUnit 2.17 (core upgraded last week) when running tests manually
the following helpful warnings appear in the console:

> [warning] Unexpected test after runEnd.
> [warning] This is unstable and will fail in QUnit 3.0.
> test	@	qunit.js
> tests/qunit/model/test_mw.echo.dm.SeenTimeModel.js
> require

There were about 1072 instances of this warning, all from Echo.

Fix this problem by removing the async callbacks and specifying the
two modules as normal dependencies instead.

== Problem 2 ==

Class NotificationBadge was being loaded in a strange way out of
bound. This was a violation of module boundaries and should not be
needed other than for a temporary hack or other tech debt. More
generally when a test uses `packageFiles` this is a likely sign of
tech debt or misunderstandings.

Instead, depend on `ext.echo.mobile` and export/import the class
as normal.

After this, the test module can use `scripts` instead.

== Problem 3 ==

The `ext.echo.mobile` uses a Mustache template which the test
was also duplicating a reference to. This is no longer needed now.

Due to the `qunit/index.js` file carefully splitting the operations
between template assignment and file loading, I wondered whether
it was meaning to replace or mock it with something else, but it
simply refers to the same file and only does this because it wasn't
using the module directly. This is now resolved.

If you do need to mock in the future, this can simply be done
by assigning `NotificationBadge.prototype.template` from a
beforeEach() callback in the test suite, or by supporting it
property as a constructor option in NotificationBadge.js and
assigning `this.template` there, which is supported by the
mobile `View` class already it seems and would follow DI patterns
more effectively.

== Problem 4 ==

Most of the Echo tests were ignored sometimes and executed other
times.

The test for `ext.echo.mobile` in particular though was never
executed in CI specifically because:

> Undefined module: 'mobile.startup'

This became a hard error with this patch, which is fixed by
the CI config change with Ie9dabe3269c56fa76db8e51.

Bug: T299780
Change-Id: Ie4a87f3b8085fd6ae53ec586c1782cc266d5288a
2022-03-02 12:52:06 +00:00
..
api build: Update eslint-config-wikimedia to 0.16.1 2020-06-15 16:19:00 +01:00
controller Allow marking all as read from popout window 2019-12-03 20:08:35 +00:00
icons build: Update SVGO to latest v2.3.0 and re-crush SVGs 2021-05-27 11:47:02 -07:00
logger Stop exporting wgWikiId, use wgWikiID from core 2019-09-25 18:14:40 +00:00
mobile tests: Fix QUnit warnings and resolve complex test_NotificationBadge 2022-03-02 12:52:06 +00:00
model eslint: Lint Gruntile.js using server rules 2022-02-07 16:30:24 +00:00
nojs Remove uses of .box-shadow() mixin 2021-09-03 19:21:39 +00:00
special Merge "Add visible help link for Special:Notifications" 2019-04-09 15:32:14 +00:00
styles Prevent welcome message partially truncated 2022-01-24 21:44:47 +01:00
ui Fix incorrect use of $.extend() 2020-10-03 18:30:30 +00:00
.eslintrc.json eslint: Lint Gruntile.js using server rules 2022-02-07 16:30:24 +00:00
echo.mixins.less Use '.text-overflow()' mixin from 'mediawiki.mixins' 2020-04-23 18:16:01 -07:00
echo.variables.less Replace static border radius value with var 2020-04-15 18:09:48 -07:00
ext.echo.init.js ext.echo.mobile: Name init function as such for clarity 2022-03-01 23:11:40 +00:00
ext.echo.moment-hack.js build: Update linters 2019-12-12 11:20:49 +00:00
hooks.txt (re)Add JavaScript hooks to Notifications 2016-10-14 17:25:25 -05:00