Commit graph

532 commits

Author SHA1 Message Date
Brian Wolff 8bb1fac8a0 Tests: More complete mock to prevent php 8.1 warning
fixes:
ContainmentSetTest::testCachedListInnerListIsOnlyCalledOnce
strtr(): Passing null to parameter #1 ($string) of type string is deprecated

Change-Id: I9bb916383eda1176a2d56c06770a60c28431dfda
(cherry picked from commit dbe112dfa8)
2022-10-04 14:33:07 +00:00
Umherirrender c81dad3efc Replace deprecated WikiPage::factory/newFromID
Replaced WikiPage::newFromID with newFromTitle,
because a Title object exists and could be reused

Bug: T297688
Change-Id: Ide30f259477ed8e0b48df31f5a23cafeb38d7316
2022-06-03 23:25:37 +02:00
Timo Tijhof 46484e8b53 tests: Use native QUnit.test.each(), ES5, and other cleanups
* Declare variables inline, as per the current code conventions.

* Convert ad-hoc cases objects into native QUnit.test.each().
  This makes for shorter and cleaner code, as well as for more
  detailed test reporting, and removes the need to manually construct
  assertion messages based on test case prefix string etc.

* Start adopting ES5 Array.forEach in a few places where otherwise
  ESLint would complain about variable name clashes.

* Future proof the test module names, by stripping the global variable
  namespace that some classes still use, matching packageFiles convention
  as used for NotificationBadge.js and its tests already, by specifying
  only the bundle name and the exported class name. Note that the
  QUnit UI does fuzzy matching so filtering works the same either
  way, e.g. "echodmfilter" will match "ext.echo.dm - FilterModel".

Change-Id: I49858dd2c95d0869f2cd15693f05c38312a9f710
2022-05-13 19:18:28 +01:00
Timo Tijhof 4c9968c71b tests: Remove use of QUnit 1.x setup()/teardown()
Bug: T250045
Change-Id: I51ff05ca32f08fe29e5edf35bbcb332112228981
2022-05-13 18:23:51 +01:00
Reedy b64c1f3642 Move EchoPush\Api namespace to MediaWiki\Extension\Notifications\Push\Api
Bug: T305667
Change-Id: I6168b386f532c83333cdc6700ba7e2917385a39c
2022-04-25 13:56:16 +01:00
Reedy c76761eff3 Move EchoPush namespace to MediaWiki\Extension\Notifications\Push
Bug: T305667
Change-Id: I5a7846a0fc383bddbf6511d6ba73c8be7d7760c7
2022-04-25 13:56:09 +01:00
Reedy f9c1a0fedb Namespace Hooks class
Change-Id: If948e7d376b40cf29480a9fcbf72a65a0eebacb7
2022-04-25 13:55:41 +01:00
jenkins-bot 047d92d059 Merge "Drop unused zero class" 2022-04-17 22:07:11 +00:00
Umherirrender c650698ac5 Call IDatabase::timestamp before inserting echo_unread_wikis
The default timestamp of 00000000000000 cannot represent as timestamp,
because it gets a negative timestamp -00011130000000

This is needed for proper cross-RDBMS support

This reapply a change from I46206e0b3a687dff3168a81cf0020e669133e876,
reverted with I1c8c409b7820512b3e31246a7f3d8c1cf4db209c.

Bug: T244898
Change-Id: I109b783de0a8d60ccb161b280ce5fa09e145017b
2022-04-11 23:12:02 +00:00
Jon Robson 5350bba546 Drop unused zero class
Not used anywhere.

Change-Id: I848650e4e3497664d712537437d8a10b22d6afb1
2022-04-04 18:20:27 +00:00
Amir Sarabadani ea21714241 Remove mocking of numRows
Deprecated and to be deleted

Bug: T286694
Change-Id: Id678f8366e7a9c18696083b2e331d2dce7d8a8eb
2022-03-15 17:36:29 +00:00
Kosta Harlan 4e125c5095 tests: Remove overlayManager from NotificationBadge params
Doesn't seem to be used anymore

Change-Id: I18f2709f000ca7469432a4c4bb919adfa0b3e829
2022-03-04 15:23:13 +00:00
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
Umherirrender 6af1473ca6 Replace deprecated wfReadOnly()
Bug: T283978
Change-Id: I5c796a0473599c71848b6079874bc7a969ee6f88
2022-02-11 23:39:06 +01:00
Umherirrender ffeee975a4 Replace deprecated User::newFromIdentity with UserFactory
Moved the factory deeper into the code right before the one usage it
still needed a full user object

Narrow done method arguments from User to UserIdentity
and use the identity directly

