Fix and enable TestEmptyLoadout (#29228)
* Fix and enabled TestEmptyLoadout * Fine, have a real name
This commit is contained in:
@@ -1,15 +1,52 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using Content.Server.Station.Systems;
|
using Content.Server.Station.Systems;
|
||||||
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Preferences;
|
using Content.Shared.Preferences;
|
||||||
using Content.Shared.Preferences.Loadouts;
|
using Content.Shared.Preferences.Loadouts;
|
||||||
using Content.Shared.Roles.Jobs;
|
using Content.Shared.Roles.Jobs;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.IntegrationTests.Tests.Preferences;
|
namespace Content.IntegrationTests.Tests.Preferences;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
[Ignore("HumanoidAppearance crashes upon loading default profiles.")]
|
|
||||||
public sealed class LoadoutTests
|
public sealed class LoadoutTests
|
||||||
{
|
{
|
||||||
|
[TestPrototypes]
|
||||||
|
private const string Prototypes = @"
|
||||||
|
- type: playTimeTracker
|
||||||
|
id: PlayTimeLoadoutTester
|
||||||
|
|
||||||
|
- type: loadout
|
||||||
|
id: TestJumpsuit
|
||||||
|
equipment: TestJumpsuit
|
||||||
|
|
||||||
|
- type: startingGear
|
||||||
|
id: TestJumpsuit
|
||||||
|
equipment:
|
||||||
|
jumpsuit: ClothingUniformJumpsuitColorGrey
|
||||||
|
|
||||||
|
- type: loadoutGroup
|
||||||
|
id: LoadoutTesterJumpsuit
|
||||||
|
name: generic-unknown
|
||||||
|
loadouts:
|
||||||
|
- TestJumpsuit
|
||||||
|
|
||||||
|
- type: roleLoadout
|
||||||
|
id: JobLoadoutTester
|
||||||
|
groups:
|
||||||
|
- LoadoutTesterJumpsuit
|
||||||
|
|
||||||
|
- type: job
|
||||||
|
id: LoadoutTester
|
||||||
|
playTimeTracker: PlayTimeLoadoutTester
|
||||||
|
";
|
||||||
|
|
||||||
|
private readonly Dictionary<string, EntProtoId> _expectedEquipment = new()
|
||||||
|
{
|
||||||
|
["jumpsuit"] = "ClothingUniformJumpsuitColorGrey"
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks that an empty loadout still spawns with default gear and not naked.
|
/// Checks that an empty loadout still spawns with default gear and not naked.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -26,19 +63,39 @@ public sealed class LoadoutTests
|
|||||||
|
|
||||||
// Check that an empty role loadout spawns gear
|
// Check that an empty role loadout spawns gear
|
||||||
var stationSystem = entManager.System<StationSpawningSystem>();
|
var stationSystem = entManager.System<StationSpawningSystem>();
|
||||||
|
var inventorySystem = entManager.System<InventorySystem>();
|
||||||
var testMap = await pair.CreateTestMap();
|
var testMap = await pair.CreateTestMap();
|
||||||
|
|
||||||
// That's right I can't even spawn a dummy profile without station spawning / humanoidappearance code crashing.
|
await server.WaitAssertion(() =>
|
||||||
|
{
|
||||||
var profile = new HumanoidCharacterProfile();
|
var profile = new HumanoidCharacterProfile();
|
||||||
|
|
||||||
profile.SetLoadout(new RoleLoadout("TestRoleLoadout"));
|
profile.SetLoadout(new RoleLoadout("LoadoutTester"));
|
||||||
|
|
||||||
stationSystem.SpawnPlayerMob(testMap.GridCoords, job: new JobComponent()
|
var tester = stationSystem.SpawnPlayerMob(testMap.GridCoords, job: new JobComponent()
|
||||||
{
|
{
|
||||||
// Sue me, there's so much involved in setting up jobs
|
Prototype = "LoadoutTester"
|
||||||
Prototype = "CargoTechnician"
|
|
||||||
}, profile, station: null);
|
}, profile, station: null);
|
||||||
|
|
||||||
|
var slotQuery = inventorySystem.GetSlotEnumerator(tester);
|
||||||
|
var checkedCount = 0;
|
||||||
|
while (slotQuery.NextItem(out var item, out var slot))
|
||||||
|
{
|
||||||
|
// Make sure the slot is valid
|
||||||
|
Assert.That(_expectedEquipment.TryGetValue(slot.Name, out var expectedItem), $"Spawned item in unexpected slot: {slot.Name}");
|
||||||
|
|
||||||
|
// Make sure that the item is the right one
|
||||||
|
var meta = entManager.GetComponent<MetaDataComponent>(item);
|
||||||
|
Assert.That(meta.EntityPrototype.ID, Is.EqualTo(expectedItem.Id), $"Spawned wrong item in slot {slot.Name}!");
|
||||||
|
|
||||||
|
checkedCount++;
|
||||||
|
}
|
||||||
|
// Make sure the number of items is the same
|
||||||
|
Assert.That(checkedCount, Is.EqualTo(_expectedEquipment.Count), "Number of items does not match expected!");
|
||||||
|
|
||||||
|
entManager.DeleteEntity(tester);
|
||||||
|
});
|
||||||
|
|
||||||
await pair.CleanReturnAsync();
|
await pair.CleanReturnAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user