Commit graph

4125 commits

Author SHA1 Message Date
Translation updater bot 12c414f4c4 Localisation updates from https://translatewiki.net.
Change-Id: Iaab9324e298b755d96678ac8868cbd98fc9d82f8
2023-12-22 17:45:28 +01:00
jenkins-bot d8711ce3ed Merge "Show warning when dir="…" don't match" 2023-12-21 21:24:13 +00:00
Adam Wight 5d1335e279 Explicit parameter names for all test fixtures
This is much more readable.  Patch changes nothing.

Bug: T353451
Change-Id: I72b58881a7329dbe98659553b84e53896ccafc2b
2023-12-21 20:59:25 +01:00
Adam Wight e0e8b2dc33 Drop constant parameters
Some tests didn't vary the key parameter, so converting to a
constant.

Change-Id: I9a42352573cc16fec11a799b878c06751eb03fc8
2023-12-21 20:52:43 +01:00
Translation updater bot 9b11e93bbe Localisation updates from https://translatewiki.net.
Change-Id: I04ba74f6fae07793f3a3180b204f3fbe89b16949
2023-12-21 19:45:01 +01:00
Adam Wight 4ed93908a3 Ref sequence vs. key
Internal ref key is always an int, but another string `key` is
created in the formatters.  This patch makes the typing explicit.  We
can distinguish between these two different values in a later patch.

Bug: T353451
Change-Id: Id5e40517705961f4d54622e91264430d9f62008d
2023-12-21 10:03:18 +01:00
Translation updater bot daf9d7b71d Localisation updates from https://translatewiki.net.
Change-Id: I9eb5ff99f40b2db8956a4c95f17a20b8bb0e06bf
2023-12-20 14:04:30 +01:00
thiemowmde b181614ba1 Show warning when dir="…" don't match
This classifies as a "warning" because we still show everything,
just with an error message appended.

Disabling the Parsoid tests right away hopefully makes it easier to
do the same change in Parsoid.

Bug: T202593
Depends-On: If14acd1070617ca8c4d15be6b1759bd47ead4926
Change-Id: I294b59f989f553932b40d08308906dd72d92d2cd
2023-12-19 14:17:30 +01:00
Subramanya Sastry 58f008ae1e Sync up Cite repo tests with Parsoid + (en/dis)able some Parsoid tests
* This now aligns with Parsoid commit 0fab92ba453d424aedeadaaa9e1514c42bbd94d1
* Disabled the newly added tests because that Parsoid fixes for the
  tests haven't been released to vendor to let CI pass these tests.
* Re-enabled a previously disabled test.

Change-Id: I4ab87d2d486b7a1fef652c50c4f1e79ddfe83ce6
2023-12-18 16:35:01 -06:00
Translation updater bot e64d944194 Localisation updates from https://translatewiki.net.
Change-Id: Ice9b812492a0bce8ef003413a66501d9db1c75e2
2023-12-18 18:16:28 +01:00
jenkins-bot 9b87bc717d Merge "Various cleanups to PHPUnit test mock setup" 2023-12-18 12:36:11 +00:00
jenkins-bot d79ae15bd0 Merge "Add basic class-level documentation to more classes" 2023-12-18 12:35:58 +00:00
jenkins-bot a10437ad1d Merge "Avoid the term "book referencing" in a few places" 2023-12-18 11:58:33 +00:00
jenkins-bot 4cc26a8fa7 Merge "Separate ReferenceStack::appendText() from setText()" 2023-12-18 11:58:29 +00:00
jenkins-bot 3bf67a3648 Merge "Track warnings separately in ReferenceStack" 2023-12-18 11:58:26 +00:00
jenkins-bot f112648cb2 Merge "Revert "Revert "Temporarily disable a Parsoid test to let us change code in Parsoid""" 2023-12-15 21:14:43 +00:00
Subramanya Sastry 8ac343718b Revert "Revert "Temporarily disable a Parsoid test to let us change code in Parsoid""
This reverts commit b163add15b.

Reason for revert: This was my mistake. I forgot that reverting this
would break Parsoid CI once the Parsoid Cite patch merged. So, I have to
wait till the Parsoid Cite change is released to vendor before I sync
the test change here.

Change-Id: Icaecee1e56907980681aae01be377b6906bd93a6
2023-12-15 20:36:43 +00:00
jenkins-bot 708436c998 Merge "Revert "Temporarily disable a Parsoid test to let us change code in Parsoid"" 2023-12-15 19:24:05 +00:00
jenkins-bot d5fe9559e7 Merge "Temporarily disable a Parsoid test to let us change code in Parsoid" 2023-12-15 19:10:57 +00:00
thiemowmde 54ac87e5ce Separate ReferenceStack::appendText() from setText()
This moves one more error situation into the stack class, together
with other error situations that are already there.

