Commit graph

441 commits

Author SHA1 Message Date
Roan Kattouw c87cae39d7 Make Echo QUnit tests run again
The automatic registration for these was broken, because
$wgResourceModules no longer contains Echo's modules (since they are now
registered in extension.json).

Instead, add the test files in tests/qunit/model/ explicitly in
onResourceLoaderTestModules. The tests in tests/qunit/mobile/ are
already added through QUnitTestModule in extension.json.

Delete the ext.echo.overlay tests, they were testing code that was
removed years ago.

Bug: T258818
Change-Id: I7b996dc8631a86033830cf532f1b8e85251788ad
2020-07-24 13:26:34 -07:00
Ed Sanders 1b40b69481 Make default snippet length (150) a constant
Change-Id: Idb53b226618fa0d625c7e4713c780538bd6a76ea
2020-07-23 13:00:44 +01:00
jenkins-bot a2c6b21925 Merge "Update hooks to use PageSaveComplete" 2020-06-30 10:40:51 +00:00
Umherirrender 3c53d6acb9 phpcs: Break long lines
Use the codesniffer default of length = 120

Change-Id: Ifbfd56b20432e54805d3a9bce22cda888c1fc74d
2020-06-27 12:05:03 +02:00
DannyS712 28a5eafe8c Update hooks to use PageSaveComplete
Extension requires MW 1.35+, always available

Bug: T250566
Change-Id: I1131a50f03002337d6b6eac18fdcb6adaaa896ce
2020-06-26 15:59:04 +00:00
vidhi-mody f25ed7e705 Selenium: Update to WebdriverIO v5
Update NPM packages: webdriverio, wdio-mediawiki.

Replace NPM packages:
- wdio-mocha-framework with @wdio/mocha-framework.
- wdio-spec-reporter with @wdio/spec-reporter.

New NPM packages: @wdio/cli, @wdio/local-runner, @wdio/sync.

Replace:
- `browser.element` with `$`.
- `chromeOptions` with `'goog:chromeOptions'`.
- `password` with `mwPwd`.
- `username` with `mwUser`.
- `waitForVisible()` with `waitForDisplayed()`.

Bug: T250610
Change-Id: If7a5ee9588f082be18f27ee45a051ae956c688f5
2020-06-22 15:54:30 +00:00
jenkins-bot 8fe5e47b76 Merge "Push: Add additional job params for logging" 2020-06-18 10:55:37 +00:00
Michael Holloway a2412732f6 Push: Add additional job params for logging
Adds additional job parameters to help diagnose the apparent issue of
jobs being performed twice on Beta.

Bug: T255068
Change-Id: Ib257a24056539487e1110fe286fa4535c3fec94a
2020-06-17 17:58:21 -04:00
Ed Sanders ffe3363d09 build: Update eslint-config-wikimedia to 0.16.1
Change-Id: I2ce14429f9440e69e36fa349847f58fb32862f2a
2020-06-15 16:19:00 +01:00
Michael Holloway 1d31fd753a Push: Submit requests to configured service endpoint
Finishes the implementation of the stubbed NotificationServiceClient.
Sends push notification request messages to the endpoint configured in
the EchoPushServiceBaseUrl setting. For example, to send messages to an
instance of mediawiki/services/push-notifications running on the host
machine while running MediaWiki in Docker, add the following line to
LocalSettings.php:

 $wgEchoPushServiceBaseUrl = 'http://172.17.0.1:8900/v1/message';

Bug: T252899
Change-Id: Icab7825e9080d6b1a4cfc5e12fed1da221ce4610
2020-06-08 13:37:24 +00:00
Michael Holloway a5bcc65504 Fix push subscription retrieval
Updates the push subscription query to retrieve a provider string rather
than only its numeric internal ID.

Change-Id: I910173409e48e8b6a6739d3122165c40b0d52b7f
2020-06-08 13:58:42 +02:00
Michael Holloway ce7a46f7ed Add push notifier
Provides a basic push notifier implementation. Since the push service is
not yet in place, all it does for now is log debug output when a
notification is to be sent.

To register the push notifier, add the following configuration to
LocalSettings.php:

 $wgEchoNotifiers['push'] = [ 'EchoPush\\PushNotifier', 'notifyWithPush' ];
 $wgDefaultNotifyTypeAvailability['push'] = true;
 $wgNotifyTypeAvailabilityByCategory['system']['push'] = false;
 $wgNotifyTypeAvailabilityByCategory['system-noemail']['push'] = false;

We'll register the notifier in configuration for now, rather than
hard-coding the default in extension.json, in order to have control over
when and where it rolls out (beta vs. prod, as well as which wikis).

