using Newtonsoft.Json.Linq; using XFEWarframe.Core; using XFEWarframe.Core.Data; using XFEWarframe.Core.Services; using Xunit; namespace XFEWarframe.Tests; public sealed partial class EngineTests { private static JObject RotatingTauAlert(string missionType = "MT_SURVIVAL", string location = "SolNode166", string level = "/Lotus/Levels/Proc/Infestation/InfestedCorpusShipSurvival", string enemy = "/Lotus/Types/Game/EnemySpecs/InfestedSurvivalA") { var row = (JObject)OfficialSample(1793163600000)["Alerts"]![0]!; row["Icon"] = "/Lotus/Interface/Icons/StoreIcons/Resources/Events/Moonflesh.png"; var info = (JObject)row["MissionInfo"]!; info["missionType"] = missionType; info["location"] = location; info["faction"] = "FC_INFESTATION"; info["levelOverride"] = level; info["enemySpec"] = enemy; info["difficulty"] = 1; info["seed"] = 56043; info["descText"] = "/Lotus/Language/TauPrologue/EventAlertTitle"; info["leadersAlwaysAllowed"] = true; if (missionType == "MT_SURVIVAL") info["maxWaveNum"] = 5; return row; } [Theory] [InlineData("MT_SURVIVAL", "SolNode166", "/Lotus/Levels/Proc/Infestation/InfestedCorpusShipSurvival", "/Lotus/Types/Game/EnemySpecs/InfestedSurvivalA")] [InlineData("MT_HIVE", "SolNode162", "/Lotus/Levels/Proc/Infestation/InfestedCorpusShipSabotage", "/Lotus/Types/Game/EnemySpecs/InfestedSquadD")] [InlineData("MT_EXTERMINATION", "SolNode173", "/Lotus/Levels/Proc/Infestation/InfestedCorpusShipExterminate", "/Lotus/Types/Game/EnemySpecs/InfestedSquadD")] public void CurrentOfficialRotatingTauAlertsKeepTheirOriginalSupportedClient(string missionType, string location, string level, string enemy) { // Shapes and rotating values captured from the official 2026-10-28 snapshot. var now = 1793163600000; var world = OfficialSample(now); world["BuildLabel"] = "2026.10.27.13.12"; var alert = RotatingTauAlert(missionType, location, level, enemy); world["Alerts"] = new JArray(alert); var state = new JObject(); OfficialEvents.Store(state, world, now); var minimum = OfficialEventCompatibility.Minimum((JObject)state["officialEvents"]!, "Alerts", alert); Assert.Equal(GameVersion.Parse("2026.10.22.13.12"), minimum); var response = WorldApi.Generate(state, "2026.10.22.13.12", now); Assert.True(JToken.DeepEquals(alert, response["Alerts"]!.Single(x => x.Value("Tag") == "RoadToTauEvent"))); } [Theory] [InlineData("location", "SolNodeUnknownFuture")] [InlineData("missionType", "MT_UNKNOWN_FUTURE")] [InlineData("levelOverride", "/Lotus/Future/UnverifiedLevel")] [InlineData("enemySpec", "/Lotus/Future/UnverifiedEnemy")] [InlineData("extraEnemySpec", "/Lotus/Future/UnverifiedEnemy")] public void RotatingAlertsWithUnverifiedResourcesOrNodesRetainTheirNewBuildRequirement(string field, string value) { var now = 1793163600000; var world = OfficialSample(now); world["BuildLabel"] = "2026.10.27.13.12"; var alert = RotatingTauAlert(); alert["MissionInfo"]![field] = value; world["Alerts"] = new JArray(alert); var state = new JObject(); OfficialEvents.Store(state, world, now); Assert.DoesNotContain(WorldApi.Generate(state, "2026.10.22.13.12", now)["Alerts"]!, x => x.Value("Tag") == "RoadToTauEvent"); Assert.Contains(WorldApi.Generate(state, "2026.10.27.13.12", now)["Alerts"]!, x => x.Value("Tag") == "RoadToTauEvent"); } [Fact] public void RotatingAlertsDoNotBypassExplicitVersionsOrNewRewardDefinitions() { var now = 1793163600000; var world = OfficialSample(now); world["BuildLabel"] = "2026.10.27.13.12"; var explicitVersion = RotatingTauAlert(); explicitVersion["MinBuildLabel"] = "2026.10.27.13.12"; var newReward = RotatingTauAlert(); newReward["MissionInfo"]!["missionReward"]!["countedItems"]![0]!["ItemType"] = "/Lotus/Future/UnverifiedReward"; world["Alerts"] = new JArray(explicitVersion, newReward); var state = new JObject(); OfficialEvents.Store(state, world, now); Assert.DoesNotContain(WorldApi.Generate(state, "2026.10.22.13.12", now)["Alerts"]!, x => x.Value("Tag") == "RoadToTauEvent"); } [Fact] public void CdnHotfixDoesNotHidePreviouslyObservedEventDefinitions() { var now = OfficialClock().Now.ToUnixTimeMilliseconds(); var state = new JObject(); var original = OfficialSample(now); OfficialEvents.Store(state, original, now); var latest = (JObject)original.DeepClone(); latest["BuildLabel"] = "2026.10.27.13.12/new-manifest"; latest["Time"] = now / 1000 + 60; latest["Goals"]![0]!["Count"] = 54; latest["Goals"]![0]!["HealthPct"] = .5478133564m; ((JArray)latest["Goals"]!).Add(new JObject { ["Tag"] = "NewFutureActivity", ["_id"] = Wire.Oid("6ad0ea700000000000000099"), ["ItemType"] = "/Lotus/Future/UnknownResource" }); OfficialEvents.Store(state, latest, now + 60000); var world = WorldApi.Generate(state, OfficialBuild, now + 60000); Assert.Contains(world["Goals"]!, x => x.Value("Tag") == "RoadToTauEvent" && x.Value("Count") == 54); Assert.DoesNotContain(world["Goals"]!, x => x.Value("Tag") == "NewFutureActivity"); Assert.Contains(world["Alerts"]!, x => x.Value("Tag") == "RoadToTauEvent"); } [Fact] public void AChangedResourceDefinitionKeepsItsOwnNewClientRequirement() { var now = OfficialClock().Now.ToUnixTimeMilliseconds(); var state = new JObject(); var world = OfficialSample(now); OfficialEvents.Store(state, world, now); world["BuildLabel"] = "2026.10.27.13.12"; world["Goals"]![0]!["ItemType"] = "/Lotus/Future/DifferentResource"; OfficialEvents.Store(state, world, now); var response = WorldApi.Generate(state, OfficialBuild, now); Assert.DoesNotContain(response["Goals"]!, x => x.Value("Tag") == "RoadToTauEvent"); Assert.Contains(response["Alerts"]!, x => x.Value("Tag") == "RoadToTauEvent"); } [Fact] public void VerifiedOctober22TauContractWorksOnAFreshOctober27Snapshot() { var now = OfficialClock().Now.ToUnixTimeMilliseconds(); var world = OfficialSample(now); var goal = (JObject)world["Goals"]![0]!; goal["Desc"] = "/Lotus/Language/TauPrologue/RoadToTauEventName"; goal["Faction"] = "FC_INFESTATION"; goal["Icon"] = "/Lotus/Interface/Icons/WorldStatePanel/EpochOperationEventBadge.png"; goal["ScoreLocTag"] = "/Lotus/Language/TauPrologue/RoadToTauEventScore"; goal["ToolTip"] = "/Lotus/Language/TauPrologue/RoadToTauShortEventDesc"; world["BuildLabel"] = "2026.10.27.13.12"; var state = new JObject(); OfficialEvents.Store(state, world, now); Assert.Equal(GameVersion.Parse("2026.10.22.13.12"), OfficialEventCompatibility.Minimum((JObject)state["officialEvents"]!, "Goals", goal)); Assert.Contains(WorldApi.Generate(state, "2026.10.22.13.12", now)["Goals"]!, x => x.Value("Tag") == "RoadToTauEvent"); } }