Commit graph

698 commits

Author SHA1 Message Date
Fomafix c973491965 PopupsContextTestWrapper: Remove null check for $gadgetsIntegration
$gadgetsIntegration can never be null. This is ensured by the PHP type
check.

Change-Id: Ia70e8b8b329ba771dcb8a98d4a78220c2f0f5fbf
2024-06-29 20:41:43 +00:00
jenkins-bot 058c772d52 Merge "Restore the original behaviour of Reference Previews" 2024-06-24 07:07:44 +00:00
Umherirrender 12a86a9e49 Use namespaced classes
Change-Id: Iaa28a15e8bc1ea29e302aa2180dec0bf67f5817e
2024-06-09 19:14:49 +02:00
Func ff30b0bc2b Restore the original behaviour of Reference Previews
Commit a75ddc41 and 33f9e9d3 effectively changed the default user
option value of popups-reference-previews for users created before
2017/08/16 without any justification.

Please see the task description for full analysis.

This partially reverts commit a75ddc41.

Bug: T366419
Change-Id: I68d6114384af6d259dbc4541522d52ae9a289e49
2024-06-08 04:26:40 +08:00
Moh'd Khier Abualruz a75ddc4173 feature(Popups): Conditional User Defaults Implementation
Implement conditional defaults for user preferences in the Popups
component.
This patch aims to simplify the preference management system by
leveraging conditional logic directly within the component rather
than relying on multiple hooks

Changes:
- Updated `extension.json` to reflect the removal of outdated hooks.
- Updated `extension.json` to reflect the conditional user defaults.
- Removed unused user option `popupsreferencepreviews` from
 `extension.json`
- Modified `PopupsHooks` to streamline the preferences management,
 and depend on conditional user defaults, and removing `onUserGetDefaultOptions` and `onLocalUserCreated` hooks.
- Removed unneeded test cases in `PopupsHooksTest`.

Bug: T364347
Change-Id: Iae454e4b4704a0289ca0a2b0794730562fda0dd1
2024-05-28 21:05:57 +00:00
thiemowmde 1e61af1798 Use more trivial HashConfig in tests
No need to mock this.

Change-Id: Ic312fd6045e4c6ea450114f3548596481f1fd2ee
2024-04-24 13:13:13 +02:00
Fomafix 1ce8b38f9f Inject 'Popups.Logger' into PopupsHooks
The function PopupsContext::getLogger is not needed anymore.

Change-Id: Ib538372f1480d282857d827fedbe0ebe9abc0685
2024-03-19 20:26:53 +00:00
Fomafix a523b79232 Inject Popups services into PopupsHooks
Change-Id: I16ebb2aff9afab0449e3cc4b58a7ac6b3ed9870a
2024-03-19 20:10:36 +00:00
Adam Wight cf2a10e42e Remove referencePreviews tests
These are causing trouble because of the forwards-compatibility
logic.  When Cite is present, we transparently switch to using that
code base for reference previews which means these tests are running
against the wrong code.  Dropping tests here in favor of the Cite
tests.

Bug: T355194
Change-Id: Ide1940ad1e915eee7127f36fb2a7c87b5fb6f88a
2024-03-18 13:55:20 +01:00
Jon Robson 7172aae082 Reference previews should no longer use Webpack
As a precursor to moving this code to the Cite extension move it off
of webpack and switch to using require rather than import

Bug: T355194
Change-Id: Ib6486ad38b79a3b67a9744b716b1a2f5d3779795
2024-02-02 10:52:30 -08:00
WMDE-Fisch bf10902f23 Don't bail out early when there are no selectors configured
It seems to me, that at this point 3rd parties might not have been
loaded that want to add custom preview types. So the list of
selectors is empty.

We still might want to initialze though for 3rd parties that load
later.

Bug: T355933
Change-Id: I5f293a134521f086c9f62babb9d06cd9c51d7d47
2024-01-26 12:38:47 +01:00
WMDE-Fisch e15e2c4d14 Increase test coverage
More of a random thing done to increase the coverage a bit because
there are upcomming features that seem to be hard to test.

- Found one test case in reference previews that was configured
  wrongly

- Adding some sanity checks to the settingsDialogRender test

Change-Id: I95d3c6f30388b2dcc76b018d5dc0f958d06aad91
2024-01-16 10:44:53 +00:00
Jon Robson 381f8f5f7d Reduce bundlesize of reference previews by making it use stable APIs
This is a precursor to moving the code out to the Cite extension.

This can be squashed into parent commit or merged at same time.

I've kept the two patches separate to make them easier to review.