Since the push notifier implementation depends on jobs being processed
by the job queue, I also recommend adding the following configuration
setting to ensure that all pending jobs are processed at the end of each
web request:

 // ensure all pending jobs are processed when a web request completes
 $wgJobRunRate = PHP_INT_MAX;

Bug: T252899
Change-Id: Ie7f222443045d30620ff297b006104ef18a074a8
2020-06-02 13:40:04 -04:00
Michael Holloway a3674974f1 Add push subscription management
Adds DB tables for storing push subscriptions, some DB interaction code
for retrieving them within MediaWiki, and a set of API modules for
managing them from the outside world.

When testing this patch, be sure to run maintenance/update.php to create
the new tables, and set $wgEchoEnablePush = true in LocalSettings.php
to enable the API new API module.

N.B. The current DB schema is centered on app push subscriptions. Web
push subscriptions require slightly different handling, since they are
provided by browsers as a JSON blob rather than a token string. How to
handle web push subscriptions is a question we can defer until the time
comes to add web push support.

Subscription data is stored in the echo_push_subscription table, with
provider names normalized into the echo_push_provider table. We expect to
be looking up subscriptions by central user ID, so that column is indexed.
The subscription data also includes a column to store SHA256 digests of
the subscriber tokens. This is for use as a unique key constraint, since
we expect every push token to be univerally unique, and the token values
themselves may be too large to reasonably index in MySQL.

Bug: T252899
Change-Id: I3928761b3fba12e54ff4850e9a05c68ec7772f62
2020-06-02 13:40:00 -04:00
Roan Kattouw 28f432b150
Add dynamic secondary action to mute/unmute page-linked notifications
Also adds an API module for muting and unmuting pages (and users).

Bug: T46787
Bug: T115264
Change-Id: Icf4e4bfa9fd7fa27b4c40892e3d5ce000eb22d5a
2020-05-27 15:20:08 +02:00
Kosta Harlan 1560528dc7 Add page linked event title muted list
* Add a section on the preference form to allow users to mute articles
  from generating "page linked" notices
* The preference will save the article title as an article ID

Depends-On: Ia0ddf78646ec4c8ae0b84b6d5b46ef5e51c8e8c1
Bug: T46787
Change-Id: I67f751eae5fdc5bccff7fe3047227d432c1cb8d5
2020-05-06 12:38:55 +02:00
Daimona Eaytoy 1be7adf0a8 tests: Avoid calling Title::__construct
Change-Id: Icfe39e0835b4779bf538c2aea9a15cacbdcd6ff5
2020-03-14 18:41:08 +00:00
Umherirrender a933412ea5 Use MediaWikiServices::getMessageCache
This required MediaWiki 1.34 (already set in extension.json)

Change-Id: Ib9f9fe6581c3019fa32dff53acf33edb4266e44d
2020-03-14 14:04:32 +01:00
DannyS712 72f30649d5 Pass a user when creating a new ParserOptions
Bug: T246861
Change-Id: Ie6b6504d3b78a33ecb89a5c431bc225622d715c2
2020-03-04 21:53:33 +00:00
Daimona Eaytoy c256faf968 Remove hack for PHPUnit's Stub interface
This partly reverts commit c19c88567b.

Bug: T192167
Depends-On: Ia12658554c94497a204b7f65f1a6f7b1fa0310ac
Change-Id: I4ef736d87d05f74920ce88f57b0ad824986adb26
2020-01-23 12:34:48 +00:00
Daimona Eaytoy 07ff3debe5 Stop using PHPUnit deprecated methods
Change-Id: I77eefbd6f8b76620257c68be1c299868b5f5ff88
2020-01-14 15:59:46 +00:00
libraryupgrader ff43e1ecf2 build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.Usage.ForbiddenFunctions.isset
* MediaWiki.Usage.PHPUnitDeprecatedMethods.AssertInternalTypeGeneric

Additional changes:
* Also sorted "composer fix" command to run phpcbf last.

Change-Id: I29416247ff3736799543926813beaf4afd569a6e
2020-01-14 05:09:44 +00:00
jenkins-bot 19d88be6cf Merge "build: Update linters" 2019-12-12 17:52:35 +00:00
Ed Sanders 80ddee3956 build: Update linters
Change-Id: I713aafb891306fc21a776a7d4622c6a039798753
2019-12-12 11:20:49 +00:00
Pppery db78c1552e Add support for watchlist events
Bug: T203941
Change-Id: I9bcd13cb0a547393696dde0e977b7761cc1fea68
2019-12-11 16:39:02 -05:00
Daimona Eaytoy c19c88567b Hack: back-compat for PHPUnit's Stub interface
Until PHPUnit7, the Stub interface came from phpunit-mock-object, and it
was at PHPUnit\Framework\MockObject\Stub. Then, phpunit-mock-object was
merged into PHPUnit, and:
 - The interface above was moved to PHPUnit\Framework\MockObject\Stub\Stub
 - The FQSEN above started pointing at a completely different interface
 
