Commit graph

470 commits

Author SHA1 Message Date
jenkins-bot 583eeafd37 Merge "Use ParserOutput::setUnsortedPageProperty()" 2024-04-18 12:47:56 +00:00
mareikeheuer 30663d285b Cypress test for adding a reference in VisualEditor using templates
Verify the functionality of adding template references

- template dialog opens correctly
- allows undocumented parameter input
- verifies the presence of the added reference in saved mode

Bug: T358657
Change-Id: I5a35a5fe0c6f27f53a1d9de887bdf52b8e7f9c08
2024-04-16 16:44:22 +02:00
C. Scott Ananian 9ff28a0837 Use ParserOutput::setUnsortedPageProperty()
The ::setPageProperty() method has some tricky corner cases where the
type of the value determines whether or not the page property will be
sorted.  Since sort order for the BOOK_REF_PROPERTY is irrelevant,
use ::setUnsortedPageProperty() to communicate this clearly to the
reader.

Depends-On: Ia94c192c429d0482c58467bed787fd2e0aca052f
Followup-To: Ibfd84b52057baa8e249d321ec9df612efd6a29a6
Change-Id: I399f4895ec8720ff2927c5cd5a09c7af4664ee46
2024-04-16 09:51:43 -04:00
C. Scott Ananian fc5f22b32e CiteParserHooksTest: make test compatible with removal of dynamic property
Whether the dynamic property is present or not, it should have a null
value when 'unset' -- and don't use `unset` to delete an *actual*
property when one is present!

Change-Id: Ifcb9492cc5c814d702c6e61e8231abfd8ea0647c
2024-04-12 15:23:14 -04:00
Isabelle Hurbain-Palatin d94d7f923b Re-enable and fix tests after Parsoid modification
Bug: T214241
Depends-On: I022501851ea45cfd2554f9e914aa6f4fe2b07548
Change-Id: Ib7d7e6debb9ea73cb05d4142392b00a195644116
2024-04-09 15:57:17 -04:00
jenkins-bot 5d878d41f7 Merge "Disable some tests for Parsoid CI" 2024-04-04 15:56:55 +00:00
jenkins-bot 5041bb598b Merge "Move Cypress tests under tests/ directory" 2024-04-04 13:55:44 +00:00
thiemowmde d2a244b753 Move Cypress tests under tests/ directory
Bug: T358851
Change-Id: I084f4e098c00d4c1bbcb0e692a2be3b1f8ce59a2
2024-04-04 13:06:26 +00:00
thiemowmde b02028b671 Move ve-cite QUnit tests to top-level tests/ directory
It's just hard to find and confusing when hidden in that
sub-directory.

Bug: T358851
Change-Id: I19ffe73b79fa9add52af12f477afe7abbc6db836
2024-04-03 12:03:33 +02:00
Isabelle Hurbain-Palatin b1ad116f89 Disable some tests for Parsoid CI
Bug: T214241
Needed-By: I022501851ea45cfd2554f9e914aa6f4fe2b07548
Change-Id: I40f3c82cbf861426137b935f1bf0bc4b3c6194b0
2024-04-03 03:01:21 +00:00
jenkins-bot 1fdc65548b Merge "Add strictly typed RefGroupItem class to Parsoid code" 2024-04-01 03:05:52 +00:00
jenkins-bot 51e569d888 Merge "Allow visualeditor-cite-tool-name-… messages to be missing" 2024-03-28 15:27:14 +00:00
jenkins-bot 310075ec69 Merge "Improve test coverage for incomplete follow=… rendering" 2024-03-28 15:27:07 +00:00
jenkins-bot 974401489d Merge "Move reference previews to Cite extension" 2024-03-15 19:15:16 +00:00
thiemowmde 7a9a48b1e0 Improve test coverage for incomplete follow=… rendering
There is currently no test coverage for recursively parsing the
contents of a <ref>…</ref> together with an incomplete follow="…".
This is critical because that's an entirely separate, special code
path (the one that creates a <p> instead of an <li>). Without this
 test we could return unparsed wikitext and never notice.

I discovered this while playing with I0b0e358.

Bug: T245549
Change-Id: Ie65c6bf6bf75db26e0fff733c93cfa28ee7bd228
2024-03-14 15:31:29 +01:00
thiemowmde 9e1c4645be Add strictly typed RefGroupItem class to Parsoid code
This does the exact same as the previously used generic stdClass
object, just strictly typed. Turned out to be surprisingly
straightforward, as proven by the small size of this patch.

I'm intentionally not adding anything new in this patch. For
example, the new class is perfect to write longer documentation
for every field. But this is for a later patch.

Change-Id: Ibf696f6b5ef1bfdbe846b571fb7e9ded96693351
2024-03-14 11:59:34 +01:00
jenkins-bot c47627b9df Merge "Add basic PHPUnit tests for Parsoid implementation" 2024-03-13 14:59:43 +00:00
Jon Robson dcb513eb0e Move reference previews to Cite extension
The ext.cite.referencePreviews module will transparently replace the
ext.popups.referencePreviews module after this patch.  Configuration
stays in Popups for now, we can migrate it in later work.

CSS classes may be renamed in the future but this will be handled
separately since it could be a breaking change for on-wiki
customizations.

A lot of fancy footwork happens in this patch to emulate a soft
dependency on Popups.  This mechanism doesn't exist explicitly in
either ResourceLoader or QUnit, so lots of workarounds are used, to
conditionally load the module and to dynamically skip dependent tests.

renderer.test.js is fully skipped for now, but can be wired up in
later work.

Bug: T355194
Change-Id: I0dc47abb59a40d4e41e7dda0eb7b415a2e1ae508
2024-03-12 17:43:51 +01:00
thiemowmde 650d2c296d Add basic PHPUnit tests for Parsoid implementation
There is much more to test, but it's a start.

Intentionally build as pure unit tests to make them as fast as
possible.

Bug: T354215
Bug: T358652
Change-Id: Iae1a8086b8f2b9e5b11e0117bd3f19fdaa087df0
2024-03-12 09:06:16 +00:00
thiemowmde 644597c402 Move Parsoid-specific CSS into a subdirectory
The first two files have been added to the root modules/ directory
via I487095d in 2015. No problem.

Many, many more files have been added via I000b453 in 2022. It's
really hard to tell what is what since then.

I'm not absolutely sure what the naming convention for this folder
should be. Could as well be "localized-styles/" or just "Parsoid/".

Bug: T156350
Change-Id: Ibcf8c7a6db5400ed8a9811244a070e03ff372a39
2024-03-11 12:42:25 +00:00
thiemowmde 2b32f15c8c Allow visualeditor-cite-tool-name-… messages to be missing
The information read from the …cite-tool-definition.json files is
effectively user input, even if only interface administrators can
edit it. Usually we carefully validate user input. But as of now
this code starts failing with all kinds of uncatched errors.
* An entry with no name, an empty name, or a name that's not a
  string will cause all kinds of undefined behavior.
* An entry with an empty title results in an invisible button.
* A missing message results in a technical <…> placeholder, even if
  the name is usually a sensible fallback.

Note that hard-coding titles as plain text strings in the ….json
file was already possible.

Change-Id: Iddcedbe859e86ac4c3f79a53d36237daff86c0db
2024-03-06 14:21:08 +01:00
thiemowmde c02595bb97 Drop obscure error message about an unused group
The message was part of the original patch that introduced the group
feature in 2009, see https://phabricator.wikimedia.org/rECIT75004e33.
Notice how there was never a test scenario for this message. A test
was added in 2020 via I07738cc.

The message appears only in a rare edge-case when a group is entirely
unused in the text, and only when the group is not empty. The shortest
possible example is:

 <references group=g>
 <ref group=g name=a>a</ref>
 </references>

Just adding something unrelated like `<ref group=g>x</ref>` to the
text changes the error message. Now the group is "used". But this
notion is confusing to begin with. References can be part of a group,
and we can use references, but we can't use groups as if they are a
separate entity.

A better error message already exists.

Notice how this special error message doesn't appear anywhere in the
Parsoid code path. That was already using the other, more generic
error message.

Bug: T269531
Change-Id: I63f663d76e45e6c3d664f145d9a564ee00ff53cd
2024-03-04 13:04:36 +01:00
thiemowmde e5eee2d049 Fix confusing error message with empty group
This is about the error message that currently says:

 »Cite error: <ref> tag with name "a" defined in <references> has
  group attribute "" which does not appear in prior text.«

This is a special error message that appears only when a group name
does not appear anywhere in the text. In all other cases a simpler
error message is shown:

 »Cite error: <ref> tag with name "a" defined in <references> is
  not used in prior text.«

While the first error message is not wrong in the edge-case
described in T269531, it's very confusing for a multitude of
reasons. For example:
* There is no group attribute in the wikitext.
* Just adding something completely unrelated like `<ref>x</ref>` to
  the text shows the other error message.

