Add test that entity prototypes don't use LocIds for name/description (#38234)
* Add test that entity prototypes don't use LocIds for name/description * Fix violation
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Localization;
|
||||
|
||||
public sealed class EntityPrototypeLocalizationTest
|
||||
{
|
||||
/// <summary>
|
||||
/// An explanation of why LocIds should not be used for entity prototype names/descriptions.
|
||||
/// Appended to the error message when the test is failed.
|
||||
/// </summary>
|
||||
private const string NoLocIdExplanation = "Entity prototypes should not use LocIds for names/descriptions, as localization IDs are automated for entity prototypes. See https://docs.spacestation14.com/en/ss14-by-example/fluent-and-localization.html#localizing-prototypes for more information.";
|
||||
|
||||
/// <summary>
|
||||
/// Checks that no entity prototypes have a LocId as their name or description.
|
||||
/// See <see href="https://docs.spacestation14.com/en/ss14-by-example/fluent-and-localization.html#localizing-prototypes"/> for why this is important.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestNoManualEntityLocStrings()
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
var server = pair.Server;
|
||||
var protoMan = server.ProtoMan;
|
||||
var locMan = server.ResolveDependency<ILocalizationManager>();
|
||||
|
||||
var protos = protoMan.EnumeratePrototypes<EntityPrototype>();
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
foreach (var proto in protos)
|
||||
{
|
||||
// Check name
|
||||
if (!string.IsNullOrEmpty(proto.SetName))
|
||||
{
|
||||
Assert.That(locMan.HasString(proto.SetName), Is.False,
|
||||
$"Entity prototype {proto.ID} has a LocId ({proto.SetName}) as a name. {NoLocIdExplanation}");
|
||||
}
|
||||
|
||||
// Check description
|
||||
if (!string.IsNullOrEmpty(proto.SetDesc))
|
||||
{
|
||||
Assert.That(locMan.HasString(proto.SetDesc), Is.False,
|
||||
$"Entity prototype {proto.ID} has a LocId ({proto.SetDesc}) as a description. {NoLocIdExplanation}");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
action-name-mapping-erase = Erase Entity
|
||||
@@ -28,7 +28,7 @@
|
||||
- type: entity
|
||||
parent: BaseMappingAction
|
||||
id: ActionMappingEraser
|
||||
name: action-name-mapping-erase
|
||||
name: Erase Entity
|
||||
components:
|
||||
- type: Action
|
||||
icon: Interface/VerbIcons/delete.svg.192dpi.png
|
||||
|
||||
Reference in New Issue
Block a user