Bug: T353266
Change-Id: Icf169650f67f64e6d29d175c3b47cf558b8de3d4
2023-12-15 16:41:05 +01:00
thiemowmde 742a9ffbf5 Track warnings separately in ReferenceStack
Check out how this gets rid of so many "to do" as well as
"deprecated" comments.

Next qustion: The elements in the stack become more and more
complicated. It's probably worth converting them from arrays into
first-class objects. But this is for another patch.

Bug: T353266
Change-Id: If14acd1070617ca8c4d15be6b1759bd47ead4926
2023-12-15 16:41:04 +01:00
thiemowmde 13138d4ed0 Avoid the term "book referencing" in a few places
We are discussing this for a long time and finally renamed the tag
on Phabricator: https://phabricator.wikimedia.org/tag/cite-extends

This patch updates only places where it can't have any negative
consequences.

This is also a direct follow-up to Ic73f1b7 where this class was
created.

Bug: T353269
Change-Id: I644fe41d3386b9bf02b83366654301633efd535f
2023-12-15 15:49:04 +01:00
xiplus f7a181ed42 Give a different error from too_many_keys when 'follow' attribute conflicts
Add message "cite_error_ref_follow_conflicts" for tags with
conflicting parameters.

Bug: T299280
Change-Id: Ie64f4ab4831966f66f812ea67cc244718f818afb
2023-12-15 15:23:53 +01:00
thiemowmde e7dea09216 Add basic class-level documentation to more classes
Bug: T353227
Change-Id: I3953543a111121cc49f6ea89988351b80b03e828
2023-12-15 14:27:58 +01:00
thiemowmde 9304e24551 Various cleanups to PHPUnit test mock setup
For example, use convenient upstream methods, and generally make the
test setup a bit more readable.

Bug: T353227
Change-Id: Ifab71041fcc3f804315793ca7b783f84829c7a0f
2023-12-15 11:45:35 +00:00
thiemowmde 4377f0923d More simple and consistent @covers and @license tags
Same arguments as in Iafa2412. The one reason to use more detailled
per-method @covers annotations is to avoid "accidental coverage"
where code is marked as being covered by tests that don't assert
anything that would be meaningful for this code. This is especially a
problem with older, bigger classes with lots of side effects.

But all the new classes we introduced over the years are small, with
predictable, local effects.

That's also why we keep the more detailled @covers annotations for
the original Cite class.

Bug: T353227
Bug: T353269
Change-Id: I69850f4d740d8ad5a7c2368b9068dc91e47cc797
2023-12-15 12:12:16 +01:00
thiemowmde d0d5fbbee6 Add temporary ErrorReporter::firstError helper function
I hope this makes other refactorings a little easier.

Bug: T353266
Change-Id: Ib574d4d54ba2c8bc1310822539336ad71c4309ef
2023-12-14 17:16:49 +01:00
thiemowmde 01dcfbac47 Move Validator tests to a separate class
I wanted to make this a unit test but it turns out the
Sanitizer::safeEncodeAttribute() calls currently make this
impossible.

Bug: T353269
Change-Id: I5266e7b8b67db1c812dc9e4675d0c079ab1f9a40
2023-12-14 15:51:26 +00:00
jenkins-bot 6fc8ee7fec Merge "Get rid of "guarded <references>" terminology" 2023-12-14 14:25:57 +00:00
jenkins-bot 9ec01ef894 Merge "Introduce named constant for "__placeholder__" string" 2023-12-14 14:20:14 +00:00
jenkins-bot 78b40a8c6b Merge "Extract validation to a separate class" 2023-12-14 14:18:40 +00:00
thiemowmde cb71e87b0e Introduce named constant for "__placeholder__" string
This is a concept that's only relevant when a sub-reference (formerly
known as BookReferencing) appears before the parent reference it
belongs to. Let the name reflect this.

Bug: T353227
Change-Id: Iabf259e72942ea70cb1cc1e0ca5a5d8cf15d7225
2023-12-14 09:45:06 +01:00
thiemowmde c794962df7 Use short fn() syntax in tests where it makes sense
We can use this syntax now. It was introduced in PHP 7.4.

Bug: T353269
Change-Id: I5404b33b654efb01171fa2b4ad3925170ffd0e56
2023-12-14 08:05:01 +00:00
jenkins-bot 5b4e869014 Merge "tests: Widen @covers annotations" 2023-12-14 07:57:46 +00:00
thiemowmde 12c7ad7504 Get rid of "guarded <references>" terminology
This patch only moves existing code around without changing any
behavior. What I basically did was merging the old "guardedReferences"
method into "references", and then splitting the resulting code in
other ways. Now we see a few other concepts emerging. But the idea
something would be "guarded" (how?) is gone.

The most critical detail in this patch are the new method names, and
how the code is split. The names should tell a story, and the methods
should do exactly what the name says. Suggestions?

Bug: T353266
Change-Id: I8b7921ce24487e9657e4193ea6a2e3e7d7b0b1c3
2023-12-14 08:44:40 +01:00
thiemowmde a6a0f66130 Extract validation to a separate class
This removes almost 200 lines from the main class.