The reason for this behavior is that the assumed default is an empty
`group=""`. The error message changes the moment any other <ref> in
the same group appears in the text vs. when the group is entirely
unused.

We can probably remove this error message entirely, but should at
least not use it when there is no group.

Notice how the Parsoid code path was already using the other error
message.

Bug: T269531
Change-Id: Ifa2e97254f4cda72233a057d8760fb1116143552
2024-03-04 12:43:26 +01:00
jenkins-bot 46499cd9c0 Merge "Rename ReferencesFormatter to ReferenceListFormatter" 2024-02-07 18:00:04 +00:00
thiemowmde 7c75d44b8a Rename ReferencesFormatter to ReferenceListFormatter
I always found the name a little ambiguous. The fact that it outputs
an actual HTML list and not just some "references" – whatever that
means – is relevant, in my opinion.

Change-Id: I0d169455c8d2b42d62da4dccb8376c09fb6902bc
2024-02-07 18:20:02 +01:00
thiemowmde 5eea8ebd90 Simplify ErrorReporter PHPUnit test setup
This was slightly overengineered ever since I4b1f890 and slowly became
more and more complicated over time, notably when withConsecutive was
replaced in Icb951b4. Turns out this was never really needed. It's
impossible to get more than one tracking category from this code path.

While we might add more tracking categories later that will most
probably not happen in this code path.

Change-Id: Ie32d17bac8d3518c985b18f83a846c3fb2bd053f
2024-02-01 17:28:44 +01:00
Subramanya Sastry 15f5cc71be Add dummy html/parsoid sections for three failing tests
* This is to worka round some confusing html2html failures in CI
  for these tests (that are not reproducible locally for me).

Change-Id: I07725155ef5e04eb4346a90c34cbacbd70e88ea6
2024-01-26 23:56:41 -06:00
jenkins-bot b4d8b9ccc6 Merge "Enable all Parsoid test modes for citeParserTests.txt" 2024-01-26 23:18:46 +00:00
Subramanya Sastry b3dff81b6d Enable all Parsoid test modes for citeParserTests.txt
* Updated the known failures file.

Depends-On: I093aeed933fe5927e031c879d48e0191e8ef4685
Depends-On: I0df36653de4c70c7a4669b874f43385a18ac5e9d
Depends-On: Id81e2f4331ce73145389e717b7c78f49b29743bf
Depends-On: I7fb86778cfb674ecc76f748786fa08d8f6ac9c65
Change-Id: I101564587dc7959cd620f0b2cc4f8e436bfba6da
2024-01-25 22:11:49 +00:00
jenkins-bot 53bc13024b Merge "Cypress Improvements" 2024-01-25 15:26:54 +00:00
jenkins-bot abb007b133 Merge "Ensure CiteParsoidTest registers our Cite implementation" 2024-01-24 20:33:11 +00:00
C. Scott Ananian 129b222e97 Ensure CiteParsoidTest registers our Cite implementation
These tests pass today because Parsoid is providing an
alternative implementation of Cite, but that means this
test case isn't actually testing the code in this repo.

Bug: T354215
Change-Id: I42521026bab36035ae5eded7c05716234a5a29ea
2024-01-24 20:09:36 +00:00
mareikeheuer 2fac0fca74 Cypress Improvements
General improvements
Ensure proper module loading in Cypress tests to prevent failures by waiting for specific modules to be loaded
Delete the selenium test suite.

Bug: T353436
Change-Id: Ieb71b122d3c6513f1a15d6574967e2bb9c21a393
2024-01-24 12:01:10 +01:00
thiemowmde 80c8eaf3ce Convert (almost) all .css files to .less
Intentionally no other change is made (yet). This is for a later,
separate patch.

Intentionally not touching the huge list of per-language
ext.cite.style.*.css files for the moment. Again, I would prefer to
do this in a separate patch.

Change-Id: I4e392c7bd1c69849a6c7946676a64c749ddbcd60
2024-01-21 15:39:08 +01:00
Umherirrender e3bbe96939 Stop writing to tablesUsed in tests
Bug: T351733
Change-Id: I2d9d7f5358b6d370a904305a0d9e152375a5aaf9
2024-01-20 12:23:34 +01:00
Subramanya Sastry ff699c31aa Sync up Cite repo with Parsoid
This now aligns with Parsoid commit a8db16f33a638931f91ba75d639bb9d661cb979b

Change-Id: Ibd53e38121231a3501dbbfce1c1e1db370740c0b
2024-01-19 12:24:59 -06:00
C. Scott Ananian 234da84418 Hook up Parsoid implementation of Cite
This commit also moves certain parser tests involving <ref> from
the Parsoid repo to citeParserTests.txt in this repo.

Bug: T354215
Change-Id: Ie5b211d2af01a56684473723c68a9ab2775542e3
2024-01-19 11:57:11 -05:00
jenkins-bot cf776d8ce0 Merge "Documenting state of subref reuse rollback" 2024-01-10 12:55:20 +00:00
jenkins-bot 04e1dc66f7 Merge "Move extendsCount into parent ref item" 2024-01-10 11:53:11 +00:00
Adam Wight c36d1b90a5 Move extendsCount into parent ref item
Eliminates a complex shared structure in favor of more encapsulation.

Change-Id: I70efabf0ee263ac578472e16dc35047b0601b7ff
2024-01-10 11:55:16 +01:00
Adam Wight e4b964eec7 Documenting state of subref reuse rollback
Some interesting stuff is happening, seems to have revealed bugs:
* Rolled-back warnings are still present on the ref
* Subref reuse numbering starts at 0 instead of 1, and formatting is cringe.

But subref rollback does seem to work!

Change-Id: If6321b34d27370553ba85e63dd1e2ae6a3b7c099
2024-01-09 18:05:05 +01:00
thiemowmde 9f6dd63ef4 Don't search for [[MediaWiki:cite_link_label_group-]]
Such a message shouldn't exist, and doesn't:
https://global-search.toolforge.org/?q=.&regex=1&namespaces=8&title=Cite+link+label+group-

Additional notes:
* Rename the method to make it more obvious that it's not a cheap
  getter, but doing something slightly more expensive.
* Use more appropriate array_key_exists to check if a cache entry
  already exists.
* Also add a bit more documentation.

Bug: T297430
Bug: T353227
Change-Id: Ia5827bbf6fd700b87a749aac17320796428f0688
2024-01-09 17:00:07 +01:00
Adam Wight 0e01e39061 Encapsulate ref: groupRefs returned as objects
This patch only affects the consumers of groupRefs.

Bug: T353451
Change-Id: I1eff735dbc26dda07aa8ac7af9ea4ddc0906f5a4
2024-01-09 10:22:04 +01:00
Adam Wight f148c65078 Encapsulate ref: pushRef returns an object
This patch affects a few methods which use the output of pushRef.

Bug: T353451
Change-Id: I10b3fe89406c11cdaede92f18a4b96586ecaf5a0
2024-01-09 10:18:57 +01:00
Adam Wight 262fbe24eb Encapsulate ref object: limited to ReferenceStack
This encapsulation gives us field name, type validation and code
documentation.

This patch only affects ReferenceStack and continues to return
approximately the same array outputs to callers.  Some additional
information is included and the placeholder column has a new name.

Bug: T353451
Change-Id: I405fe7ac241f6991fd4c526bfbb58fbc34f2e147
2024-01-09 09:59:16 +01:00
Adam Wight 1434dc5ca6 Switch to a 1-based "count"
The previous patch deprecated the last conditional depending on magic
meanings of 0 and -1, so now we're free to let "count" take on a more
natural meaning: the number of times a footnote mark appears in
article text.

Includes a small hack to avoid changing parser output, by
artificially decrementing the count by one during rendering.  The
hack can be removed and test output updated in a separate patch.

Bug: T353227
Change-Id: I6f76c50357b274ff97321533e52f435798048268
2024-01-08 11:45:36 +01:00
Adam Wight 86edddc8c2 Use semantic field to test ref type
Stop relying on the magic number distinction between "count" = 0 and -1,
by explicitly testing the "name" field instead.

Bug: T353227
Change-Id: I9dce16b01814e19f508d45b927de570049f0e0f5
2024-01-06 16:46:56 +01:00
Arlo Breault fa5100fa92 Sync up Cite repo with Parsoid
This now aligns with Parsoid commit 285e5e390af1c9370203bb3f6111f01fd41d3009

Change-Id: I9311cd580b938d4dabc43f4a659fb49243f22783
2024-01-05 14:30:56 -05:00
jenkins-bot 0071289f79 Merge "Inline constant for "placeholder" key" 2024-01-05 11:53:19 +00:00
jenkins-bot 0f4c90cc54 Merge "Store group in ref items" 2024-01-05 11:53:17 +00:00