tests: Adjust mw-parser-output div for new attributes lang/dir

Add in core with d0a96db0

Follow-Up: Ib130a055e46764544af0f1a46d2bc2b3a7ee85b7
Change-Id: I016093b732fc8c44901632c4d63608c5af41cda5
This commit is contained in:
Umherirrender 2023-11-06 20:43:49 +01:00
parent b5ab3bac24
commit 8ef8014843

View file

@ -194,61 +194,61 @@ class TemplateStylesHooksTest extends MediaWikiLangTestCase {
$popt, [], $popt, [],
'<templatestyles />', '<templatestyles />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"templatestyles-test\"><p><strong class=\"error\">TemplateStyles' <code>src</code> attribute must not be empty.</strong>\n</p></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"><p><strong class=\"error\">TemplateStyles' <code>src</code> attribute must not be empty.</strong>\n</p></div>",
], ],
'Tag with invalid src' => [ 'Tag with invalid src' => [
$popt, [], $popt, [],
'<templatestyles src="Test&lt;&gt;" />', '<templatestyles src="Test&lt;&gt;" />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"templatestyles-test\"><p><strong class=\"error\">Invalid title for TemplateStyles' <code>src</code> attribute.</strong>\n</p></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"><p><strong class=\"error\">Invalid title for TemplateStyles' <code>src</code> attribute.</strong>\n</p></div>",
], ],
'Tag with valid but nonexistent title' => [ 'Tag with valid but nonexistent title' => [
$popt, [], $popt, [],
'<templatestyles src="ThisDoes\'\'\'Not\'\'\'Exist" />', '<templatestyles src="ThisDoes\'\'\'Not\'\'\'Exist" />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"templatestyles-test\"><p><strong class=\"error\">Page <a href=\"/index.php?title=Template:ThisDoes%27%27%27Not%27%27%27Exist&amp;action=edit&amp;redlink=1\" class=\"new\" title=\"Template:ThisDoes&#39;&#39;&#39;Not&#39;&#39;&#39;Exist (page does not exist)\">Template:ThisDoes&#39;&#39;&#39;Not&#39;&#39;&#39;Exist</a> has no content.</strong>\n</p></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"><p><strong class=\"error\">Page <a href=\"/index.php?title=Template:ThisDoes%27%27%27Not%27%27%27Exist&amp;action=edit&amp;redlink=1\" class=\"new\" title=\"Template:ThisDoes&#39;&#39;&#39;Not&#39;&#39;&#39;Exist (page does not exist)\">Template:ThisDoes&#39;&#39;&#39;Not&#39;&#39;&#39;Exist</a> has no content.</strong>\n</p></div>",
], ],
'Tag with valid but nonexistent title, main namespace' => [ 'Tag with valid but nonexistent title, main namespace' => [
$popt, [], $popt, [],
'<templatestyles src=":ThisDoes\'\'\'Not\'\'\'Exist" />', '<templatestyles src=":ThisDoes\'\'\'Not\'\'\'Exist" />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"templatestyles-test\"><p><strong class=\"error\">Page <a href=\"/index.php?title=ThisDoes%27%27%27Not%27%27%27Exist&amp;action=edit&amp;redlink=1\" class=\"new\" title=\"ThisDoes&#39;&#39;&#39;Not&#39;&#39;&#39;Exist (page does not exist)\">ThisDoes&#39;&#39;&#39;Not&#39;&#39;&#39;Exist</a> has no content.</strong>\n</p></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"><p><strong class=\"error\">Page <a href=\"/index.php?title=ThisDoes%27%27%27Not%27%27%27Exist&amp;action=edit&amp;redlink=1\" class=\"new\" title=\"ThisDoes&#39;&#39;&#39;Not&#39;&#39;&#39;Exist (page does not exist)\">ThisDoes&#39;&#39;&#39;Not&#39;&#39;&#39;Exist</a> has no content.</strong>\n</p></div>",
], ],
'Tag with wikitext page' => [ 'Tag with wikitext page' => [
$popt, [], $popt, [],
'<templatestyles src="TemplateStyles test/wikitext" />', '<templatestyles src="TemplateStyles test/wikitext" />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"templatestyles-test\"><p><strong class=\"error\">Page <a href=\"/wiki/Template:TemplateStyles_test/wikitext\" title=\"Template:TemplateStyles test/wikitext\">Template:TemplateStyles test/wikitext</a> must have content model \"Sanitized CSS\" for TemplateStyles (current model is \"wikitext\").</strong>\n</p></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"><p><strong class=\"error\">Page <a href=\"/wiki/Template:TemplateStyles_test/wikitext\" title=\"Template:TemplateStyles test/wikitext\">Template:TemplateStyles test/wikitext</a> must have content model \"Sanitized CSS\" for TemplateStyles (current model is \"wikitext\").</strong>\n</p></div>",
], ],
'Tag with CSS (not sanitized-css) page' => [ 'Tag with CSS (not sanitized-css) page' => [
$popt, [], $popt, [],
'<templatestyles src="TemplateStyles test/nonsanitized.css" />', '<templatestyles src="TemplateStyles test/nonsanitized.css" />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"templatestyles-test\"><p><strong class=\"error\">Page <a href=\"/wiki/Template:TemplateStyles_test/nonsanitized.css\" title=\"Template:TemplateStyles test/nonsanitized.css\">Template:TemplateStyles test/nonsanitized.css</a> must have content model \"Sanitized CSS\" for TemplateStyles (current model is \"CSS\").</strong>\n</p></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"><p><strong class=\"error\">Page <a href=\"/wiki/Template:TemplateStyles_test/nonsanitized.css\" title=\"Template:TemplateStyles test/nonsanitized.css\">Template:TemplateStyles test/nonsanitized.css</a> must have content model \"Sanitized CSS\" for TemplateStyles (current model is \"CSS\").</strong>\n</p></div>",
], ],
'Working tag' => [ 'Working tag' => [
$popt, [], $popt, [],
'<templatestyles src="TemplateStyles test/styles1.css" />', '<templatestyles src="TemplateStyles test/styles1.css" />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"templatestyles-test\"><style data-mw-deduplicate=\"TemplateStyles:r{{REV:styles1.css}}/templatestyles-test\">.templatestyles-test .foo{color:blue}</style></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"><style data-mw-deduplicate=\"TemplateStyles:r{{REV:styles1.css}}/templatestyles-test\">.templatestyles-test .foo{color:blue}</style></div>",
], ],
'Disabled' => [ 'Disabled' => [
$popt, [], $popt, [],
'<templatestyles src="TemplateStyles test/styles1.css" />', '<templatestyles src="TemplateStyles test/styles1.css" />',
"<div class=\"templatestyles-test\"></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"></div>",
[ 'wgTemplateStylesDisable' => true ], [ 'wgTemplateStylesDisable' => true ],
], ],
'Replaced content (which includes sanitization errors)' => [ 'Replaced content (which includes sanitization errors)' => [
$popt, [], $popt, [],
'<templatestyles src="Test replacement" />', '<templatestyles src="Test replacement" />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"templatestyles-test\"><style data-mw-deduplicate=\"TemplateStyles:8fd14043c1cce91e8b9d1487a9d17d8d9ae43890/templatestyles-test\">/*\nErrors processing stylesheet [[:Template:Test replacement]] (rev ):\n• Unrecognized or unsupported property at line 1 character 22.\n*/\n.templatestyles-test .baz{color:orange}</style></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"><style data-mw-deduplicate=\"TemplateStyles:8fd14043c1cce91e8b9d1487a9d17d8d9ae43890/templatestyles-test\">/*\nErrors processing stylesheet [[:Template:Test replacement]] (rev ):\n• Unrecognized or unsupported property at line 1 character 22.\n*/\n.templatestyles-test .baz{color:orange}</style></div>",
], ],
'Hoistable selectors are hoisted' => [ 'Hoistable selectors are hoisted' => [
$popt, [], $popt, [],
'<templatestyles src="TemplateStyles test/styles3.css" />', '<templatestyles src="TemplateStyles test/styles3.css" />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"templatestyles-test\"><style data-mw-deduplicate=\"TemplateStyles:r{{REV:styles3.css}}/templatestyles-test\">html.no-js body.skin-minerva .templatestyles-test .bar{color:yellow}</style></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"><style data-mw-deduplicate=\"TemplateStyles:r{{REV:styles3.css}}/templatestyles-test\">html.no-js body.skin-minerva .templatestyles-test .bar{color:yellow}</style></div>",
], ],
'Still prefixed despite no wrapping class' => [ 'Still prefixed despite no wrapping class' => [
$popt2, [ 'unwrap' => true ], $popt2, [ 'unwrap' => true ],
@ -273,7 +273,7 @@ class TemplateStylesHooksTest extends MediaWikiLangTestCase {
' ), ' ),
// phpcs:disable Generic.Files.LineLength // phpcs:disable Generic.Files.LineLength
trim( ' trim( '
<div class="templatestyles-test"><style data-mw-deduplicate="TemplateStyles:r{{REV:styles1.css}}/templatestyles-test">.templatestyles-test .foo{color:blue}</style> <div class="mw-content-ltr templatestyles-test" lang="en" dir="ltr"><style data-mw-deduplicate="TemplateStyles:r{{REV:styles1.css}}/templatestyles-test">.templatestyles-test .foo{color:blue}</style>
<link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r{{REV:styles1.css}}/templatestyles-test"> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r{{REV:styles1.css}}/templatestyles-test">
<style data-mw-deduplicate="TemplateStyles:r{{REV:styles2.css}}/templatestyles-test">.templatestyles-test .bar{color:green}</style> <style data-mw-deduplicate="TemplateStyles:r{{REV:styles2.css}}/templatestyles-test">.templatestyles-test .bar{color:green}</style>
<link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r{{REV:styles1.css}}/templatestyles-test"> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r{{REV:styles1.css}}/templatestyles-test">
@ -285,19 +285,19 @@ class TemplateStylesHooksTest extends MediaWikiLangTestCase {
$popt2, [], $popt2, [],
'<templatestyles src="TemplateStyles test/styles1.css" wrapper=".foobar" />', '<templatestyles src="TemplateStyles test/styles1.css" wrapper=".foobar" />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"mw-parser-output\"><style data-mw-deduplicate=\"TemplateStyles:r{{REV:styles1.css}}/mw-parser-output/.foobar\">.mw-parser-output .foobar .foo{color:blue}</style></div>", "<div class=\"mw-content-ltr mw-parser-output\" lang=\"en\" dir=\"ltr\"><style data-mw-deduplicate=\"TemplateStyles:r{{REV:styles1.css}}/mw-parser-output/.foobar\">.mw-parser-output .foobar .foo{color:blue}</style></div>",
], ],
'Invalid wrapper parameter' => [ 'Invalid wrapper parameter' => [
$popt, [], $popt, [],
'<templatestyles src="TemplateStyles test/styles1.css" wrapper=".foo .bar" />', '<templatestyles src="TemplateStyles test/styles1.css" wrapper=".foo .bar" />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"templatestyles-test\"><p><strong class=\"error\">Invalid value for TemplateStyles' <code>wrapper</code> attribute.</strong>\n</p></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"><p><strong class=\"error\">Invalid value for TemplateStyles' <code>wrapper</code> attribute.</strong>\n</p></div>",
], ],
'Invalid wrapper parameter (2)' => [ 'Invalid wrapper parameter (2)' => [
$popt, [], $popt, [],
'<templatestyles src="TemplateStyles test/styles1.css" wrapper=".foo/*" />', '<templatestyles src="TemplateStyles test/styles1.css" wrapper=".foo/*" />',
// phpcs:ignore Generic.Files.LineLength // phpcs:ignore Generic.Files.LineLength
"<div class=\"templatestyles-test\"><p><strong class=\"error\">Invalid value for TemplateStyles' <code>wrapper</code> attribute.</strong>\n</p></div>", "<div class=\"mw-content-ltr templatestyles-test\" lang=\"en\" dir=\"ltr\"><p><strong class=\"error\">Invalid value for TemplateStyles' <code>wrapper</code> attribute.</strong>\n</p></div>",
], ],
'Wrapper parameter and proper deduplication' => [ 'Wrapper parameter and proper deduplication' => [
$popt2, [], $popt2, [],
@ -310,7 +310,7 @@ class TemplateStylesHooksTest extends MediaWikiLangTestCase {
' ), ' ),
// phpcs:disable Generic.Files.LineLength // phpcs:disable Generic.Files.LineLength
trim( ' trim( '
<div class="mw-parser-output"><style data-mw-deduplicate="TemplateStyles:r{{REV:styles1.css}}">.mw-parser-output .foo{color:blue}</style> <div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><style data-mw-deduplicate="TemplateStyles:r{{REV:styles1.css}}">.mw-parser-output .foo{color:blue}</style>
<link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r{{REV:styles1.css}}"> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r{{REV:styles1.css}}">
<style data-mw-deduplicate="TemplateStyles:r{{REV:styles1.css}}/mw-parser-output/.foobar">.mw-parser-output .foobar .foo{color:blue}</style> <style data-mw-deduplicate="TemplateStyles:r{{REV:styles1.css}}/mw-parser-output/.foobar">.mw-parser-output .foobar .foo{color:blue}</style>
<style data-mw-deduplicate="TemplateStyles:r{{REV:styles1.css}}/mw-parser-output/.foobaz">.mw-parser-output .foobaz .foo{color:blue}</style> <style data-mw-deduplicate="TemplateStyles:r{{REV:styles1.css}}/mw-parser-output/.foobaz">.mw-parser-output .foobaz .foo{color:blue}</style>