Commit graph

574 commits

Author SHA1 Message Date
Thiemo Kreuz 1cf721e2a2 Handle collapsible & sortable elements in reference popups
Elements that are marked as collapsible (often tables, but can
actually be anything) are most certainly marked as such because
they are big and don't fit in a popup.

Another plugin makes tables sortable.

In both cases non-functional UI elements appear in the popup.
We decided:
* Hide collapsible elements (no matter if currently collapsed
  or not), and show a placeholder text instead.
* Remove sortable arrows.

This is a baseline patch that solves everything, except the
(i) icon is missing. This will be added in the next patch.

Bug: T220208
Change-Id: I58f3036bf4988d0ebe5716b0a54506446fca10c3
2020-10-28 17:23:12 +01:00
Thiemo Kreuz 26ca2bcf5b Scroll reference heading as well
Bug: T249548
Change-Id: I808ee9aadc8766490e98267bb94d25887f404362
2020-10-28 11:26:52 +01:00
Thiemo Kreuz d6ab2072e3 Open only external links in new tabs
There are 3 types of links:
* Links with no class are links to other pages in the same wiki.
* Links with "extiw" are interlanguage as well as interwiki
  links to other known wikis (e.g. from Wikipedia to Wikidata).
* Links with "external" point to somewhere else on the web.

Bug: T215419
Bug: T239230
Change-Id: Ia25db94d02670a919fc003f3e3562725de2e8eae
2020-10-20 10:52:05 +02:00
Umherirrender 23b6332a5b Avoid shadowed variables in javascript
The rule no-shadow gets enabled in the version eslint-config-wikimedia
0.17.0.
In prepration for the automatic update with libup this needs to be done
in a separate patch set due to T262450

Change-Id: I66d405aef6d2b777e9a7f63734f2b5a5649d2080
2020-09-21 20:31:44 +00:00
vidhi-mody 17a3e59a1e 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.
- wdio-junit-reporter with @wdio/junit-reporter.

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

Commands that return data no longer wrapped in `{ value: … }`.
Values are now returned directly.

Replace:
- `browser.element` with `$`.
- `chromeOptions` with `'goog:chromeOptions'`.
- `password` with `mwPwd`.
- `username` with `mwUser`.
- `moveToObject()` with `moveTo()`.
- `isVisible()` with `isDisplayed()`.

Bug: T258620
Change-Id: If339ff08b5e87c91905a65927ccd7e1b72b9f8e4
2020-07-24 17:17:01 +05:30
Ammar Abdulhamid 5e405eb2f2 Popups: Rename new config variable
In this patch we introduce a new config variable and update its default
to be the same as the production value of $wgPopupsPageBlacklist.

When this code is deployed everywhere, we will remove wgPopupsPageBlacklist
from mediawiki config and defer to the Popups extension as the source of
truth from now on.

Bug: T254676
Change-Id: Ifebdcf8f5eec854a2b947dc390eaf47704a5c5eb
2020-07-07 09:47:59 -07:00
Ed Sanders 536470c01d build: Update eslint-config-wikimedia to 0.16.2
Change-Id: Icb65074fe64993314bbb28f690ce3ce0f89fb57c
2020-06-26 17:05:56 +01:00
Thiemo Kreuz 092e2a4959 Talk about "exclusions" instead of "blacklists"
AVoid the term if possible, in all internal code. The only remaining
use of the word is in the public $wgPopupsPageBlacklist config
variable.