This is a temporary hack to allow upgrading to PHPUnit 8, and MUST be
removed as soon as the upgrade is complete.

The :string typehint is also necessary in PHPUnit8, and it will work
with PHPUnit 6 as well.

Bug: T192167
Change-Id: I07cebd07088bced5c5ddc62936f0098dfa39e151
2019-11-18 16:58:18 +00:00
jenkins-bot 4b6fc85f39 Merge "Use absolute class names in @covers tags" 2019-10-24 18:37:15 +00:00
jenkins-bot 41fd67da53 Merge "Prefer strict assertSame() for all numeric assertions" 2019-10-24 07:12:31 +00:00
jenkins-bot 962f958a8c Merge "tests: Kill last use of deprecated getMock()" 2019-10-23 23:26:31 +00:00
Thiemo Kreuz 229c3d0fdd Remove non helpful (auto-generated) comments
None of these comments explains anything that wouldn't be obvious
from the code itself.

Change-Id: Ibcf50d401999ae76f315df2d2d27097a39f41bbd
2019-10-23 12:31:35 +02:00
Thiemo Kreuz bc3dabf828 Prefer strict assertSame() for all numeric assertions
assertEquals() does not compare the type. It can not only be a float,
it can even be a string. E.g. 9 and '9' are considered equal.

Worst case scenarios are:
* 0 is considered equal to any "falsy" value, including the empty
string.
* 1 is considered equal to true.

assertSame() does not have any of these confusing edge-cases.

Change-Id: Ib6af0fefbbd8856adcf27844bb8ddd8e33ed3f9d
2019-10-23 12:28:30 +02:00
Thiemo Kreuz 967a0b54e9 Use absolute class names in @covers tags
Not all tools require these to be absolute, full qualified class
names. But some do. This does make the code more compatible with all
kinds of tools.

Change-Id: Ie7f9d9469b7a48b2fe908d3428fca9ec0120f855
2019-10-23 12:23:09 +02:00
Max Semenik 94646b0de0 tests: Kill last use of deprecated getMock()
Change-Id: I6bb9fcce07389868544b25875d95a1af628a1136
2019-10-23 09:02:12 +00:00
James D. Forrester abaff73626 build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: Ib66b0ad1b3929bf7e49eb40a3d5463b0d8b2280b
2019-10-10 09:29:24 +00:00
jenkins-bot cd6a340ce8 Merge "Dormant mobile notifications overlay lives in Echo" 2019-10-09 19:50:57 +00:00
jdlrobson d3c0494a17 Dormant mobile notifications overlay lives in Echo
This code will be enabled when Iba1d7863171268066bf7597182c57a0a2041497f
relinquishes the responsibility for rendering the Echo notification badge
and wiring up of the related JS.

It makes 3 assumptions:
1) Minerva will expose a VERSION property on the skins.minerva.scripts module
to tell Echo it can begin control of the functionality
2) A new hook `SkinMinervaReplaceNotificationsBadge` will run on the server side
allowing Echo extension to render the Notifications badge in Minerva.
3) A new client side hook (echo.mobile) will fire whenever the Echo dialog is opened or
closed.

All code relating to Echo inside MobileFrontend and Minerva is
moved here.
CSS for the modules is kept in Minerva as skinStyles

This code remains dormant until Iba1d7863171268066bf7597182c57a0a2041497f lands.
It pre-registers a "to-be-created" hook SkinMinervaReplaceNotificationsBadge that
substitutes the Minerva badge.

It also watches the export value of skins.minerva.scripts for a VERSION value - when
this appears it will take the signal that it should manage the frontend code.