This patch intentionally doesn't make any changes to the code but
only moves it around. Further improvements are for later patches.

Bug: T353269
Change-Id: Ic73f1b7458b3f7b7b89806a88a1111161e3cf094
2023-12-14 07:43:29 +00:00
Translation updater bot 428494cd82 Localisation updates from https://translatewiki.net.
Change-Id: I876220af9cc824740b1ab30132cbb5b9f2af4632
2023-12-14 08:27:12 +01:00
jenkins-bot bf53249893 Merge "Move a bit of code out of Cite::guardedReferences" 2023-12-14 02:10:06 +00:00
jenkins-bot 61850c091a Merge "Remove PHPDocs that just repeat what the code already says" 2023-12-14 02:04:15 +00:00
Timo Tijhof 2ff327df53 tests: Widen @covers annotations
> We lose useful coverage and spend valuable time keeping these tags
> accurate through refactors (or worse, forget to do so).
>
> I am not disabling the "only track coverage of specified subject"
> benefits, nor am I claiming coverage in in classes outside the
> subject under test.
>
> Tracking tiny per-method details wastes time in keeping tags
> in sync during refactors, and time to realize (and fix) when people
> inevitably don't keep them in sync, and time lost in finding
> uncovered code to write tests for only to realize it was already
> covered but "not yet claimed".

https://gerrit.wikimedia.org/r/q/owner:Krinkle+is:merged+message:%2522Widen%2522

Change-Id: Iafa241210b81ba1cbfee74e3920fb044c86d09fc
2023-12-14 01:54:48 +00:00
Sam Wilson b03dd1bba8 Load WikiEditor ref toolbar button on other content types
Allow other extensions to provide lists of page content
models for which they want to load the Cite toolbar button.
This will, for example, make it possible for ProofreadPage
to have the button on Page pages.

Bug: T348403
Change-Id: Id28cb0b6cb8a2b86a66b17232575afe513969c54
2023-12-13 21:45:19 +00:00
thiemowmde 04208b5fd1 Remove PHPDocs that just repeat what the code already says
We removed a bunch of now redundant docs already, see e.g. Ie0692fa.

Change-Id: I55c62d935bdec8bedaebc2666fca3eb17309b0c7
2023-12-13 12:44:41 +01:00
Translation updater bot 7ef1d0d009 Localisation updates from https://translatewiki.net.
Change-Id: I1e7405edbd415fc2392fa73f4aa4917a48410c9d
2023-12-13 08:40:31 +01:00
jenkins-bot c3aa27f2a1 Merge "Avoid a few isset() in favor of more recent syntax" 2023-12-12 23:58:45 +00:00
thiemowmde 689bafdd7f Use upstream assertStatusError and such in tests
The main benefit is that these methods give good debug output in
case they fail.

Bug: T353266
Change-Id: I0423737240c35c18078863a7eb1d8e4779363973
2023-12-12 19:16:50 +01:00
thiemowmde 9425bb3248 Move a bit of code out of Cite::guardedReferences
The main benefit is that the two lines that set and reset
$this->inReferencesGroup are now next to each other. More can be
done in later patches.

Bug: T353266
Change-Id: Ib3f40c40e0b1854f8e5a32af600f28931fffdb8c
2023-12-12 18:06:58 +00:00
jenkins-bot 739e05e151 Merge "build: Update linter libs" 2023-12-12 14:45:22 +00:00
jenkins-bot cdc2bd2b96 Merge "Skip URL encoding in id="…" attributes that aren't URLs" 2023-12-12 14:34:07 +00:00
thiemowmde 89bd26fcf5 Skip URL encoding in id="…" attributes that aren't URLs
I played around with a few options (see patchset 1) but ended
introducing new terminology:

* "Backlink" describes the ↑ button down in the list of <references>
  that jumps back up into the article. The code was already using
  "backlink" in some places.
* "Backlink target" is the id="…" attribute up there, visible as the
  typical [1] in the article.
* I use "jump" to describe the idea that clicking the [1] jumps down
  to the full reference.
* "Jump target" is the id="…" down there in the list of <references>.
* "Jump link" is the same id, but encoded to be used as the href="…"
  attribute when clicking the [1].

I hope this makes sense. Suggestions welcome.

Another benefit is that "normalization" is really only normalization
now, not any URL and/or HTML encoding.

Bug: T298278
Change-Id: I5a64ac43aef895110b61df65b27f683b131886fb
2023-12-12 13:56:37 +00:00
WMDE-Fisch 2a02f5311d build: Update linter libs
* "eslint-config-wikimedia": "0.26.0"
* "grunt-eslint": "24.3.0"
* "grunt-stylelint": "0.19.0"
* "stylelint-config-wikimedia": "0.16.1"

Including auto fixes.

Change-Id: Iadacfc781a48675022144bb8c9489073d0bc19e3
2023-12-12 14:21:07 +01:00