From 033f8444baa9719b8f48f62b3516aea8adc4ebc3 Mon Sep 17 00:00:00 2001 From: "Ignaz \"Ian\" Kraft" Date: Thu, 23 Jan 2025 15:01:45 +0100 Subject: [PATCH] added missing allowed department to the restricted severity (#34558) * added missing allow job to the base restricted severity * no need to make a list * no more linq in ContrabandTest * less nesting in ContrabandTest --- .../Tests/ContrabandTest.cs | 41 +++++++++++++++++++ .../Entities/Objects/base_contraband.yml | 1 + 2 files changed, 42 insertions(+) create mode 100644 Content.IntegrationTests/Tests/ContrabandTest.cs diff --git a/Content.IntegrationTests/Tests/ContrabandTest.cs b/Content.IntegrationTests/Tests/ContrabandTest.cs new file mode 100644 index 0000000000..ebd6afa7ef --- /dev/null +++ b/Content.IntegrationTests/Tests/ContrabandTest.cs @@ -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(); + var componentFactory = client.ResolveDependency(); + + await client.WaitAssertion(() => + { + foreach (var proto in protoMan.EnumeratePrototypes()) + { + if (proto.Abstract || pair.IsTestPrototype(proto)) + continue; + + if (!proto.TryGetComponent(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(); + } +} diff --git a/Resources/Prototypes/Entities/Objects/base_contraband.yml b/Resources/Prototypes/Entities/Objects/base_contraband.yml index 84df2f8b37..7217808807 100644 --- a/Resources/Prototypes/Entities/Objects/base_contraband.yml +++ b/Resources/Prototypes/Entities/Objects/base_contraband.yml @@ -29,6 +29,7 @@ components: - type: Contraband severity: Restricted + allowedDepartments: [ Security ] # one department restricted contraband - type: entity -- 2.51.2