In the new system the mobile specific code is limited to the mobile version of
Minerva. The desktop version of Echo loads on Minerva desktop - presenting an
opportunity in future to consolidate both implementations to use the same component.
The mobile version of Vector and Timeless for example will load the mobile overlay
(with existing styling issues that we don't need to worry about right now given
we don't officially support skins other than Minerva as mobile)

Testers:
* Check require( 'ext.echo.mobile' )(); inside initMobile
inside ext.echo.init does not fire until
Iba1d7863171268066bf7597182c57a0a2041497f is checked out.

Depends-On:  I1a66939d2b596094b419de40b370e79f09c85581
Bug: T221007
Change-Id: I09c27a084100b223662f84de6cbe01bebe1fe774
2019-10-09 12:36:11 -07:00
Max Semenik 7e9e549743 Use PHPUnit 6 class names
Bug: T192167
Change-Id: Id309ad5933371dd835ec431ded80f650e228099c
2019-10-06 15:23:15 -07:00
Max Semenik 031e6d37bf Drop old PHPUnit rudiments
Change-Id: I0a69ee7826227ee195415e43dc688f76602ed02b
2019-10-04 20:54:45 -07:00
mainframe98 b942fa3c65 Inject PermissionManager into Userrightspage in tests
With I40fc8a709de96aceee14a10c973cd5b0a9a6f063 UserrightsPage
now requires the PermissionManager service to be injected.

Change-Id: Ibf3728c1e143787fb35b88ad8a8d5aabc8fadcb8
2019-09-13 18:24:52 +02:00
Kosta Harlan 15d36ccae5 Remove global usage in UserNotificationGateway
As noted in Ic22075bb5e, UserNotificationGatewayTest relies on the presence of
globals. When Ic22075bb5e is merged, UserNotificationGatewayTest will fail in
CI. This patch injects the configuration object into UserNotificationGateway.

Change-Id: I9c15a588a76a41a3ebfb59dac7f0761f756008ff
2019-08-30 22:58:41 +02:00
jenkins-bot 42fd16e0f3 Merge "Update for MessageCache as a service" 2019-08-19 15:36:45 +00:00
Aryeh Gregor 7290434158 Update for MessageCache as a service
Change-Id: I546eda0377f3a50843144b1450d3fbe8e4e02a8a
2019-08-18 11:46:11 +03:00
Kosta Harlan efd759402f Skip broken Selenium test
Caused failure in
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Echo/+/524520#message-7f1addb6b8b09919581014fe18c6dddef32fb078

Bug: T227009
Change-Id: Iae088bc7c966f927a15d06a4de5966a76913dbe4
2019-07-30 16:54:31 +02:00
Dayllan Maza b3df45dc34 Add option to mute/unmute notifications on Special:Mute
The hook (SpecialMuteModifyFormFields) is used to append
the option to mute/unmute echo notifications from a specified user.

Special:Mute handles posting and saving the fields, the only
requirement is that the field name is the same as the property
that wants to be modified, in this case 'echo-notifications-blacklist'

Bug: T220163
Depends-On: I2b3eee0802cb086091f35ecce13ae77a8e7d518d
Change-Id: I77b3ccfdce9b501eb8ecd58c0d7bbecb78029a7e
2019-07-18 15:47:24 +00:00
Amir Sarabadani 7a27d13a7b Move unit tests, round II
Change-Id: I4a419ae44a73ece55f2519dddc1aac4bedebc9e4
2019-07-15 18:10:01 +02:00
libraryupgrader 4bf8a6736a build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 24.0.0 → 26.0.0

npm:
* set-value: 2.0.0 → 2.0.1
  * https://npmjs.com/advisories/1012
  * CVE-2019-10747
* union-value: 1.0.0 → 1.0.1
  * https://npmjs.com/advisories/1012
  * CVE-2019-10747
* mixin-deep: 1.3.1 → 1.3.2
  * https://npmjs.com/advisories/1013
  * CVE-2019-10746

Change-Id: I6d3efdf65c207b98447565e2df6f0698aaa8ea6b
2019-07-14 10:57:49 +00:00
Amir Sarabadani 1c93cba790 Move unit tests to the new structure
Change-Id: I02e2a33149eee859ec10ab7f8265609b0f17d1cc
2019-07-12 18:22:52 +02:00
ephemeralwaves 05f3e66a9d Selenium: Fix failing test by only running tests tagged @daily
Changed `selenium-daily` npm script to only run tests tagged `@daily`
and removed `it.skip` on tests failing in beta cluster.

Bug:T227009
Change-Id: Id2edbfd941df098d326fa30ed9dc9f68e228f021
2019-07-05 10:58:19 +00:00
Željko Filipin e76e9f9b5c Selenium: Fix failing Jenkins job by disabling failing tests
Bug: T227009
Change-Id: I5d2fcc1e6f50e73375c834e1167726273c82025c
2019-07-01 17:49:29 +02:00
jenkins-bot c2669ba0b3 Merge "Selenium: Test that checks for user mention alerts" 2019-06-19 10:42:06 +00:00
ephemeralwaves dd4539b522 Selenium: Test that checks for user mention alerts
Check that a user gets an alert when their username is mentioned by another user.

Bug: T224894
Change-Id: I303e10a40d1092e4b9f81deef0f1ac2af6f7a435
2019-06-19 10:23:22 +00:00