Commit graph

714 commits

Author SHA1 Message Date
Jon Robson 9aa07d0809 Model: Make dwell delay part of model and registration
Dwell delay varies between popup type so should be part of the
definition. Since this is needed by reference tooltips we should
make this part of the Page preview model. This will allow us to
separate concerns of the architecture and reference  tooltips
for better maintenance between WMDE and web team.

Bug: T326692
Change-Id: Ia021c8b90fd69d70c4b33744520bb963a65db036
2023-07-26 17:42:56 -07:00
WMDE-Fisch c2413c858b selenium: Refactor WebdriverIO tests from sync to async mode
I also removed the bool on the shouldUseReferencePopupsBetaFeature
method. It was always just used with `true`

Bug: T293072
Change-Id: I1a2d6f912fcac2ac77539581897e0feab489edf0
2023-07-18 09:34:47 +02:00
Jon Robson 36101004e7 Browser tests: Skip another test
Bug: T341763
Change-Id: I37d8c62c1e10160bc27ed9135fd3765cccf77be5
2023-07-14 09:57:28 -07:00
Jon Robson 3d627fe731 Skip flakey Selenium test for now
This test is failing regularly on the daily build. I manually
checked and could see no problems with the functionality:
https://integration.wikimedia.org/ci/job/selenium-daily-beta-Popups/

Bug: T341763
Change-Id: Id3a3a1c16c400796467496d8934fdff7a14be9fb
2023-07-13 15:15:34 +00:00
bwang 6b659443b5 Update popups to use codex buttons over mediawiki.ui.buttons
- Provides missing accessible label for the settings button

Bug: T340256
Change-Id: I86972322ae34f1d1df8d79c66daa9e34091f9dd3
2023-07-10 16:03:36 -05:00
Moh'd Khier Abualruz 67a718a5be TypeError: n.closest is not a function
- check if the element has the function in it before using it
- implementing a native code to get the same result based on polyfill examples
- fix Coverage Block

Bug: T340081
Change-Id: I1c2ce46a88cde6323ab862964062dd722ff5edcb
2023-07-10 11:48:40 -07:00
WMDE-Fisch 606475f80e selenium: run tests concurrently
Includes a bit untangling of the reference and page previews tests
and simplifies the setup.

Bug: T337862
Change-Id: Ia92cccb90fd79d10c5b33744520cb963a65db046
2023-06-30 08:52:47 +02:00
Jon Robson 049729626c IP masked users use localStorage for settings
Bug: T330517
Change-Id: Ib283e37f379e8cccc7f49ab0ce9aadd6535ea668
2023-06-14 08:16:50 -07:00
Jon Robson 580067b94e Discourage jQuery usage in Popups extension
Change-Id: Iff0c81e4c1d78cc52d1bd9d81e24d8fae228c9bc
2023-06-13 15:39:57 -07:00
jenkins-bot a38f4c5336 Merge "Prefer native JavaScript to jQuery" 2023-05-26 03:22:52 +00:00
Jon Robson 7c592bc790 Prefer native JavaScript to jQuery
Bug: T315929
Change-Id: I949fd9551269a3cb9d9df7744149510949d3076c
2023-05-21 16:53:50 +00:00
Umherirrender 9da6586158 tests: Make PHPUnit data providers static
Initally used a new sniff with autofix (T333745)

Bug: T332865
Change-Id: I1a585a5e81ad0355b3be806da249e632f3fd21ec
2023-05-20 13:56:14 +02:00
Jon Robson 323d770d66 Use native JavaScript to build thumbnail clip path
Change-Id: Ib5d734fde88eaa20ec866722af3de37abe694add
2023-05-16 17:19:47 -07:00
Jon Robson 1ee66bbf72 Don't use parseHTML in parseHTMLResponse
These changes impact the preview itself and the settings
dialog which shows to anonymous users

