diff --git a/Content.IntegrationTests/Tests/Parkstation/Announcers/AnnouncerFallbackTest.cs b/Content.IntegrationTests/Tests/Parkstation/Announcers/AnnouncerFallbackTest.cs index 17a8ca6b22..6db350cfcf 100644 --- a/Content.IntegrationTests/Tests/Parkstation/Announcers/AnnouncerFallbackTest.cs +++ b/Content.IntegrationTests/Tests/Parkstation/Announcers/AnnouncerFallbackTest.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Linq; using Content.Shared.Parkstation.Announcements.Prototypes; using Robust.Shared.Prototypes; @@ -6,11 +7,13 @@ namespace Content.IntegrationTests.Tests.Parkstation.Announcers; [TestFixture] [TestOf(typeof(AnnouncerPrototype))] -public sealed partial class AnnouncerPrototypeTests +public sealed class AnnouncerPrototypeTests { [Test] public async Task TestAnnouncerFallbacks() { + // Checks if every announcer has a fallback announcement + await using var pair = await PoolManager.GetServerClient(); var server = pair.Server; @@ -18,12 +21,19 @@ public async Task TestAnnouncerFallbacks() await server.WaitAssertion(() => { + var success = true; + var why = new List(); + foreach (var announcer in prototype.EnumeratePrototypes()) { - Assert.That(announcer.Announcements.Any(a => a.ID.ToLower() == "fallback"), - Is.True, - $"Announcer \"{announcer.ID}\" does not have a fallback announcement"); + if (announcer.Announcements.All(a => a.ID.ToLower() != "fallback")) + { + success = false; + why.Add(announcer.ID); + } } + + Assert.That(success, Is.True, $"The following announcers do not have a fallback announcement:\n {string.Join("\n ", why)}"); }); await pair.CleanReturnAsync(); diff --git a/Content.IntegrationTests/Tests/Parkstation/Announcers/AnnouncerLocalizationTest.cs b/Content.IntegrationTests/Tests/Parkstation/Announcers/AnnouncerLocalizationTest.cs new file mode 100644 index 0000000000..10c507e16b --- /dev/null +++ b/Content.IntegrationTests/Tests/Parkstation/Announcers/AnnouncerLocalizationTest.cs @@ -0,0 +1,66 @@ +using System.Collections.Generic; +using Content.Server.Parkstation.Announcements.Systems; +using Content.Server.StationEvents; +using Content.Shared.Parkstation.Announcements.Prototypes; +using Robust.Shared.GameObjects; +using Robust.Shared.Localization; + +namespace Content.IntegrationTests.Tests.Parkstation.Announcers; + +[TestFixture] +[TestOf(typeof(AnnouncerPrototype))] +public sealed class AnnouncerLocalizationTest +{ + [Test] + public async Task TestEventLocalization() + { + // Checks if every station event wanting the announcerSystem to send messages has a localization string + // If an event doesn't have startAnnouncement or endAnnouncement set to true + // it will be expected for that system to handle the announcements if it wants them + + await using var pair = await PoolManager.GetServerClient(); + var server = pair.Server; + + var locale = server.ResolveDependency(); + var entSysMan = server.ResolveDependency(); + var announcer = entSysMan.GetEntitySystem(); + var events = entSysMan.GetEntitySystem(); + + await server.WaitAssertion(() => + { + var succeeded = true; + var why = new List(); + + foreach (var ev in events.AllEvents()) + { + if (ev.Value.StartAnnouncement) + { + var announcementId = announcer.GetAnnouncementId(ev.Key.ID); + var eventLocaleString = announcer.GetEventLocaleString(announcementId); + + if (locale.GetString(eventLocaleString) == eventLocaleString) + { + succeeded = false; + why.Add($"\"{announcementId}\": \"{eventLocaleString}\""); + } + } + + if (ev.Value.EndAnnouncement) + { + var announcementId = announcer.GetAnnouncementId(ev.Key.ID, true); + var eventLocaleString = announcer.GetEventLocaleString(announcementId); + + if (locale.GetString(eventLocaleString) == eventLocaleString) + { + succeeded = false; + why.Add($"\"{announcementId}\": \"{eventLocaleString}\""); + } + } + } + + Assert.That(succeeded, Is.True, $"The following announcements do not have a localization string:\n {string.Join("\n ", why)}"); + }); + + await pair.CleanReturnAsync(); + } +}