From 3d270bbb3e546db7ff6a5fa44aed72e743b7b66b Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Sat, 28 Jan 2023 12:39:14 -0500 Subject: [PATCH] add a test for jobs with setPreference: false (#13182) --- .../Tests/Station/StationJobsTest.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Content.IntegrationTests/Tests/Station/StationJobsTest.cs b/Content.IntegrationTests/Tests/Station/StationJobsTest.cs index d881ed217d..c47619d478 100644 --- a/Content.IntegrationTests/Tests/Station/StationJobsTest.cs +++ b/Content.IntegrationTests/Tests/Station/StationJobsTest.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Content.Server.Maps; using Content.Server.Station.Systems; using Content.Shared.Preferences; +using Content.Shared.Roles; using NUnit.Framework; using Robust.Shared.GameObjects; using Robust.Shared.Log; @@ -188,6 +189,40 @@ public sealed class StationJobsTest }); await pairTracker.CleanReturnAsync(); } + + [Test] + public async Task InvalidRoundstartJobsTest() + { + await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes}); + var server = pairTracker.Pair.Server; + + var prototypeManager = server.ResolveDependency(); + + await server.WaitAssertion(() => + { + // invalidJobs contains all the jobs which can't be set for preference: + // i.e. all the jobs that shouldn't be available round-start. + var invalidJobs = new HashSet(); + foreach (var job in prototypeManager.EnumeratePrototypes()) + { + if (!job.SetPreference) + invalidJobs.Add(job.ID); + } + + foreach (var gameMap in prototypeManager.EnumeratePrototypes()) + { + foreach (var (stationId, station) in gameMap.Stations) + { + foreach (var job in station.AvailableJobs.Keys) + { + Assert.That(invalidJobs.Contains(job), Is.False, $"Station {stationId} contains job prototype {job} which cannot be present roundstart."); + } + } + } + + }); + await pairTracker.CleanReturnAsync(); + } } internal static class JobExtensions