Bug: T326692
Change-Id: I50dbf28a1078df6c73fd0fbf77480488dd82c7b3
2024-01-16 11:44:07 +01:00
Jon Robson 59c6b8e88f Reference previews should use Popups registration
* Adds a new webpack entry point for references previews
* Reference related code in src/index.js is moved to new
file resources/ext.popups.referencePreviews/index.js

The changes:
* References previews now in its own module ext.popups.referencePreviews
* Loaded via getCustomPopupTypes
* OWNERS.md files make clear which team owns which part of the code.

Bug: T326692
Change-Id: Iea8a5b9221c0b1fd41e40bff2cbe01e42124d53f
2024-01-16 11:38:08 +01:00
WMDE-Fisch a3f3cf9e3f build: Update eslint 0.26.0 and apply fixes
Mainly auto fixes but also getting rid of some straight forward lint
warnings to reduce the wall of issues a bit when running the tests.

Also removing some rule exceptions that seem to got more relaxed
upstream.

Change-Id: Icb4d73374583675be74517e6df6508314d61e8c2
2024-01-12 13:50:19 -05:00
Jon Robson 2c09fd1d1c Generalize settings code (attempt 2)
This reverts commit a6a65204c6.
to restore custom preview types.

-- Changes since revert
The previous patch accidentally removed the syncUserSettings
changeListener. This has now been restored with several modifications:
* We have a migrate script which rewrites existing localStorage settings
to the new system
* The existing save functions are generalized.

The changes since this patch are captured in
Ia73467799a9b535f7a3cf7268727c9fab7af0d7e

-- More information

A new REGISTER_SETTING action replaces the BOOT action for
registering settings. This allows custom preview types to be
associated with a setting. They do this by adding the enabled
property to the module they provide to mw.popups.register

Every time the new action is called, we refresh the settings
dialog UI with the new settings.

Previously the settings dialog was hardcoded, but now it is generated
from the registered preview types by deriving associated messages
and checking they exist, so by default custom types will not show
up in the settings.

Benefits:
* This change empowers us to add a setting for Math previews to allow
them to be enabled or disabled.
* Allows us to separate references as its own module

Additional notes:
* The syncUserSettings.js changeListener is no longer needed as the logic
for this is handled inside the "userSettings" change listener in response to
the "settings" reducer which is responding to
SETTINGS_CHANGE and REGISTER_SETTING actions.

Upon merging:
* https://www.mediawiki.org/wiki/Extension:Popups#Extensibility will be
updated to detail how a setting can be registered.

Bug: T334261
Bug: T326692

Change-Id: Ie17d622870511ac9730fc9fa525698fc3aa0d5b6
2024-01-09 17:24:09 -08:00
Umherirrender f3c4642fd5 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Ib30da35841aadb558709dbbe6e30be2241048c87
2024-01-05 22:41:45 +01:00
jenkins-bot cdede23c59 Merge "Update tests for PHPUnit 9.6" 2023-11-30 23:08:24 +00:00
Ed Sanders c0bf30fb58 Documentation fixes
* Element -> HTMLElement
* JQuery -> jQuery
* Remove `return {void}`

Change-Id: I887dfe98af77358ad4ef4e1c835ccf45c2c64400
2023-11-30 10:38:07 +00:00
jenkins-bot ea42009239 Merge "Update UserOptionsLookup's FQN" 2023-11-29 17:14:37 +00:00
gerritbot 96cea43fe1 Update UserOptionsManager's FQN
User-options related classes are being moved to
the MediaWiki\User\Options namespace in MediaWiki Core;
reflect that change here.

Bug: T352284
Depends-On: I9822eb1553870b876d0b8a927e4e86c27d83bd52
Change-Id: Icb39d3f73e120fd0d9dad5ae362787cd19d47bfb
2023-11-29 12:55:13 +00:00
gerritbot 031ace2dba Update UserOptionsLookup's FQN
User-options related classes are being moved to the MediaWiki\User\Options namespace in MediaWiki Core; reflect that change here.

Bug: T352284
Depends-On: I9822eb1553870b876d0b8a927e4e86c27d83bd52
Change-Id: I0c66220b0ba9501e8ef20a172d21d7e75a19d6cc
2023-11-29 12:39:47 +00:00
Daimona Eaytoy d77b6e9992 Update tests for PHPUnit 9.6
- Avoid withConsecutive()

Bug: T342110
Change-Id: I3f07a2f071ddec3f9bbd147b8bfc0d32277203d6
2023-11-27 03:13:29 +01:00
WMDE-Fisch b218a77ca4 Remove all BetaFeature code from ReferencePreviews
The extension is out of beta and will be enabled by default now.
Leaving some hints if we decide to also remove the feature flag.

