mediawiki-extensions-Discus.../tests/cases/isSingleCommentSignedBy.json
Bartosz Dziewoński 0ecc8a4c05 Improve detecting already signed comments
Previously, we required a signature at the end of the comment.
This was a pretty rough heuristic that did not correctly handle
many comments that we would consider entirely properly signed
in CommentParser (e.g. comments wrapped in formatting like
<small>…</small>, comments with a post-scriptum or in parentheses,
or comments generated by various templates).

Now we process the user input using the same code that adds reply
links, and only add a signature when we detect that there really
isn't a signature (including template-generated), or if the signature
is in the wrong place and would result in the reply link showing up
in the wrong place as well (not at the end of the comment).

Bug: T278442
Bug: T268558
Bug: T278355
Bug: T291421
Bug: T282983
Change-Id: I46b6110af328ebdf93b7dfc2bd941e04391a1599
2022-02-21 21:21:26 +00:00

143 lines
5.1 KiB
JSON

[
{
"msg": "Simple message",
"title": "Talk:A",
"user": "X",
"html": "<p>Foo bar\n</p>",
"expected": false
},
{
"msg": "Simple message [with heading]",
"title": "Talk:A",
"user": "X",
"html": "<h2><span class=\"mw-headline\" id=\"Foo\">Foo</span></h2>\n<p>bar\n</p>",
"expected": false
},
{
"msg": "Simple message [indented]",
"title": "Talk:A",
"user": "X",
"html": "<dl><dd>Foo bar</dd></dl>",
"expected": false
},
{
"msg": "Already signed",
"title": "Talk:A",
"user": "X",
"html": "<p>Foo bar <a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)\n</p>",
"expected": true
},
{
"msg": "Already signed [with heading]",
"title": "Talk:A",
"user": "X",
"html": "<h2><span class=\"mw-headline\" id=\"Foo\">Foo</span></h2>\n<p>bar <a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)\n</p>",
"expected": true
},
{
"msg": "Already signed [indented]",
"title": "Talk:A",
"user": "X",
"html": "<dl><dd>Foo bar <a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)</dd></dl>",
"expected": true
},
{
"msg": "Already signed with hyphens",
"title": "Talk:A",
"user": "X",
"html": "<p>Foo bar --<a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)\n</p>",
"expected": true
},
{
"msg": "Already signed without space",
"title": "Talk:A",
"user": "X",
"html": "<p>Foo bar<a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)\n</p>",
"expected": true
},
{
"msg": "Signed with 5 tildes",
"title": "Talk:A",
"user": "X",
"html": "<p>Foo bar 00:01, 1 January 2020 (UTC)\n</p>",
"expected": false
},
{
"msg": "Signed with 3 tildes",
"title": "Talk:A",
"user": "X",
"html": "<p>Foo bar <a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>)\n</p>",
"expected": false
},
{
"msg": "Already signed by the wrong user",
"title": "Talk:A",
"user": "Y",
"html": "<p>Foo bar <a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)\n</p>",
"expected": false
},
{
"msg": "Already signed (self-link on user talk page)",
"title": "User talk:X",
"user": "X",
"html": "<p>Foo bar <a class=\"mw-selflink selflink\">X</a> 00:01, 1 January 2020 (UTC)\n</p>",
"expected": true
},
{
"msg": "Already signed (not at the end, parentheses)",
"title": "Talk:A",
"user": "X",
"html": "<p>(Foo bar <a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC))\n</p>",
"expected": true
},
{
"msg": "Already signed (not at the end, <small>)",
"title": "Talk:A",
"user": "X",
"html": "<p><small>Foo bar <a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)</small>\n</p>",
"expected": true
},
{
"msg": "Already signed (not at the end, <small>) [indented]",
"title": "Talk:A",
"user": "X",
"html": "<dl><small>Foo bar <a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)</small></dd></dl>",
"expected": true
},
{
"msg": "Already signed (wrapper)",
"title": "Talk:A",
"user": "X",
"html": "<table>\n<tbody><tr>\n<td>Foo bar <a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)\n</td></tr></tbody></table>",
"expected": true
},
{
"msg": "Already signed (multi-line)",
"title": "Talk:A",
"user": "X",
"html": "<p>Foo\n</p><p>bar\n</p><p><a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)\n</p>",
"expected": true
},
{
"msg": "Already signed (multi-line) [indented]",
"title": "Talk:A",
"user": "X",
"html": "<dl><dd>Foo</dd>\n<dd>bar</dd>\n<dd><a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)</dd></dl>",
"expected": true
},
{
"msg": "Already signed (not at the end, multiline)",
"title": "Talk:A",
"user": "X",
"html": "<p>Foo\n</p><p><a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)\n</p><p>bar\n</p>",
"expected": false
},
{
"msg": "Already signed (not at the end, multiline) [indented]",
"title": "Talk:A",
"user": "X",
"html": "<dl><dd>Foo</dd>\n<dd><a href=\"/wiki/User:X\" title=\"User:X\">X</a> (<a href=\"/wiki/User_talk:X\" title=\"User talk:X\">talk</a>) 00:01, 1 January 2020 (UTC)</dd>\n<dd>bar</span></dd></dl>",
"expected": false
}
]