Add interaction tests (#15251)

This commit is contained in:
Leon Friedrich
2023-04-15 07:41:25 +12:00
committed by GitHub
parent ffe946729f
commit 489660a6bb
36 changed files with 2354 additions and 32 deletions

View File

@@ -0,0 +1,69 @@
using System.Threading.Tasks;
using Content.IntegrationTests.Tests.Interaction;
using Content.Server.Power.Components;
using Content.Shared.Wires;
using NUnit.Framework;
using Robust.Shared.GameObjects;
namespace Content.IntegrationTests.Tests.Construction.Interaction;
public sealed class PanelScrewing : InteractionTest
{
[Test]
public async Task ApcPanel()
{
await SpawnTarget("APCBasic");
var comp = Comp<ApcComponent>();
// Open & close panel
Assert.That(comp.IsApcOpen, Is.False);
await Interact(Screw);
Assert.That(comp.IsApcOpen, Is.True);
await Interact(Screw);
Assert.That(comp.IsApcOpen, Is.False);
// Interrupted DoAfters
await Interact(Screw, awaitDoAfters: false);
await CancelDoAfters();
Assert.That(comp.IsApcOpen, Is.False);
await Interact(Screw);
Assert.That(comp.IsApcOpen, Is.True);
await Interact(Screw, awaitDoAfters: false);
await CancelDoAfters();
Assert.That(comp.IsApcOpen, Is.True);
await Interact(Screw);
Assert.That(comp.IsApcOpen, Is.False);
}
// Test wires panel on both airlocks & tcomms servers. These both use the same component, but comms may have
// conflicting interactions due to encryption key removal interactions.
[Test]
[TestCase("Airlock")]
[TestCase("TelecomServerFilled")]
public async Task WiresPanelScrewing(string prototype)
{
await SpawnTarget(prototype);
var comp = Comp<WiresPanelComponent>();
// Open & close panel
Assert.That(comp.Open, Is.False);
await Interact(Screw);
Assert.That(comp.Open, Is.True);
await Interact(Screw);
Assert.That(comp.Open, Is.False);
// Interrupted DoAfters
await Interact(Screw, awaitDoAfters: false);
await CancelDoAfters();
Assert.That(comp.Open, Is.False);
await Interact(Screw);
Assert.That(comp.Open, Is.True);
await Interact(Screw, awaitDoAfters: false);
await CancelDoAfters();
Assert.That(comp.Open, Is.True);
await Interact(Screw);
Assert.That(comp.Open, Is.False);
}
}