Change-Id: Ib238731270f473ad44fcff13df617a70433f2452
2020-06-09 08:56:06 +02:00
DannyS712 48f3a8f720 Remove unneeded ::setUp and ::tearDown methods that only call parent
Change-Id: I2700613e5071bc20ef8ed9706de70e596cdfdbc7
2020-06-07 03:10:11 +00:00
Ed Sanders 1703736805 eslint: Fix selenium config
Change-Id: I7baea467c1d7ac44d9fb1788cf9a3fb8d520c6b1
2020-05-02 14:27:00 +01:00
Ed Sanders 957e81747b eslint: Update to 0.15.3
Change-Id: Ide2bdfac7838408c39e1d26ea7662b90a6e3ddfd
2020-04-25 22:32:53 +01:00
Ed Sanders 050911fe11 Use faster implicit conversion instead of Number.parseFloat
Change-Id: Ide478617475c73bfe6a81cdb171d606082a1448b
2020-03-03 17:26:55 +00:00
DannyS712 68d52f7fa9 Use assertTrue instead of assertSame to compare with true
Bug: T244552
Change-Id: I42c50e37515e49a15658041147edc1d644812c46
2020-02-07 07:17:04 +00:00
Piotr Miazga 0ab39f88e7 Enable by default
Popups is enabled on the Wikipedias but disabled by default, which makes
it more difficult to enable on third-party wikis.

Things should be enabled by default, and them WMF configs should disable
features when they are not used/available.

Supporting changes:

- Rename PopupsContextTest#testAnonUserHasDisabledPagePreviews and
  remove the associated data provider, which provided only one datum

- Set $wgPopupsReferencePreviews to false in
  PopupsContextTest#testShouldSendModuleToUser in order to isolate the
  code under test

Change-Id: Ib8cc7041d792bed0a19d18e14506627099a69bef
2020-01-29 15:40:23 +00:00
Umherirrender 9fa7f2071c build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
Change-Id: Ifb739130872b192b0fee54351555b65c3099981e
2020-01-26 20:22:03 +01:00
WMDE-Fisch 4f263bebfc Don't use double dash in refrence preview tests
The default way to build these ids is without a double dash afaik.

Change-Id: I068d97de517f9da09c203d543cf6eb51cf306465
2020-01-23 18:41:50 +01:00
jenkins-bot 5d925e3479 Merge "Add tests case for user preferences while in Beta mode" 2019-12-18 07:57:40 +00:00
Thiemo Kreuz 776f4af6c5 Add tests case for user preferences while in Beta mode
This is a direct follow up for I4d31805. Note the previous patch was
only testing the code path when Beta is disabled. But the bug was about
what happens when Beta is enabled. This is now properly covered by
these tests.

Bug: T240947
Change-Id: I54c5e9751e14a94808e85d935e1972eea0395002
2019-12-17 16:27:26 +01:00
Thiemo Kreuz fc6a72094d Turn some tests into faster running "pure" unit tests
On my local machine, this reduced the runtime for all PHPUnit tests
combined from 900ms to 800ms.

Change-Id: Iec4f0396115fd270ba1a1f6668e1672cea5f7aff
2019-12-17 16:20:27 +01:00
Thiemo Kreuz 5752c2538e Fix initial preferences for newly created user accounts
It appears like we accidentially copy-pasted the behavior for
PagePreviews and made ReferencePreviews behave the same, not taking
into account that the later feature is in Beta mode.

Bug: T240947
Change-Id: I4d31805ee9b2045c49c7ab4179c5a4adbcba0394
2019-12-17 13:37:11 +00:00
jdlrobson 01fc2db19f Use 6.1.0 of @wikimedia/mw-node-qunit
Bug: T203137
Change-Id: I9fd701cc9575ad250c919d88bf1fe74898b690eb
2019-10-22 10:42:49 -07:00
Thiemo Kreuz 76e02fae98 Remove obsolete mediaWiki and jQuery aliases
Notice how this actually reduces the size of the final, compiled index.js.
It's not much, but still.

One issue I noticed is that the coverage reports for the JS code stopped
working. I have no idea why.

Bug: T208951
Change-Id: I2fe92579574b3b1ba4d2dd064899eee944045a96
2019-10-22 09:30:46 +02:00
Thiemo Kreuz 71ac670d9e Add visibility keywords to all constants in PHP code
Change-Id: I384cffed670c7e845465e3e18808e267327011ed
2019-10-22 07:10:31 +00:00
Thiemo Kreuz c7595e54f6 Replace deprecated mw.RegExp.escape() with mw.util.escapeRegExp()
The signature mw.RegExp.escape() is deprecated since MediaWiki 1.34.