Change-Id: Ic118f23ef504c7fda892480df61ea68c10915f78
2022-02-11 20:35:49 +00:00
Ed Sanders ba38b57c83 eslint: Lint Gruntile.js using server rules
Change-Id: Ic7d67098492558fdd6cec292afd22aaf8693a594
2022-02-07 16:30:24 +00:00
osamaahmed17 020b44c43a selenium: Delete invisible unicode characters
Bug: T300386
Change-Id: I7c5db54247dc5b4566996afcbfab70b5fd4696a8
2022-01-31 09:02:09 +00:00
Umherirrender 9bf6ceb738 Replace deprecated JobQueueGroup::singleton()
Change-Id: I298d8507f4ec706c235087b726b7b230ed5e9ac6
2022-01-25 22:24:53 +01:00
jenkins-bot a8af58f362 Merge "Parse section titles in notifs as if they weren't at the start of line" 2022-01-24 05:43:44 +00:00
jenkins-bot ceda28121f Merge "Adjust doc for EchoNotification::readTimestamp" 2022-01-21 08:11:26 +00:00
Bartosz Dziewoński 3493317d79 Parse section titles in notifs as if they weren't at the start of line
The section titles are wikitext extracted from inside heading markup
like `== … ==`, so start-of-line markup like `*` should not be parsed.

Bug: T299572
Change-Id: Ie3995b943e5fe20ad86041d6be755f14f32eb01e
2022-01-21 00:07:53 +01:00
Alexander Vorwerk 4c7726a9ec selenium: reenable skipping of flaky test
Bug: T299339
Change-Id: I4d0838bdd6f1d0e1e220d1d611ae3e6e5c2b80eb
2022-01-17 16:26:35 +01:00
Kosta Harlan e4803b42e3 selenium: Add missing await statements
Follows-Up: 8327d33c99e495b109d97df7b525181dfc41c18d
Bug: T293073
Change-Id: Ib1862b857955999dbe7085a247e215e31eb89cff
2022-01-17 18:05:59 +05:00
Kosta Harlan 73496ec386 selenium: Skip flaky test
Bug: T299339
Change-Id: I6ff5d9d0e90b447112f5efea1489030238b52fac
2022-01-17 13:21:35 +01:00
osamaahmed17 9903581028 selenium: Refactor Echo WebdriverIO tests from sync to async mode
WebdriverIO has dropped support of sync mode due to breaking changes in Chromium, hence all tests of Echo have been changed to async.

Bug: T293073
Change-Id: I8327d33c99e495b109d97df7b525181dfc41c18d
2022-01-17 04:32:20 +05:00
Umherirrender 8e974de839 Adjust doc for EchoNotification::readTimestamp
And simplify the null check
Fix tests to provide null and not the empty string

Change-Id: Ic0f2dc09525f1542c7e62da97ac0f3fe936ff67e
2022-01-05 20:29:03 +01:00
Umherirrender d4640b31f0 build: Update eslint-config-wikimedia to 0.21.0
This includes the update of lockFile version

Bug: T225730
Change-Id: I04f2c6ef8751b3ffff886da4b69c2ed80425de91
2021-12-21 23:08:09 +01:00
vladshapik a3c55f6272 Avoid using User::getOption() method
Replace User::getOption() with UserOptionsLookup::getOption() since this method will be hard-deprecated.

Bug: T296083
Change-Id: I0ecdc63b0344bc4c24196cc5edb3d02b6a7ed615
2021-12-10 13:37:45 +01:00
libraryupgrader 2c3d370846 build: Updating mediawiki/mediawiki-codesniffer to 38.0.0
Change-Id: I10e9f9f6ddd9539ff95636902219c0e9fa35fc0f
2021-10-24 02:46:52 +00:00
Alexander Vorwerk 449f82faa3 MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: I68efac2c458748fa3ab16c4c652bd2c4af9cbb75
2021-10-12 00:42:10 +02:00
Matěj Suchánek 628122e155 Fix camelCase of getUserEnabledEventsBySections
Change-Id: I14b6750f7f3cc5334e3143f0e85ca033681b4e35
2021-08-20 17:03:28 +00:00
jenkins-bot 5cfc33d546 Merge "Add notifiertypes parameter to ApiEchoNotifications" 2021-08-19 05:06:57 +00:00
Matěj Suchánek 199c9084d4 Move isBundleExpandable to EchoAttributeManager
It's an attribute, so it is definitely the manager's
responsibility. Unit test case included.
(EchoDataOutputFormatter really calls for becoming a service.)

Change-Id: If2658dd8c107246158cd93cbb233d8af62fd4424
2021-08-18 18:23:22 -07:00
Michael Holloway 5eb4c6cd1d Add notifiertypes parameter to ApiEchoNotifications
Previously, ApiEchoNotifications returned only events which were
enabled for the `web` notifier type. With this change, the notifier
type or types to consider can be specified by argument to the new
`notifiertypes` parameter.

