mirror of
https://github.com/discourse/discourse.git
synced 2025-10-03 17:21:20 +08:00
DEV: raise error on deprecated icon name caught on JS in system and qunit tests (#30942)
This PR raises an error on any deprecated icon names being converted by `icon-library.js`, which will result in any deprecated icons introduced in JS-land to fail qunit/system tests. We'll do the same for `svg_sprite.rb` once I've resolved pre-existing deprecated icons in core/plugins that's caught by the same exception logic.
This commit is contained in:
parent
37d1212865
commit
b195b1c8a6
3 changed files with 38 additions and 9 deletions
|
@ -1,7 +1,11 @@
|
|||
import { h } from "virtual-dom";
|
||||
import attributeHook from "discourse/lib/attribute-hook";
|
||||
import deprecated from "discourse/lib/deprecated";
|
||||
import { isDevelopment } from "discourse/lib/environment";
|
||||
import {
|
||||
isDevelopment,
|
||||
isRailsTesting,
|
||||
isTesting,
|
||||
} from "discourse/lib/environment";
|
||||
import escape from "discourse/lib/escape";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
|
@ -147,6 +151,7 @@ function handleDeprecatedIcon(id) {
|
|||
{
|
||||
id: "discourse.fontawesome-6-upgrade",
|
||||
url: "https://meta.discourse.org/t/325349",
|
||||
raiseError: isTesting() || isRailsTesting(),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -189,12 +194,12 @@ registerIconRenderer({
|
|||
}
|
||||
html += ` xmlns="${SVG_NAMESPACE}"><use href="#${id}" /></svg>`;
|
||||
if (params.label) {
|
||||
html += `<span class='sr-only'>${escape(params.label)}</span>`;
|
||||
html += `<span class="sr-only">${escape(params.label)}</span>`;
|
||||
}
|
||||
if (params.title) {
|
||||
html = `<span class="svg-icon-title" title='${escape(
|
||||
html = `<span class="svg-icon-title" title="${escape(
|
||||
i18n(params.title)
|
||||
)}'>${html}</span>`;
|
||||
)}">${html}</span>`;
|
||||
}
|
||||
|
||||
if (params.translatedtitle) {
|
||||
|
@ -207,9 +212,9 @@ registerIconRenderer({
|
|||
}
|
||||
|
||||
if (params.translatedTitle) {
|
||||
html = `<span class="svg-icon-title" title='${escape(
|
||||
html = `<span class="svg-icon-title" title="${escape(
|
||||
params.translatedTitle
|
||||
)}'>${html}</span>`;
|
||||
)}">${html}</span>`;
|
||||
}
|
||||
return html;
|
||||
},
|
||||
|
|
|
@ -6,6 +6,10 @@ import {
|
|||
iconHTML,
|
||||
iconNode,
|
||||
} from "discourse/lib/icon-library";
|
||||
import {
|
||||
disableRaiseOnDeprecation,
|
||||
enableRaiseOnDeprecation,
|
||||
} from "discourse/tests/helpers/raise-on-deprecation";
|
||||
|
||||
module("Unit | Utility | icon-library", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
@ -67,4 +71,24 @@ module("Unit | Utility | icon-library", function (hooks) {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("fa5 remaps throws error", function (assert) {
|
||||
disableRaiseOnDeprecation();
|
||||
assert.throws(
|
||||
() => {
|
||||
iconHTML("adjust");
|
||||
},
|
||||
/Deprecation notice: The icon name "adjust" has been updated to "circle-half-stroke".*\[deprecation id: discourse\.fontawesome-6-upgrade\]/,
|
||||
"throws an error if icon name is deprecated"
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
() => {
|
||||
iconHTML("far-dot-circle");
|
||||
},
|
||||
/Deprecation notice: The icon name "far-dot-circle" has been updated to "far-circle-dot".*\[deprecation id: discourse\.fontawesome-6-upgrade\]/,
|
||||
"throws an error if icon name is deprecated"
|
||||
);
|
||||
enableRaiseOnDeprecation();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -173,7 +173,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::FirstShare
|
||||
b.name = "First Share"
|
||||
b.default_icon = "share-alt"
|
||||
b.default_icon = "share-nodes"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
@ -193,7 +193,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = id
|
||||
b.name = name
|
||||
b.default_icon = "share-alt"
|
||||
b.default_icon = "share-nodes"
|
||||
b.badge_type_id = level
|
||||
b.multiple_grant = true
|
||||
b.target_posts = true
|
||||
|
@ -402,7 +402,7 @@ end
|
|||
Badge.seed do |b|
|
||||
b.id = Badge::FirstEmoji
|
||||
b.name = "First Emoji"
|
||||
b.default_icon = "smile"
|
||||
b.default_icon = "face-smile"
|
||||
b.badge_type_id = BadgeType::Bronze
|
||||
b.multiple_grant = false
|
||||
b.target_posts = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue