test(inventory): обновлены устаревшие ассерты (ActualQty=BookQty, no-diff post = no-op)
После рефактора модели МойСклада (839fcaf) авто-загруженные строки получают
ActualQty=BookQty (а не 0), и проведение без расхождений — no-op (204, без
документов, остаток не меняется). Обновил два устаревших ассерта + все 4 теста
InventoryPostUnpostTests зелёные (вкл. cancel-results).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
99e10fa365
commit
365dc5c1a8
|
|
@ -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);
|
var lineP1 = lines.First(l => l.GetProperty("productId").GetString() == p1);
|
||||||
lineP1.GetProperty("bookQty").GetDecimal().Should().Be(10m);
|
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).
|
// Вносим фактические: 12 шт p1 (излишек +2), 3 шт p2 (недостача -2).
|
||||||
var put = await api.Http.PutAsJsonAsync($"/api/inventory/inventories/{invId}", new
|
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]
|
[Fact]
|
||||||
public async Task Post_rejected_if_no_diffs()
|
public async Task Post_with_no_diffs_is_noop()
|
||||||
{
|
{
|
||||||
var api = new ApiActor(_factory.CreateClient());
|
var api = new ApiActor(_factory.CreateClient());
|
||||||
await api.SignupAndLoginAsync($"inv-nodiff-{Guid.NewGuid():N}");
|
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<JsonElement>();
|
var inv = await create.Content.ReadFromJsonAsync<JsonElement>();
|
||||||
var invId = inv.GetProperty("id").GetString();
|
var invId = inv.GetProperty("id").GetString();
|
||||||
|
|
||||||
// Фактическое = учётному (3 == 3, diff = 0).
|
// Фактическое = учётному (3 == 3, diff = 0): проведение завершает
|
||||||
|
// инвентаризацию, но НЕ создаёт документов и НЕ меняет остаток.
|
||||||
await api.Http.PutAsJsonAsync($"/api/inventory/inventories/{invId}", new
|
await api.Http.PutAsJsonAsync($"/api/inventory/inventories/{invId}", new
|
||||||
{
|
{
|
||||||
date = DateTime.UtcNow, storeId = refs.StoreId, notes = "no-diff",
|
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 { });
|
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<JsonElement>();
|
||||||
|
invGet.GetProperty("related").EnumerateArray().Should().BeEmpty("без расхождений связанные документы не создаются");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue