From 365dc5c1a86112252b013801414ead516d9da748 Mon Sep 17 00:00:00 2001 From: nns Date: Fri, 9 Oct 2026 01:27:14 +0500 Subject: [PATCH] =?UTF-8?q?test(inventory):=20=D0=BE=D0=B1=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D1=83=D1=81=D1=82=D0=B0=D1=80?= =?UTF-8?q?=D0=B5=D0=B2=D1=88=D0=B8=D0=B5=20=D0=B0=D1=81=D1=81=D0=B5=D1=80?= =?UTF-8?q?=D1=82=D1=8B=20(ActualQty=3DBookQty,=20no-diff=20post=20=3D=20n?= =?UTF-8?q?o-op)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit После рефактора модели МойСклада (839fcaf) авто-загруженные строки получают ActualQty=BookQty (а не 0), и проведение без расхождений — no-op (204, без документов, остаток не меняется). Обновил два устаревших ассерта + все 4 теста InventoryPostUnpostTests зелёные (вкл. cancel-results). Co-Authored-By: Claude Opus 5.5 --- .../InventoryPostUnpostTests.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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]