From af2bea7f66a1e482bc14235a81f8f093e43ca83c Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Wed, 27 Aug 2025 16:30:53 -0400 Subject: [PATCH] Add test of disposal unit throw-insert behavior (#39479) * Add test of disposal unit throw-insert behavior * Remove initially-empty check --- .../Disposal/DisposalUnitInteractionTest.cs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Content.IntegrationTests/Tests/Disposal/DisposalUnitInteractionTest.cs diff --git a/Content.IntegrationTests/Tests/Disposal/DisposalUnitInteractionTest.cs b/Content.IntegrationTests/Tests/Disposal/DisposalUnitInteractionTest.cs new file mode 100644 index 0000000000..d4b20a55a8 --- /dev/null +++ b/Content.IntegrationTests/Tests/Disposal/DisposalUnitInteractionTest.cs @@ -0,0 +1,54 @@ +using Content.IntegrationTests.Tests.Interaction; +using Content.Server.Containers; +using Robust.Shared.Containers; +using Robust.Shared.Prototypes; + +namespace Content.IntegrationTests.Tests.Disposal; + +public sealed class DisposalUnitInteractionTest : InteractionTest +{ + private static readonly EntProtoId DisposalUnit = "DisposalUnit"; + private static readonly EntProtoId TrashItem = "BrokenBottle"; + + private const string TestDisposalUnitId = "TestDisposalUnit"; + + [TestPrototypes] + private static readonly string TestPrototypes = $@" +# A modified disposal unit with a 100% chance of a thrown item being inserted +- type: entity + parent: {DisposalUnit.Id} + id: {TestDisposalUnitId} + components: + - type: ThrowInsertContainer + probability: 1 +"; + + /// + /// Spawns a disposal unit, gives the player a trash item, and makes the + /// player throw the item at the disposal unit. + /// After a short delay, verifies that the thrown item is contained inside + /// the disposal unit. + /// + [Test] + public async Task ThrowItemIntoDisposalUnitTest() + { + var containerSys = Server.System(); + + // Spawn the target disposal unit + var disposalUnit = await SpawnTarget(TestDisposalUnitId); + + // Give the player some trash to throw + var trash = await PlaceInHands(TrashItem); + + // Throw the item at the disposal unit + await ThrowItem(); + + // Wait a moment + await RunTicks(10); + + // Make sure the trash is in the disposal unit + var throwInsertComp = Comp(); + var container = containerSys.GetContainer(ToServer(disposalUnit), throwInsertComp.ContainerId); + Assert.That(container.ContainedEntities, Contains.Item(ToServer(trash))); + } +}