Commit graph

18 commits

Author SHA1 Message Date
Bartosz Dziewoński 33d69e26c9 tests: Fix different whitespace trimming in PHP and JS
Notably, JS trims the no-break space, while PHP doesn't. There are
some other differences that don't come up in our tests. What we really
want is to trim the ASCII whitespace as defined in the HTML spec.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
https://www.php.net/manual/en/function.trim.php
https://infra.spec.whatwg.org/#ascii-whitespace

Change-Id: I95b8fb38878716a2fa7ec84c9f2e8065ebe77c0d
2020-05-14 21:37:26 +00:00
Bartosz Dziewoński c0002be7cd tests: Fix computing ranges in Parsoid documents
In JS tests, we load the documents via mw.template, which apparently
causes the <html>, <head> and <body> tags to disappear, resulting
in the ranges not matching in PHP tests (and the real document).

Put in a big hack that makes them match, and update the JSON files.

Change-Id: I8194752cd5f82c3716c99e76a37226af5d4a0ec1
2020-05-14 01:11:44 +02:00
Ed Sanders 4397bda8cb Modifier: Separate out test data
Change-Id: I63d868a47daebee180c229b424311d10b80d2e89
2020-05-11 16:58:00 +01:00
Ed Sanders 41d5aa1d37 Separate out more data from parser.tests.js
Change-Id: Ib1c3ec30796dd6bff36835e4555b6974e2a5b376
2020-05-08 12:12:11 +01:00
Bartosz Dziewoński 0269626adc Handle &nbsp; and other entities in the timestamp/timezone
Bug: T251838
Change-Id: Iba8d7c71e332c63229eec4bc7c80b10627135784
2020-05-05 22:38:16 +02:00
Bartosz Dziewoński 047e8eb82c Fix inserting replies inside a <pre>
In the future, we should think about a better solution that also
handles other elements (T250126), but this is an easy fix for now.

Bug: T250512
Change-Id: I1321f0da523ddb4a999b8c453b9094a267b38ae2
2020-04-27 23:23:31 +02:00
Bartosz Dziewoński 55b43a70d4 Fix skipping to the end of the paragraph when there is no wrapper
Bug: T249217
Change-Id: I77847901d98f56dbcbcf379c6c17f41e06a3a939
2020-04-03 18:11:59 +00:00
Bartosz Dziewoński a14293c8e7 Remove Parsoid section wrappers before finding transclusions
The section wrappers can be marked as template-affected when the
previous or next section is transcluded, causing comments to be
unnecessarily uneditable. The new test case demonstrates this.

Depends-On: I03bc455d5484a6c51f3fa2397c64936b829fe7e3
Change-Id: I895a04990d79a3475d778b4fef054ea0bb076f0b
2020-03-24 23:31:21 +01:00
Bartosz Dziewoński dab37fd7b4 parser: Make #getTranscludedFrom return page title in text form
It's more convenient for display or comparing it with other things.

Depends-On: I03bc455d5484a6c51f3fa2397c64936b829fe7e3
Change-Id: I88d7aa68977210b16860075ed52983a5e99ee0f7
2020-03-24 22:29:35 +00:00
Bartosz Dziewoński e9b583d1c3 parser: Improve merging multiple comments on one line
Now also works if the "follow-up" comment is wrapped in e.g. `<small>`.

Change-Id: Ic37cb6afdb42021f109a1818f5c4299d907ed094
2020-03-14 13:34:42 +00:00
jenkins-bot 2e0c299a1f Merge "Fix signatureRanges overlapping for some comments" 2020-03-09 20:31:54 +00:00
Bartosz Dziewoński e3e4ef9de4 parser: Detect comments transcluded from another page
When trying to reply to a comment that is inside a transclusion,
detect if it's transcluded from a subpage or simply wrapped in a
template, and show appropriate error messages.

References:
* VisualEditor ve.dm.Converter#getAboutGroup()
* VisualEditor ve.dm.ModelRegistry#matchElement()
* Parsoid Linter#findEnclosingTemplateName()

Bug: T245694
Change-Id: If3dd1ebbf1d02ee4379c200019bfc3a8ec02325b
2020-03-09 20:28:56 +01:00
Bartosz Dziewoński b4029c3c58 Fix signatureRanges overlapping for some comments
If two signatures for a single comment were near each other,
we would sometimes treat them as one huge signature.

Change-Id: Ied4b3aa535a9ca6bebef8a004ae48b7d5a8f2f9b
2020-03-09 13:28:22 +00:00
Bartosz Dziewoński 0ca851aa92 parser: Return signature and timestamp ranges
Currently not used for anything. May be used later for editing
comments (T245225) or reformatting timestamps (T240360).

Note that a comment may have multiple signatures+timestamps,
and we return them all so that you have to deal with that.

Fix some unrelated incorrect documentation comments.

Bug: T245220
Change-Id: I51b8bf4a3bb7968f35e32c7e44c95c2ab079d9ac
2020-03-05 14:28:17 +01:00
Bartosz Dziewoński 606d6b34ec Add reply links at the end of a line, even if the signature is in the middle
Previously they were added at the end of the text node containing the
timestamp, which was usually the end of the line, but not always.

And also fix the same problem for inserting the actual replies (or
reply widgets). This replaces an undocumented hack that prevented our
own reply links from triggering this bug (without it, the reply widget
would be inserted before the reply link rather than after).

While we're here, remove unintentional spacing that appeared before
some reply links, caused by trailing whitespace in text nodes.

Add tests for all of the above.

Bug: T245695
Change-Id: I354b63e2446bb996176a2e3d76abf944127f307e
2020-03-02 21:39:37 +01:00
Bartosz Dziewoński ea26009896 Work around mw.Uri crash on fallback encoding in links
Bug: T245889
Change-Id: I182f9ffa84a3b3cf4afafd536360572eda9d2714
2020-02-29 19:08:01 +01:00
Bartosz Dziewoński e9c401e3aa Ignore LRM and RLM before timezone indicator
They are not generated by MediaWiki, but they often appear when users
sign others' unsigned comments by copy-pasting the timestamp from the
history page.

Add test config data for nlwiki, exported by running this in the
browser console:

  copy(
    JSON.stringify( { wgArticlePath, wgNamespaceIds, wgFormattedNamespaces }, null, 2 ) + '\n' +
    JSON.stringify( mw.loader.moduleRegistry['ext.discussionTools.parser'].packageExports['data.json'], null, 2 )
  );

Bug: T245784
Change-Id: Icbcdc5a028e9ce2cb09173f87769e525ec3082fc
2020-02-25 00:20:00 +00:00
Bartosz Dziewoński 2a93ed11b4 Rearrange test cases
I think directories like this make more sense for adding more test cases.

Depends-On: I9153851fe162c012967fda00d3e1f81964a8dce9
Change-Id: Ibc72b747a75c72643c1fc04eae49bd15656e8104
2020-02-25 00:19:30 +00:00