By the way, this is the 4th or even 5th time in my short career this
tiny, single line (!) helper function is moved around and I need to
update all my code. This felt already ridiculous when it happened the
2nd time.

Change-Id: I4d05a49120aff64ebc316d0af7736c62385d9307
2019-10-21 15:00:36 -07:00
jenkins-bot 4476eb7f75 Merge "Upgrade Popups mw-node-qunit version" 2019-10-21 11:07:57 +00:00
Thiemo Kreuz fe32c48268 Replace all mock builders with createMock() calls
This was motivated by two things:

1. Notice the bad class name in UserPreferencesChangeHandlerTest. This
was possible because the default mock builder does not check if a class
exists, *and* there was no type hint in place. createMock() *does* check
if a class exists.

2. We are free to use createMock() from PHPUnit 5+ now. It's not only
shorter but more strict and reliable.

Change-Id: I301a171d587026eab0a62575ab2fdbfd7733c661
2019-10-18 14:31:10 +00:00
Thiemo Kreuz a63a1cf91c Split user preferences for Page and Reference previews
Bug: T233813
Change-Id: I89205658c561961b90abaa133a004e54beebfab5
2019-10-17 11:21:21 +02:00
James D. Forrester e16143df16 build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: Icd67aed448269f603dd4465f7e46eac9a64bd1a1
2019-10-15 16:13:01 -07:00
jdlrobson 7d6a903d69 Upgrade Popups mw-node-qunit version
Bug: T203137
Change-Id: I0cf856d04eacf5bf7764c58db55eeae04811e973
2019-10-15 15:36:54 -07:00
Adam Wight 76a34618c3 Tracking for Reference Previews interactions
Logs events to the ReferencePreviewsPopups EventLogging schema, in
order to understand whether Reference Previews is helpful for
end-users.

This will be removed along with the older tracking, as soon as our analysis
phase is finished.

Incidentally disables a lint rule for the generated JS, it's about
readability so irrelevant to the minified code.

Bug: T214493
Change-Id: I2638611ba67b785338f7e98a1c4b08a5e829812d
2019-10-07 11:22:00 +02:00
Max Semenik b72a95b5c0 Fixes for PHPUnit 6
Bug: T192167
Change-Id: I354077e8e44cfea3e75219d6701a4f9e11d4c70a
2019-10-05 22:43:20 -07:00
Thiemo Kreuz 3eb7c9b976 Replace all loose assertEquals with strict PHPUnit assertions
A method that is expected to return, for example, a boolean true
should not return an other value that PHPs loose == comparison might
also consider true.

Same for all other loose equality checks.

Change-Id: If729c6e97d5337eee10b717da76dad428218ff69
2019-10-04 10:34:21 +02:00
Adam Wight aa6972c277 Collect metrics for logged-in users as well as anons
The eventlogging `isEnabled` function determines when to sample,
this patch removes the `isAnon` conditional so that we can measure
reference reading habits for all users.

Also guards against a non-function navigator.sendBeacon, which was
previously intended but incorrectly tested.

Bug: T214493
Change-Id: I42cb3082fb85c7900426a2055dfa3c2f6ecfd968
2019-09-27 12:07:11 +02:00
Ed Sanders 9b3029e0ee Build: Update linters
Change-Id: Ia2a833a01e1bb05d6be3923dd452b1851afd7655
2019-09-17 12:47:25 +01:00
WMDE-Fisch 69caa6ec3d Add browser tests for quickly hovering links
Bug: T219434
Change-Id: I3597b8025f7a12db0cf5d83cce5a77abace9bae3
2019-08-23 08:21:14 +00:00
Thiemo Kreuz 065a8e9631 Fix action reducer forgetting *all* duplicate dwell actions
I was able to track the issue down to the changes made in this patch:
https://gerrit.wikimedia.org/r/331563

This patch is mostly a simplification of ce8a2d4
(I9a73b3086fc8fb0edd897a347b5497d5362e20ef):

- Don't make wait#wait() abortable. This adds complexity and isn't
  needed since the token is rechecked in the .then() of
  actions#linkDwell(). The request is permitted to continue and fetch if
  that token still matches and is never issued otherwise.

  Once a request has been issued, that request is still abortable.
  However, note that calling XHR.abort() is just a request to abort and
  may not be granted. Whether or not XHR.catch() is invoked is what
  dispatches the FETCH_ABORTED action (or doesn't if the request to
  abort was denied).

- Remove the abort tests for wait#wait() since the functionality is no
  longer provided.

- Pass the preview token in the FETCH_ABORTED action and reduce
  FETCH_ABORTED the same way as ABANDON_COMPLETE in reducers/preview.

The follow-up patch, I3597b8025f7a12db0cf5d83cce5a77abace9bae3, adds
integration tests for the specific bug fix. Note that these Selenium
tests are incompatible with the content proxy, so it is probably best to
simply unset $wgPopupsRestGatewayEndpoint and $wgPopupsGateway and allow
the defaults to be used. Also note that the tests are incompatible with
recent versions of Node.js (so use NVM) and emit many deprecation
warnings (so set deprecationWarnings to false in
tests/selenium/wdio.conf.js) An example run of the tests looks something
like:

  chromedriver --url-base=wd/hub --port=4444 &
  # If any changes are made locally, also run `npm -s start &`.
  MW_SERVER=http://localhost:8181 \
  MEDIAWIKI_USER=foo \
  MEDIAWIKI_PASSWORD=bar \
  DISPLAY= \
  npm -s run selenium-test

Live testing may be performed as well. Remember that RESTBase requests
are incompatible with MobileFrontend's content proxy hack so ensure to
comment it out if $wgPopupsGateway is configured for RESTBase (see
T218159).

1. Open the DevTools network tab.
2. Disable the browser cache. Chromium, at least, won't abort requests
   coming form the cache.
3. Hover back and forth quickly over a preview. In Chromium, canceled
   requests are labeled and appear red. This is a good scenario to test.
   With the patch, a preview should always be shown when ultimately
   resting on a link. Without the patch, it is possible to rest upon the
   link with no preview showing. This may require several attempts.

Bug: T219434
Change-Id: I9da84b0296dd14e9ce69cb35f1ca475272fb249a
2019-08-23 10:08:19 +02:00
Ed Sanders 4d885286a3 eslint: Enforce template-curly-spacing
Change-Id: I5640e86cba25f6100c7814c2ef8a845941f73497
2019-08-15 10:24:43 +02:00
Ed Sanders 2687d12c52 eslint: Remove valid-jsdoc override
Change-Id: I6a9936743a74afb528713f21e016838947fa1914
2019-08-15 08:00:24 +00:00
Ed Sanders a17be78b3d build: Update linters
Change-Id: I9b32f412e7e75918a59bdb239d3a42670177be70
2019-08-15 09:55:57 +02:00
Dan Andreescu 27a95517b7 Remove dependencies on deprecated schema modules
As mentioned in T205744, EventLogging schema ResourceLoader modules have
been deprecated.  This removes those modules from loader calls.

Bug: T221281
Change-Id: I1b7355c69e09756f50ccd1c1955b45cae4a64b9e
2019-06-19 09:51:30 -06:00
Adam Wight ed06a6dbb1 Docs: Remove incorrect documentation about LocalSettings in tests README
Follows-up 1cff4a15a7.

There is no such file to copy, delete from README.

Change-Id: I1fa0ac574743f5dbd577653aa74d416ca4609aa8
2019-05-13 11:52:55 +00:00
WMDE-Fisch a498423f90 Avoid popups on self links with file extension
This fixes page previews appearing when there is self link to a page
that has a file extension in it's name.

Bug: T222869
Change-Id: I5caf610fa76986026948a5b7b55537723752b755
2019-05-10 18:02:50 +02:00
WMDE-Fisch 1879a4d59e Show referencePreviews on click
Introducing the REFERENCE_CLICK action that will fetch and show the
preview for the clicked reference right away without any delay.

The main goal of the new chain of events introduced with the reference
click is showing the reference preview right away. The actions triggered
by the dwelling include delays in multiple parts of the process.

If there's a dwell action-chain in progress when the click action is
executed, the related promise ( that might still include steps with
delays ) and the reference preview is retrieved and shown right away
re-using the token. 

In the case where there's no dwell action running ( e.g. when the click
was triggered via touch ) we create a new token and start from scratch.

In either case we want to avoid, that multiple clicks trigger multiple
actions and abort early when there's already a click action in progress.

Bug: T218765
Change-Id: I073a93be2d17a21178aebe12267765f60a2811b9
2019-04-29 17:46:49 +00:00
Thiemo Kreuz 8305eb8634 Minimize createStubTitle() helper method
Pretty much all usages of this function do *not* use the second
parameter to pass a page name prefixed with a namespace, but pass the
page name only.

This patch here removes the redundancy. The namespace prefix is now a
generated one, saying "Namespace <number>:…". It turns out no test
relies on this so far.

Bug: T220097
Change-Id: Ibd45d49c91e86a2647afe676a5e3bb07dfeab6ed
2019-04-26 07:45:13 -06:00
WMDE-Fisch 6c535739bf Use title.getNameText() to compare selflinks
config.get( 'wgTitle' ) returns the unnormalized title of the current
page while title.getName() gets the normalized title (e.g. with underscores ).

On pages with spaces in the check failed before this patch.

Bug: T220097
Change-Id: I58a532627bb27be030cbc553f1181a89109edd80
2019-04-26 13:58:08 +02:00
WMDE-Fisch 35aa05afee Use title and namespace id to check if link is current page
Bug: T220097
Change-Id: Ieffd6a02b4126f6713610e968d662516499d4998
2019-04-23 15:17:06 +02:00
Adam Wight 0acc8db529 Decode fragment, needed for multilingual named references
Named references may include non-ascii characters, so we decode the fragment before matching against reference IDs.

Bug: T220196
Change-Id: I63bba59fa8f0f6aa95aeadbb1f85745d480988bd
2019-04-23 11:39:30 +02:00
Timo Tijhof 81b94eff0a Remove redundant wgPopupsShouldSendModuleToUser variable
It is set based on the same conditional that loads the code,
thus checking it inside the loaded code is a no-op and adds
extra HTML to the <head> that blocks text/layout rendering and
delays fetching of Popups JS.

Bug: T219342
Change-Id: I9c1f4b3861ce2cecb654eb0a78469a616730a40b
2019-04-09 18:31:35 +00:00
WMDE-Fisch 5a38638388 Fix module load script and remove pause
I just realized on another test set, that this is actually not implemented
in a way where it is working correctly. The return value of the browser.exectue()
is returned as part of an object and not directly. So the condition was always
true and the wait until did not really wait for anything.

As a result I'm quite confident the pause is not necessary.

Change-Id: I274bdee0b3c39c418a2b61881d56f89889c53485
2019-04-08 21:17:53 +02:00
WMDE-Fisch 79ee43fbeb Avoid exception when checking for loaded modules
The test would lead to an exception when 'mediaWiki' is not defined. The
exception would then also abort the whole execution so in this context it's
safer to use typeof with 'undefined'.

When the mediaWiki js base is loaded though, loader.getState() is guaranteed
to be available since it is part of the root module.

This also uses "mw" instead of "mediaWiki" for consistency in test.

Change-Id: I1262d0b5c4a1136f4d2294f125336e72118c6e2c
2019-04-08 19:51:11 +02:00