Bug: T282999
Bug: T351708
Change-Id: I1556b2f3592294d094770ede2c276eddeef8bbe9
2023-11-24 13:07:46 +01:00
thiemowmde 7596165a5d Fix confusing constant names in PHP
The …AFTER_BETA constant is the one we want to keep after we removed
all BetaFeature code. The naming scheme is just confusing.

Safe to rename. Not used anywhere else:
https://codesearch.wmcloud.org/search/?q=REFERENCE_PREVIEWS_PREFERENCE_NAME

We also decided to keep the $wgPopupsReferencePreviews feature flag.
Update the documentation accordingly.

This is split from I1556b2f to make it easier to review.

Bug: T351708
Change-Id: Ifbb41156f2a5a4d8a81e79f613754869c5c89690
2023-11-24 12:51:41 +01:00
Ed Sanders 461f949823 build: Update linters
Also restructure eslint config so that
* root files are linted with server rules
* src and tests share config

Change-Id: Ie4d0731ba9670af7f3e60cdfe3c4e331386b17c6
2023-11-09 11:36:08 +00:00
Jon Robson a6a65204c6 Revert "Generalize settings code"
This reverts commit 6924a89b07.

Reason for revert: Breaks persistence of setting
for anonymous users.

Change-Id: I3efc20f44281c1c68c4162584388e33bb38c4848
2023-10-19 14:13:15 -07:00
Jon Robson 6924a89b07 Generalize settings code
A new REGISTER_SETTING action replaces the BOOT action for
registering settings. This allows custom preview types to be
associated with a setting. They do this by adding the enabled
property to the module they provide to mw.popups.register

Every time the new action is called, we refresh the settings
dialog UI with the new settings.

Previously the settings dialog was hardcoded, but now it is generated
from the registered preview types by deriving associated messages
and checking they exist, so by default custom types will not show
up in the settings.

Benefits:
* This change empowers us to add a setting for Math previews to allow
them to be enabled or disabled.
* Allows us to separate references as its own module

Additional notes:
* The syncUserSettings.js changeListener is no longer needed as the logic
for this is handled inside the "userSettings" change listener in response to
the "settings" reducer which is responding to
SETTINGS_CHANGE and REGISTER_SETTING actions.

Upon merging:
* https://www.mediawiki.org/wiki/Extension:Popups#Extensibility will be
updated to detail how a setting can be registered.

Bug: T334261
Bug: T326692
Change-Id: Ie11057052fb9035944f2b79a17fb486f97102994
2023-10-17 15:08:15 +00:00
Jon Robson a11d459ef1 Selenium: More explicitly target reference links
The previous selector in the case of the first reference link
matches two elements - one in the "Reference links" section
and one in the "References" section.

My hunch is this leads to the test failures we have been seeing

Bug: T344072
Change-Id: Icda37b4f46add4049344f7a8c452082d7b0df5c8
2023-09-21 22:48:43 +00:00
bwang 154912e5db Rename icon classes in Popups to use popups-icon prefix instead of mw-ui-icon, replace resource loader icons with codex
Bug: T345653
Change-Id: I19b9861850064df50d6b88cda748feff6231091c
2023-09-12 10:56:53 -05:00
jenkins-bot 7e88a55e10 Merge "Replace mediawiki.ui.icon with Codex, update preview markup and styles to be more consistent" 2023-08-21 20:09:27 +00:00
bwang b78cfe50c9 Replace mediawiki.ui.icon with Codex, update preview markup and styles to be more consistent
- Removes .mw-ui-icon and .mw-ui-icon-element
- Aligns markup/styles between generic and disambiguation previews
- Update padding for generic and disambiguation previews to be the same as other popups, results in minor visual changes

Bug: T341899
Change-Id: I9a58fc6a93160d07452ea6f903e1797dd9421d92
2023-08-21 19:53:51 +00:00
gerritbot 2da869fa58 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: Ia3b739ceacc035d64ec6d13de9d3e6de102dbb20
2023-08-19 12:22:49 +00:00
Daimona Eaytoy c581aab15e Avoid using TestUser in non-Database tests
TestUser is expensive and requires DB access because it creates the user
in the test database. That is not needed here. For these tests, a mock
is enough.

Also make PopupsGadgetsIntegrationTest an integration test, to fix a
local failure and in view of I0a04c82250582fed7a66c1e10868d9b4f3823a28.
If a test is testing the integration of X with Y, guess what, it's an
integration test ;-)

Change-Id: Ie8b3376ce97b9ddc67746f7754b92628c5ab9470
2023-08-10 00:08:49 +02:00
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