using Newtonsoft.Json.Linq; using XFEWarframe.Core; using XFEWarframe.Core.Data; using Xunit; namespace XFEWarframe.Tests; public sealed partial class EngineTests { [Fact] public async Task InventoryPresentationExposesRarityFlawedImposterAndLegacyWithoutChangingIdentity() { var q = await Login(); var catalog = new ItemCatalog().WithLanguage("en"); var examples = new[] { (catalog.Entries.First(x => x.Meta.Value("isStarter")).Type, "starter"), (catalog.Entries.First(x => x.Meta.Value("isFrivolous")).Type, "frivolous"), (LegacyMods.All.Properties().First().Name, "u5mod") }; foreach (var (type, reason) in examples) { var response = await Call("/control/v1/catalog", query: new() { ["q"] = type, ["lang"] = "en" }, admin: true); Assert.Equal(200, response.Status); var row = JObject.Parse(response.Body)["items"]!.Single(x => x.Value("type") == type); Assert.Equal(reason, row["presentation"]!.Value("badReason")); Assert.NotEmpty(row["presentation"]!.Value("warning")!); if (reason == "u5mod") { Assert.Equal(5, row["presentation"]!.Value("legacyVersion")); Assert.EndsWith("(U5)", row.Value("name")); } else Assert.Contains(reason == "starter" ? "Flawed" : "Imposter", row.Value("name")); } const string serration = "/Lotus/Upgrades/Mods/Rifle/WeaponDamageAmountMod"; await Give(q, serration); var before = await RawInventory(q); var view = await ReadEditor(q, "RawUpgrades"); var owned = view["items"]!.Single(x => x.Value("type") == serration); Assert.Equal("UNCOMMON", owned["presentation"]!.Value("rarity")); Assert.NotEmpty(owned["presentation"]!.Value("rarityLabel")!); Assert.True(JToken.DeepEquals(before, await RawInventory(q))); } [Fact] public async Task QuestRowsMatchUpstreamFirstRunReplayStageCompletionAndActiveMarkers() { var q = await Login(); const string type = "/Lotus/Types/Keys/VorsPrize/VorsPrizeQuestKey"; foreach (var (progress, completed, expectedStage, expectedReplays) in new[] { (new JArray(), false, 0, 0), (new JArray(new JObject(), new JObject()), false, 2, 0), (new JArray(new JObject { ["c"] = 1 }, new JObject { ["c"] = 1 }, new JObject()), false, 1, 2), (new JArray(new JObject { ["c"] = 2 }, new JObject { ["c"] = 2 }), true, 1, 3) }) { var patch = new JObject { ["ActiveQuest"] = type, ["QuestKeys"] = new JArray(new JObject { ["ItemType"] = type, ["Completed"] = completed, ["Progress"] = progress }) }; Assert.Equal(200, (await Call($"/control/v1/accounts/{q["accountId"]}/import", new { inventory = patch }, admin: true)).Status); var before = await RawInventory(q); var view = await ReadEditor(q, "QuestKeys"); var summary = view["items"]![0]!["quest"]!; Assert.Equal(expectedStage, summary.Value("stage")); Assert.Equal(expectedReplays, summary.Value("replays")); Assert.Equal(completed, summary.Value("completed")); Assert.True(summary.Value("active")); Assert.True(JToken.DeepEquals(before, await RawInventory(q))); } } [Fact] public async Task PlayerCatalogAndInventoryKeepAnnotationsThroughPagedJsonContract() { var player = await RegisterPlayer(); var token = player.Value("token"); var q = await Login("portal@example.invalid", XFEWarframe.Core.Services.Accounts.GamePassword("PortalTest-123")); var type = new ItemCatalog().Entries.First(x => x.Meta.Value("isStarter")).Type; await Give(q, type); var response = await Portal("inventory", token: token, query: new() { ["lang"] = "en", ["q"] = type }); Assert.Equal(200, response.Status); var row = JObject.Parse(response.Body)["items"]![0]!; Assert.Equal(type, row.Value("type")); Assert.Contains("Flawed", row.Value("tags")); } }