diff --git a/tests/food-market.IntegrationTests/InventoryPostUnpostTests.cs b/tests/food-market.IntegrationTests/InventoryPostUnpostTests.cs index 3213cb1..5d06154 100644 --- a/tests/food-market.IntegrationTests/InventoryPostUnpostTests.cs +++ b/tests/food-market.IntegrationTests/InventoryPostUnpostTests.cs @@ -53,7 +53,9 @@ public async Task Create_loads_book_qty_post_applies_diff_to_stock() var lineP1 = lines.First(l => l.GetProperty("productId").GetString() == p1); lineP1.GetProperty("bookQty").GetDecimal().Should().Be(10m); - lineP1.GetProperty("actualQty").GetDecimal().Should().Be(0m); + // Авто-загруженные строки «посчитаны по учёту»: ActualQty = BookQty, Diff = 0 + // (чтобы проведение не обнуляло непересчитанные позиции — см. 839fcaf). + lineP1.GetProperty("actualQty").GetDecimal().Should().Be(10m); // Вносим фактические: 12 шт p1 (излишек +2), 3 шт p2 (недостача -2). var put = await api.Http.PutAsJsonAsync($"/api/inventory/inventories/{invId}", new @@ -142,7 +144,7 @@ public async Task CancelResults_then_repost_restores_stock_to_actual() } [Fact] - public async Task Post_rejected_if_no_diffs() + public async Task Post_with_no_diffs_is_noop() { var api = new ApiActor(_factory.CreateClient()); await api.SignupAndLoginAsync($"inv-nodiff-{Guid.NewGuid():N}"); @@ -166,7 +168,8 @@ public async Task Post_rejected_if_no_diffs() var inv = await create.Content.ReadFromJsonAsync(); var invId = inv.GetProperty("id").GetString(); - // Фактическое = учётному (3 == 3, diff = 0). + // Фактическое = учётному (3 == 3, diff = 0): проведение завершает + // инвентаризацию, но НЕ создаёт документов и НЕ меняет остаток. await api.Http.PutAsJsonAsync($"/api/inventory/inventories/{invId}", new { date = DateTime.UtcNow, storeId = refs.StoreId, notes = "no-diff", @@ -174,7 +177,10 @@ public async Task Post_rejected_if_no_diffs() }); using var post = await api.Http.PostAsJsonAsync($"/api/inventory/inventories/{invId}/post", new { }); - ((int)post.StatusCode).Should().Be(400); + post.IsSuccessStatusCode.Should().BeTrue($"post при нулевых расхождениях: {(int)post.StatusCode} {await post.Content.ReadAsStringAsync()}"); + (await api.StockOfAsync(refs.StoreId, p1)).Should().Be(3m, "без расхождений остаток не меняется"); + var invGet = await (await api.Http.GetAsync($"/api/inventory/inventories/{invId}")).Content.ReadFromJsonAsync(); + invGet.GetProperty("related").EnumerateArray().Should().BeEmpty("без расхождений связанные документы не создаются"); } [Fact]