This change is required so that the apps can request notification
content from the API for push notifications.

Bug: T287909
Change-Id: I2d1155e113f2defb0f02416a7a659c3ee162d3a6
2021-08-17 10:27:14 -04:00
Matěj Suchánek ab8ea040ca Use constant in EchoAttributeManager::getNotificationSection
And as a bonus, add a unit test case to solve the todo.

Change-Id: Ic2e13eae6583155230be6c184db4836f28378483
2021-08-11 11:27:55 +02:00
jenkins-bot 66bb02fd8b Merge "Disable EchoGetEventsForRevision hook handlers while running tests" 2021-08-04 17:42:25 +00:00
jenkins-bot ec9ea8fc81 Merge "Tweaks to EchoTalkPageFunctionalTest" 2021-08-04 16:47:55 +00:00
jenkins-bot 5566f84378 Merge "Turn push notification token list into a circular buffer." 2021-07-30 14:46:10 +00:00
Dmitry Brant 6c5a88107c Turn push notification token list into a circular buffer.
At the moment we support a maximum of 10 tokens per user for subscribing
to push notifications, stored as a basic list that runs out when the
limit is reached.  There may, however, be some edge cases where an app
registers a token and then forgets to unregister it (and repeats this 10
times), after which time it will be unable to register any new token.

This changes the token list to behave more like a circular buffer, by
simply deleting the oldest token before inserting the new one. This way
an app could register a new token even in the rare case of forgetting
the previous ten.

Change-Id: I387de63460882e4e56d1aa6db1f78d73a0495208
2021-07-29 17:22:57 -04:00
Bartosz Dziewoński ee860bc577 Disable EchoGetEventsForRevision hook handlers while running tests
Extensions using this hook (e.g. DiscussionTools) cause test failures
otherwise.

Change-Id: I21159d03eebaf46ad94f4273ba698a59b8019185
2021-07-26 13:56:44 +02:00
libraryupgrader 17a644263a build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs are failing and were disabled:
  * PSR12.Functions.ReturnTypeDeclaration.SpaceBeforeReturnType

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* trim-newlines: 3.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: Id866782d39ac02a329bd79539f2d52392fffd296
2021-07-24 01:48:06 +00:00
Bartosz Dziewoński 762a2e192a Tweaks to EchoTalkPageFunctionalTest
* Fix off-by-one counting
* Fix asserting properties on the wrong event (first one instead of
  last one), luckily they are identical

Change-Id: Ib1a02476554b29b2a1d0bfdfa89859d71d7691b1
2021-07-21 23:25:54 +02:00
jenkins-bot a6dbadb006 Merge "Avoid using User::setOption()" 2021-07-17 10:29:45 +00:00
ZabeMath 3befbe0a69 Avoid using User::setOption()
User::setOption() is deprecated and should be replaced with UserOptionsManager::setOption()

Bug: T277818
Change-Id: I001301fb95635c421a0bbb921fd909c5312dc896
2021-07-17 09:52:53 +00:00
DannyS712 0099c45e54 AttributeManager: accept UserIdentity objects
Inject a UserOptionsLookup to replace deprecated
User::getOption()

Change-Id: I177f6d3486f987073e5d745077f0abfe9ae85aca
2021-06-29 06:41:47 +00:00
DannyS712 68f7a9a985 Use WikiPage::doUserEditContent() instead of ::doEditContent()
::doUserEditContent() is available since 1.36 as a replacement
for ::doEditContent(), which has been deprecated. Extension
already requires MediaWiki 1.37+, so the method is always
available.

Bug: T255507
Change-Id: Iee5de356dbccd453a3083e0a58859b4cd83a946b
2021-06-24 05:30:07 +00:00
jenkins-bot 73c124c498 Merge "selenium: Update wdio-mediawiki" 2021-05-26 15:07:07 +00:00
Željko Filipin b6a9950642 selenium: Update wdio-mediawiki
wdio-mediawiki v1.1.1:
- Includes wdio-defaults.conf.js file that vastly simplifies wdio.conf.js.
- Replaces @wdio/spec-reporter with @wdio/dot-reporter.
- Introduces video recording.

Bug: T283597
Bug: T276503
Change-Id: Ic80f90dbbd5604dc3c9afe3303862edbf46b1cd2
2021-05-26 13:36:53 +00:00
jenkins-bot c9839d897b Merge "selenium: Update README.md file" 2021-05-26 10:01:08 +00:00
anjali041 0001ee4dc3 selenium: Update README.md file
Bug: T282237
Change-Id: I87018d39e9a9d6fb101ad5e1f7c4f13f8200611e
2021-05-25 16:03:45 +00:00