]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
added missing allowed department to the restricted severity (#34558)
authorIgnaz "Ian" Kraft <ignaz.k@live.de>
Thu, 23 Jan 2025 14:01:45 +0000 (15:01 +0100)
committerGitHub <noreply@github.com>
Thu, 23 Jan 2025 14:01:45 +0000 (09:01 -0500)
* added missing allow job to the base restricted severity

* no need to make a list

* no more linq in ContrabandTest

* less nesting in ContrabandTest

Content.IntegrationTests/Tests/ContrabandTest.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Objects/base_contraband.yml

diff --git a/Content.IntegrationTests/Tests/ContrabandTest.cs b/Content.IntegrationTests/Tests/ContrabandTest.cs
new file mode 100644 (file)
index 0000000..ebd6afa
--- /dev/null
@@ -0,0 +1,41 @@
+using Content.Shared.Contraband;
+using Robust.Shared.GameObjects;
+using Robust.Shared.Prototypes;
+
+namespace Content.IntegrationTests.Tests;
+
+[TestFixture]
+public sealed class ContrabandTest
+{
+    [Test]
+    public async Task EntityShowDepartmentsAndJobs()
+    {
+        await using var pair = await PoolManager.GetServerClient();
+        var client = pair.Client;
+        var protoMan = client.ResolveDependency<IPrototypeManager>();
+        var componentFactory = client.ResolveDependency<IComponentFactory>();
+
+        await client.WaitAssertion(() =>
+        {
+            foreach (var proto in protoMan.EnumeratePrototypes<EntityPrototype>())
+            {
+                if (proto.Abstract || pair.IsTestPrototype(proto))
+                    continue;
+
+                if (!proto.TryGetComponent<ContrabandComponent>(out var contraband, componentFactory))
+                    continue;
+
+                Assert.That(protoMan.TryIndex(contraband.Severity, out var severity, false),
+                    @$"{proto.ID} has a ContrabandComponent with a unknown severity.");
+
+                if (!severity.ShowDepartmentsAndJobs)
+                    continue;
+
+                Assert.That(contraband.AllowedDepartments.Count + contraband.AllowedJobs.Count, Is.Not.EqualTo(0),
+                    @$"{proto.ID} has a ContrabandComponent with ShowDepartmentsAndJobs but no allowed departments or jobs.");
+            }
+        });
+
+        await pair.CleanReturnAsync();
+    }
+}
index 84df2f8b37ed77095e2a9659712c0d7f95181db8..721780880775e50465c30bbb9026f8b7b6afd8b4 100644 (file)
@@ -29,6 +29,7 @@
   components:
   - type: Contraband
     severity: Restricted
+    allowedDepartments: [ Security ]
 
 # one department restricted contraband
 - type: entity