Files
tbd-station-14/Content.IntegrationTests/Tests/Chemistry/DispenserTest.cs
Kevin Zheng 9394a26245 Add limited-reagent dispensers (#23907)
* Add limited-reagent dispensers

* Add empty versions for all dispensers

* Fix lint

* Set initial window size so all buttons are visible

* Simplify logic, add parenthesis

* Use localized name for initial labels

* Adjust button style

* Avoid touching items before MapInit

* Remove pre-labeling

* Reduce diff

* Clean up YAML

* Fix test

* Really fix test

* Document

* Adjust based on review

* Add labels for obnoxiously long bottles

---------

Co-authored-by: AWF <you@example.com>
2024-01-17 16:43:48 -05:00

47 lines
1.6 KiB
C#

using Content.Client.Chemistry.UI;
using Content.IntegrationTests.Tests.Interaction;
using Content.Shared.Chemistry;
using Content.Server.Chemistry.Components;
using Content.Shared.Containers.ItemSlots;
namespace Content.IntegrationTests.Tests.Chemistry;
public sealed class DispenserTest : InteractionTest
{
/// <summary>
/// Basic test that checks that a beaker can be inserted and ejected from a dispenser.
/// </summary>
[Test]
public async Task InsertEjectBuiTest()
{
await SpawnTarget("ChemDispenser");
ToggleNeedPower();
// Insert beaker
await Interact("Beaker");
Assert.That(Hands.ActiveHandEntity, Is.Null);
// Open BUI
await Interact();
// Eject beaker via BUI.
var ev = new ItemSlotButtonPressedEvent(ReagentDispenserComponent.BeakerSlotId);
await SendBui(ReagentDispenserUiKey.Key, ev);
// Beaker is back in the player's hands
Assert.That(Hands.ActiveHandEntity, Is.Not.Null);
AssertPrototype("Beaker", SEntMan.GetNetEntity(Hands.ActiveHandEntity));
// Re-insert the beaker
await Interact();
Assert.That(Hands.ActiveHandEntity, Is.Null);
// Re-eject using the button directly instead of sending a BUI event. This test is really just a test of the
// bui/window helper methods.
await ClickControl<ReagentDispenserWindow>(nameof(ReagentDispenserWindow.EjectButton));
await RunTicks(5);
Assert.That(Hands.ActiveHandEntity, Is.Not.Null);
AssertPrototype("Beaker", SEntMan.GetNetEntity(Hands.ActiveHandEntity));
}
}