Change-Id: If288161fb5eb4446a79e68841ab53a6c713f1d3a
2023-05-16 17:18:06 -07:00
Jon Robson 3bd4275023 Fix test case with type with space in it
Types should not have spaces in them. In the current example this
results in a page preview element with an additional class "<"\'>"
I'm not sure what this is protecting against since we can trust types
to always be in a sensible class friendly form. It would be better
to throw an error in the mw.popups.register function than allow this.

Change-Id: If08c5162c1ca0fc3db4944092231061e22113263
2023-05-15 14:18:39 -07:00
Jon Robson 7ff66a50b0 Fixes flakey test: it should resolve after waiting
Change-Id: I6d63fa2d316af296401eaa3dabee10375e73108b
2023-05-09 10:43:56 -07:00
Jon Robson f9b9feaff5 ES6: Prefer Object.assign and Promise to jQuery
Additional change:
* Lint dist folder as ES6 code now ES6 is everywhere

Change-Id: Ie77046f5c6fbdafa4679dbaf97f7bf6f16292b9c
2023-04-19 17:02:14 -07:00
Umherirrender 3573232c21 build: Updating npm dependencies
* eslint-config-wikimedia: 0.22.1 → 0.24.0
* @wikimedia/mw-node-qunit: 6.3.3 → 7.0.0

Change-Id: I348eb70bfc6c1d6c922c8290152926183712dee1
2023-04-03 23:14:47 +02:00
Jon Robson 119483bdd8 Expand tests to include hash fragment behaviour
Bug: T198652
Change-Id: Ic43883d7092499386df35e6fe049863cbffbe635
2023-01-30 19:25:22 +00:00
Jon Robson fb0ac8e270 Tests: correction to unit test
Follow up to
Iefe98c1f0422dbf034e385b1a41a859d030a2cf4

Change-Id: Ib3beda14aa3e94def5833082148b7395bc378d74
2023-01-23 10:22:07 -08:00
Fomafix 76e2339cec Inject service UserOptionsManager in Hooks
Change-Id: I690699210c041f950a076904b863bc014833e5ad
2022-12-15 22:13:23 +00:00
jenkins-bot 94c251583e Merge "Extensible previews" 2022-12-02 17:02:04 +00:00
Jon Robson 0febc3f54d Extensible previews
Allow extensions to register new types of previews via
extension attributes.

Changes:

- The check for reference previews doesn't make sense
as $('a[ href*="#" ]' ) will match any elements with a hash
fragment, so the additional check to Title.getFragment
will not provide a different result. This was introduced in
I9ec57e0fbb0d21beaaa7b359c1c2bef64d2c14f5
- Links that point to themselves are marked with mw-selflink
in MediaWiki so this can use the not selector we already have.
- The new API is used internally and only available via extension
Attributes
- An example is provided in SkinJSON
(https://github.com/jdlrobson/mediawiki-skins-skinjson/pull/14)

Bug: T233099
Change-Id: Iefe98c1f0422dbf034e385b1a41a859d030a2cf4
2022-11-22 08:45:27 -08:00
Fomafix c58f9234fc Use $this->getServiceContainer() in test cases
Change-Id: Ic03f4d692720cd9810c44700f7bf27d1cf07d26d
2022-11-05 09:50:56 +00:00
Fomafix 56d8a8df55 Inject service SpecialPageFactory
Change-Id: Ia38b468741bdfd5bab5bb34df79bf01d549498a9
2022-11-05 09:28:08 +00:00
Thiemo Kreuz dd3bff0d2a Use PHPUnit's convenience shortcuts where possible
Change-Id: I5cc75a66f5971de409a9debdd4f4ebfb8ee94b22
2022-09-29 14:41:35 +02:00
Jon Robson c2b840a561 Fixes Selenium Popups tests
As part of T310054, we moved article tabs into
the #content area on the beta cluster which caused
the daily tests to fail. As a result the page previews
test is currently expecting a page preview to show
on hovering "Article" which is not the case.

Update selector to target links in the parser
content

Bug: T310313
Change-Id: I0bbccbbfbae458d5c32eaea12f855b832b52491c
2022-06-15 10:09:21 -07:00
Reedy 3ac384e5a5 PopupsGadgetsIntegrationTest: Use namespaced Gadget class
Change-Id: Iad6488408fdd29af45dab46e1c81944d181f711d
2022-03-29 20:37:32 +01:00
Reedy b6eb2627ff Use namespaced GadgetRepo
Change-Id: Ibaa24dc0bf02b0d1cbe4e66a8a4efc47896d0fb9
2022-03-06 01:33:08 +00:00
Ed Sanders 883c8c1aca build: Update eslint-config-wikimedia to 0.22.1
Change-Id: I055517998ed06fccdf50ec31251ea6aa9040abb5
2022-02-28 13:18:24 +00:00
Fomafix cfa0f5419b Use HookHandlers and implement hook interfaces
This change requires MediaWiki 1.35+.

Bug: T263353
Change-Id: I4d3aa20c666799e6e693a6a4b7a3e835303e2fc5
2021-12-20 11:05:19 +00:00
Alexander Vorwerk 131186d8b8 MediaWikiTestCase -> MediaWikiIntegrationTestCase
MediaWikiTestCase has been renamed to MediaWikiIntegrationTestCase in 1.34.

Bug: T293043
Change-Id: I1cb26373fb173c5abf7c3838185b68016e4ade05
2021-10-12 01:00:04 +02:00
jdlrobson fa19ee0d4f Adjust previews to meet specifications
Apply max-heights and tweak some of the margin values

Bug: T284643
Change-Id: I0c8a77e10c36ae444e541bb52a8797594c77db63
2021-08-25 22:55:26 +00:00
jdlrobson 75a9d81755 Fix pointer class behaviour
Add unit tests for landscape previews.

Bug: T287520
Change-Id: Ib9a7635b532248a4f44c308d7bb5dc7ab08667e6
2021-08-10 10:40:40 -07:00
Thiemo Kreuz a01c31efd7 Show medium size (<320 wide, but >=250 high) images as well
The requirement for landscape images is to be at least 320px
wide. The requirement for portrait images is more relaxed,
only 250px high. Images that fall between these two
requirements currently don't show a thumbnail, even if they
could.

This change affects a very specific group of images:
* Square images from 250 x 250 to 319 x 319.
* Landscape images from 251 x 250 to 319 x 250.
* Landscape images from 319 x 250 to 319 x 318.

The most extreme ratio is 319 x 250. This will be cut to
203 x 250. I.e. the absolute extreme are 58px missing left
and right, but never more.

Requested at https://www.mediawiki.org/wiki/Topic:Vwl97pm6as9fuf6k

Additional stories for testing more extreme small images:
* Small Tall - 300x1000px
* Small Short - 300x200px

Update tests accordingly.

Bug: T268999
Change-Id: I811f1c0e7e9b0c30280b36a61cc7831a5b9e58c8
2021-08-03 13:17:06 -06:00
Sam Smith 8f5000f346 Remove Popups instrumentation
Bug: T267211
Change-Id: I640ab367cd235ab8da7dd70dbef7ae9076712e84
2021-07-29 17:01:01 +00:00
sahil 1e1b8506ac 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
Change-Id: I76edb3f16272fc6c1d70b0a796115cf5cc22d255
2021-07-28 16:35:31 +05:30
Alexander Vorwerk 35462639c3 Avoid using User::getBoolOption()
User::getBoolOption() is deprecated and should be replaced with
UserOptionsLookup::getBoolOption()

Bug: T277600
Change-Id: I9a2118a6342bd5f145174428dcfb518cba4e439b
2021-06-06 16:44:20 +02:00
jenkins-bot 26ae1842c1 Merge "Avoid using User::setOption()" 2021-06-03 20:04:41 +00:00
anjali041 81bb920e2b Avoid using User::setOption()
User::setOption() is deprecated and should be replaced with UserOptionsManager::setOption()

Bug: T277818
Change-Id: I5698b4422755a921c9c9c01ce29084ebfe5f5385
2021-06-02 12:21:10 +00:00
sahil 9a22c9a028 selenium: Update README.md file
Bug: T282237
Change-Id: I16d7f7744f01be15e32a2729e9f516dbb508e41e
2021-05-24 18:04:51 +00:00
Thiemo Kreuz 5d2c5aeaa1 Remove a small piece of unused code from reference.js
Turns out this was only in place because the test was
(intentionally) incomplete. But it's dead code in
production. Let's get rid of it.

Change-Id: Ieeb145b6972dceb7eeda3a167d907b680d5c3ce4
2021-05-07 16:43:01 +02:00
Thiemo Kreuz 6b728243d6 Add missing test cases for the settings reducer
As well as make some more test code more readable without
changing what the test does.

Bug: T281698
Change-Id: Ia153981d9196b47099ef3880ac334718895fb0fc
2021-05-07 11:21:37 +00:00
jenkins-bot 5b641130f6 Merge "More unit test cases for isReferencePreviewsEnabled" 2021-05-07 09:19:44 +00:00
Thiemo Kreuz c5e9a68ab8 Set both Beta/non-Beta user option in Selenium tests
I was not able to reproduce the issue locally, but I believe
this might be the reason for the failure we see. It can't hurt
and needs to change anyway, with or without the failure.

Bug: T281324
Change-Id: I0002f952438d7afe2fb6c2100bf25760f7dda10d
2021-05-04 10:45:32 +02:00
James D. Forrester 14c2102476 build: Upgrade eslint-config-wikimedia from 0.17.0 to 0.20.0
Some inline compatibility queries for the maintainers, where it
wasn't obviously intentional.

Change-Id: Idd659a0a0f7fb86c3f6870b8fe4608bbf8a45f05
2021-05-03 12:31:52 -07:00
Thiemo Kreuz 30863cfae5 More unit test cases for isReferencePreviewsEnabled
Not all relevant combinations of flags are currently covered
by tests.

Change-Id: I6276d591185d08a46ffa69b710e1d28c01536b76
2021-05-03 18:57:43 +02:00
Marcel Ruiz Forns a6a06f70bf Move VirtualPageViews back to mw.track
Use mw.track instead of dedicated tracker for VirtualPageViews.
This way we can migrate it to the new Event Platform client.
The new client does not observe DNT, which was the reason this
instrument was moved to a dedicated tracker on the first place.

Bug: T279382
Change-Id: I8bb515eab337ffed686ba7522bc6153cfdd8ca8d
2021-04-29 16:15:16 +02:00
Željko Filipin 0f15690b07 selenium: fix JUnit reporter
JUnit reporter configuration changed since WebdriverIO v6. Before this
patch, the reporter was outputing to terminal, instead of outputing to
file.

Bug: T214686
Change-Id: Ib315b0261b3724cded17c85519ac28842d7ab071
2021-04-27 19:50:10 +02:00
Thiemo Kreuz 3a00223a36 Separate reference preview settings in beta & non-beta
This is the smallest possible patch for a backport.

While it seems there is zero technical reason to limit user
option keys to lowercase with dashes, it's best-practice.
Same as message keys.

Bug: T281235
Change-Id: Ia4a45cf4459543c81b23b757ae9c2cfaf9676894
2021-04-27 16:15:17 +02:00
jenkins-bot 5594191b6b Merge "Clean up popup type settings related code" 2021-04-23 13:46:15 +00:00
jenkins-bot a5786d63e5 Merge "Add tests for rewritten SETTINGS_CHANGE action reducer" 2021-04-23 13:43:24 +00:00
Thiemo Kreuz d0872e3025 Clean up popup type settings related code
* Change more places to not hard-code the popup types, but use
  loops and such.
* Change many `function ()` headers to use the more streamlined
  ES6 sytnax.

Bug: T277639
Bug: T277640
Change-Id: Ifece87d51012e0e069286453b27f5c9ae273710e
2021-04-23 15:38:38 +02:00
Thiemo Kreuz a2c8417d74 Add test case for syncUserSettings with reference previews
Code was introduced in I13acfb8, but not individually tested
so far.

Bug: T277639
Change-Id: Ica4527d3514246069cce7f5848c22764c6306531
2021-04-23 13:05:09 +02:00
Thiemo Kreuz 7f938bb077 Add tests for rewritten SETTINGS_CHANGE action reducer
The new code that is tested here was introduced in I860a1b3.

Bug: T277639
Change-Id: I128e69f8ca0415ff78d68a2fea2c9622c90029e0
2021-04-23 11:03:28 +00:00
Svantje Lilienthal 09c2c52945 Added popup types handling
We added reference preview as a checkbox the the
anonymous user settings. To handle both popup types
(pages and references), we changed the usage of
preview.enabled. We pass on all types as a map
inside preview.enabled. The footer link to edit the
settings will appear for anonymous users if at least
one type is disabled.

Bug: T277639
Change-Id: I860a1b35ac7749d8d0884575f6acb7186ad8e4d0
2021-04-23 12:14:23 +02:00
Thiemo Kreuz c281bb9302 Clean up code enabling individual popup types
We still have 2 different mechanisms in place, maybe even 3:
* We simplify the CSS selector when we know a popup type is
  disabled, and it's impossible an anonymous user can enable it
  at run-time.
* We create that "initiallyEnabled" map that allows anonymous
  users to toggle the individual popup types at run-time.
* This map is also used to check if the footer link should be
  shown.
* There is also a wgPopupsReferencePreviews global that acts as
  a "kill switch". However, this is not a pure feature flag,
  but incorporates the user setting for registered users. This
  is currently partly redundant (checking
  `mw.user.options.get( 'popupsreferencepreviews' )` does the
  same) and can be removed later when the feature flag is not
  needed any more.

The footer link currently acts odd because anonymous users are
unable to enable ReferencePreviews, but get the footer link.

This patch introduces a 3-state model:
* `true` acts as before.
* `false` means a popup type is disabled, but anonymous users
  can enable it (i.e. this is the opt-out behavior for anonymous
  users).
* `null` means a popup type is not available at run-time, for
  nobody. Anonymous users can't do anything about this.
  Registered users must leave the page and change a setting.

Bug: T277640
Change-Id: Id8d1396c09cf0f706034a66f9cd3c880a8b33df8
2021-04-21 19:38:25 +02:00
Svantje Lilienthal cf9258b0c5 Changed radio button to checkbox in anonymous user settings window
Bug: T277639
Change-Id: Ifa84dda88a8a167fc8ed2cef17254c1b722ade2d
2021-04-21 14:13:47 +02:00
Thiemo Kreuz e19b557227 Merge duplicate ReferencePreviews Beta feature flag
Change-Id: Ia7f1c9128460bc5a139e37eb16fff649e80cd20f
2021-04-21 10:46:05 +02:00
Thiemo Kreuz 3466e66995 Minor cleanups to QUnit test setups
* That `this.user` is unused.
* Some tests missed a module name. This means they are reported
  as part of the previous module. While this is purely cosmetic,
  it's confusing to see the wrong module name in the report.

Change-Id: I73915d3c4fd9a03bda1ddc8dff6dd5539113c3cd
2021-04-16 13:23:10 +02:00
Thiemo Kreuz 622fb6c5e8 Allow to disable/enable popup types individually
Bug: T277639
Change-Id: I0742b8ab1c5ed0b374d4f9447bebc46a35207339
2021-04-15 11:30:36 +02:00
Thiemo Kreuz 4b1f020b9d Avoid hard to read jQuery.extend() in tests
… as well as in one place in production code. The motivation
for this change is to make the code easier and faster to read.
There is a little bit of duplication in the test setup now.
But I would like to argue this is a good thing. The values are
rather trivial. The difference (or absense of a difference) is
much easier to see now.

Change-Id: I9aa95b59f0c45ea7c9257970e2fcdba3a000d234
2021-04-15 10:47:44 +02:00
Thiemo Kreuz b28f48d6d6 Rename variables in change listeners for clarity
This patch does nothing but rename a pair of variables:
"prevState/state" becomes "oldState/newState". Reasoning:

1. The abbreviated "prev" is confusing, especially because we
are in a codebase that is all about "previews".

2. We are in a context that is all about a state **change**.
Change listeners get notified about the change from one state
to another. While it would be possible to stick to the already
mentioned "previous/current" terminology, I find the word
"current" confusing. What is "current" in this context? Did
the state already change? Am I notified about a change that is
**going** to happen or already happened? Is this even relevant?
I don't think it is. Therefor "old/new".

Another possibility is "previous/next".

Change-Id: Id886e1a095967fe86fb9021f59e335c62da8994e
2021-04-15 10:19:40 +02:00
Thiemo Kreuz a35e35e3b3 Expand userSettings module for reference previews
Bug: T277639
Change-Id: I13acfb8bcc6e95fc28969072ec5420fd075d5096
2021-04-13 12:19:49 +02:00
Thiemo Kreuz 51dd4b2807 Make nextState support non-flat updates
The nextState() function was not able to understand updates that
are deeper than a single level. Example:

nextState( state, { pagePreviews: { enabled: true } } )

Before, this would replace whatever was in the "pagePreviews"
property with { enabled: true }, but not merge it. In some places
a single level of recursion was done manually because of this.
This can be removed now.

This is done in preparation for splitting the "enabled" flag into
separate ones for each popup type.

Bug: T277639
Change-Id: I35911c18018ba7cd1633a4c882b978656c3fee36
2021-04-12 13:46:18 +02:00
Thiemo Kreuz ddf574afa3 Remove not needed userSettings.hasIsEnabled()
Note how getIsEnabled() is documented: "if the user hasn't
previously enabled or disabled Page Previews […] then they
are treated as if they have enabled them."

In other words: The idea that the default should be true is
encoded twice in this code. This is just not necessary. We can
remove one without loosing anything.

Motivtion: Simplifying the code and reducing the package size.

Since the code fundamentally depends on this default value
anyway, we can clear the users localStorage when they decide
to go back to the default – instead of storing a "1" which
does the same as the default.

Change-Id: I2814a1e9269979918609162a508eeee6944d9e52
2021-04-08 11:57:52 +02:00
Thiemo Kreuz c5accc0300 Rename many functions and files for clarity
The main motivation here is to dramatically reduce the number
of places that use the same property name "enabled" for values
on different objects (e.g. "state", "actions", and "updates"
are all different things) with slightly different meanings. I
tried hard to come up with names that reflect better what each
meaning is.

Bug: T277639
Change-Id: Ie766259793f716262e3d4622ca55156d11f4842c
2021-04-08 11:04:02 +02:00
Clare Ming 4908f82c01 Add title attribute to settings gear icon
Add message, description, extension for title. Update createPagePreview, renderPagePreview methods to add title attribute to settings gear icon. Add test for title attribute. Increase maxSize, maxAssetSize, maxEntrypointSize. Add compiled js files.

Bug: T274887
Change-Id: Ibb29deb3418569d8283b954b4b22074423e78bda
2021-04-02 13:30:07 -06:00
Andrew Kostka e4e07e509a Separate page and reference preview preferences
Bug: T277638
Change-Id: I8144625e0d3a2626511f35d4e92d082b6fa44bb4
2021-03-29 14:09:27 +02:00
WMDE-Fisch 97538eb9e1 Add tests for bitmask code
Bug: T276716
Change-Id: I7c21e909f121217e43bf5072061bda422f390693
2021-03-11 14:05:21 +01:00
WMDE-Fisch 58f820009e Use flags to represent settings
To reduce size of code added to the <head> and increase performance.
The increased bundlesize is still less than the size spared bytes in
ResourceLoaderGetConfigVars. - But nevertheless the main gain is loading
less in the <head> anyways.

To avoid further complexity in the code, the bitmask is converted to
the according config setting early on instead of adding checks on the
bitmask all over the place.

Tests will be added in follow ups.

Bug: T276716
Change-Id: Ib4f82bed58295b25f0a41cb37e36244e45f16317
2021-03-11 13:38:06 +01:00
jenkins-bot e441052cb0 Merge "Combine page and reference preview preferences" 2021-03-01 11:10:17 +00:00
Umherirrender eaaf560d99 build: Updating mediawiki/mediawiki-codesniffer to 35.0.0
Change-Id: Ib411b8fbec93f469e4f4812f60f8349207744ecd
2021-02-26 23:42:29 +01:00
Andrew Kostka 82d54945e4 Combine page and reference preview preferences
Update copy and remove unnecessary reference preview preference
in favor of using the default preference. It seems there is no
stable method to link to the subsections on the preference page
for gadgets. So in all cases does the link just point to the
gadgets pref page.

These changes should only be visible when reference previews
are no longer marked as a beta feature.

Bug: T265709
Change-Id: I7b8ab91331092ada04b230315373548673b9272c
2021-02-25 10:21:16 +00:00
Thiemo Kreuz 513899d808 Much more relaxed reference type detection
* When there are multiple <cite> elements, the first that contains a
  known class is used. We assume the earlier one must be the relevant
  one.
* When there are multiple known classes in e.g. <cite class="web news">,
  the last one is used. This follows how CSS works.
* There is extra validation if the corresponding message exists, just
  to be sure. This is cheap.

Bug: T274979
Change-Id: Iee3481ea16af96b40faf978e254718e5a48917f3
2021-02-22 11:55:03 +01:00
Svantje Lilienthal 1962372a44 Add cogwheel to disable ReferencePreviews
I added the common styling for the setting icon to the popup.less
and removed the now empty pagePreview.less.

Bug: T234205
Change-Id: I2a82831bc71a4208c4b66c18e2a4613127c43e1f
2021-02-16 15:39:43 +01:00
Thiemo Kreuz 8fbcf6f962 Add missing TextExtracts parameter sectionformat=plain
It turns out the TextExtracts extension is build in a way so
that the parameter plaintext=1 alone is not enough. It does
not really mean "please return plain text" but "please don't
return HTML". It can still return one of three formats:
* Wikitext.
* An intermediate parser format where headlines are not
  `== this ==` but `��2��this`.
* Actual flat plain text.

The default is wikitext. That's why we see `== wikitext
syntax ==` in certain edge-case situations. Forcing it to
"plain" fixes this.

Bug: T271439
Change-Id: I3035fb3df99680af8bbd10c4513aed730013c344
2021-01-08 09:17:35 +01:00
Noam Rosenthal 7b0937c5a8 Use CSS clip-path instead of SVG when supported.
This reduces a lot of churn in creating the SVG
element and related helpers.

When IE11 is dropped, the SVG code-path can also be dropped.

Bug: T269336
Change-Id: I7f91192dedc2a78f1c7c84179cff1687593177c0
2021-01-05 19:26:24 +00:00
Bartosz Dziewoński c8b8ba7f5f Revert "Remove title attributes at init"
This reverts commit 6bc2077ed5.

The change causes issues with various popular gadgets on Wikimedia
wikis. The 'title' attributes have been the easiest way to determine
the target pages of links, and many gadgets have come to rely on that.

Bug: T269297
Bug: T269873
Change-Id: I49d315a13c327a1c5af51d3de887c0c17642e9fe
2020-12-11 16:53:17 +00:00
Svantje Lilienthal cbd4e673d4 Add qunit test for conflict with popups
Bug: T267951
Change-Id: I47cc8e8565252dc78e39c00c94a07300b4e35593
2020-12-10 15:47:38 +01:00
Vedmaka ff2ba9ebf5 Adds "$wgPopupsTextExtractsIntroOnly" option to control "intro" parameters for TextExtracts API request
Change-Id: I84f91ab0752bbd4a5b1ee159b7cbe1388f942f24
2020-12-07 15:00:29 -08:00
Noam Rosenthal 4492b54a44 Performance optimization for popup rendering
Reduce layout/style thrashing by measuring all required geometries
at event handler, not waiting for delays/redux/style changes.

Use CSS bottom instead of top, to avoid having to measure the popup
before positioning it, if it's placed above the link ("flippedY").

Disable some test cases that relied on implementation detail of using
"top" CSS.

Change-Id: Id0cbf506009b824d0fb6af4d6fe220e2f69aaaad
2020-11-30 17:33:07 +02:00
Noam Rosenthal 6bc2077ed5 Remove title attributes at init
This is a performance optimization - removing
all the titles when initializing the popup extension
reduces DOM manipulation during hover, removing/reinstating the title
attribute.

When the popup extension is loaded, the default "title" behvior is unnecessary.

Change-Id: I1a85394b6b67eabee50a8d554bfd9b62de2a24d3
2020-11-30 15:39:36 +02:00
WMDE-Fisch 22b0e54cf1 Use Util.waitForModuleState in browser tests
Change-Id: I09dbaa703818bf3df62c290e83ca6e36adf2f72a
2020-11-20 10:35:10 +01:00
WMDE-Fisch 0cd94df686 Fix and re-enable ReferencePreview browser tests
The tests were skipped for some time already because the beta
feature mode is taken into account on the test systems. The tests
need to login and enable the beta feature mode to be executed. This
is fixed with that patch.

The patch also fixes broken tests due to changes that made one test
obsolete and another that needed adjustments.

There are also comments added to places where code can be removed or
altered if the feature gets out of beta status.

Bug: T268134
Change-Id: Ib96d23f3cb6c6130fd5880a78fafd252bf706475
2020-11-18 14:33:45 +01:00
Svantje Lilienthal 0b6c859a2b hide reference previews when reference tooltip gadget is active
Change-Id: I5f43270bfeba944c05dc09adf771ed07057237c7
2020-11-16 18:36:04 +01:00
Adam Wight 789cedc168 Remove reference preview "Jump to reference" link
Now that the footnote label links to the references section, we don't
need this additional link.

Bug: T265482
Change-Id: Ib9b2939eb49e7b826c7699a5b7fa0e8255fa9da1
2020-10-30 11:33:24 +00:00
Thiemo Kreuz c1abe80b08 Minor code cleanups, e.g. utilizing arrow functions
Change-Id: I56bcfa040553a96f018f22483f3f988c5639fc97
2020-10-30 11:31:12 +01:00
Thiemo Kreuz 7d2de31fd9 Don't show preview popups with no visible content
I played around with a lot of options, and settled with:
* When there is nothing but text, but the text is all
  whitespace, don't show it.
* Make sure an <img> with no text is still shown. This is done
  by checking for child elements.

A possible future enhancement could be to check the visible
width of the element as well. Unfortunately this fails in
tests. Everything is 0 in tests.

Bug: T240543
Depends-On: I2929a86b6a09f3b72e5e2f4151cb13f52446897d
Change-Id: I94ed575abcd69241c82480ade07017e61cc26c9c
2020-10-30 11:19:52 +01:00
Adam Wight 877c2f3e12 Clicking on a reference should behave normally
We no longer intercept reference clicks, now clicking on a reference
label will scroll to the reference definition in the same way as when
reference previews is disabled.

Metrics about clicking on the label are collected by the Cite
extension, are are unaffected by this change.

Bug: T265482
Change-Id: I2929a86b6a09f3b72e5e2f4151cb13f52446897d
2020-10-30 10:57:41 +01:00
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