Files
ERP-core/Testing/e2e/specs/stock-adjustments.spec.ts
ImanThiyanga 15ddac178c Refactor production and stock tests to remove UOM dependency
- Updated production.spec.ts, stock-adjustments.spec.ts, and stock-transfers.spec.ts to eliminate UOM references in API seeder and test cases.
- Adjusted ApiSeeder methods to remove UOM parameters from stock receiving and production template creation.
- Revised documentation to reflect changes in UOM handling, emphasizing that stock is counted in base UOM only.
- Introduced new enums for MeasureUnit and StageQtyUnit to clarify content size and stage input quantities.
- Implemented ItemContent service to validate and normalize content sizes.
- Updated smoke tests to validate production stage inputs expressed in content units, ensuring correct consumption calculations.
- Modified frontend UOM label handling to reflect the removal of per-line UOMs in document lines.
2026-08-11 11:32:40 +05:30

64 lines
2.2 KiB
TypeScript

import { test, expect, APIRequestContext } from "@playwright/test"
import { ApiSeeder, newApiContext, Warehouse, Item, Vendor } from "../support/api"
import { StockAdjustmentNewPage } from "../pages/StockPages"
// Stock adjustment flow (Backend/ERPCore/Controllers/StockAdjustmentsController.cs,
// Frontend app/dashboard/stock/adjustments/new): posts immediately, no draft state
// (Backend/ERPCore/Dtos/Stock/AdjustmentDtos.cs - QtyDelta is a signed base-UOM delta).
test.describe("Stock adjustments", () => {
let api: APIRequestContext
let seeder: ApiSeeder
let warehouse: Warehouse
let vendor: Vendor
let item: Item
test.beforeAll(async () => {
api = await newApiContext()
seeder = new ApiSeeder(api)
warehouse = await seeder.firstWarehouse()
vendor = await seeder.createVendor()
item = await seeder.createItem({ namePrefix: "Adjustment Test Item" })
await seeder.receiveStock({
warehouseId: warehouse.warehouseId,
vendorId: vendor.vendorId,
itemId: item.itemId,
qty: 20,
unitCost: 30,
})
})
test.afterAll(async () => {
await api.dispose()
})
test("positive adjustment increases on-hand and shows the posted doc number", async ({ page }) => {
const before = await seeder.stockOnHand(item.itemId, warehouse.warehouseId)
const newPage = new StockAdjustmentNewPage(page)
await newPage.goto()
await newPage.fill({ warehouse: warehouse.name, reasonCode: "System Correction", item: item.name, qtyDelta: 5 })
await newPage.submit()
await newPage.expectPosted()
const after = await seeder.stockOnHand(item.itemId, warehouse.warehouseId)
expect(after.onHand).toBeCloseTo(before.onHand + 5, 4)
})
test("negative adjustment decreases on-hand", async ({ page }) => {
const before = await seeder.stockOnHand(item.itemId, warehouse.warehouseId)
const newPage = new StockAdjustmentNewPage(page)
await newPage.goto()
await newPage.fill({ warehouse: warehouse.name, reasonCode: "Damage", item: item.name, qtyDelta: -3 })
await newPage.submit()
await newPage.expectPosted()
const after = await seeder.stockOnHand(item.itemId, warehouse.warehouseId)
expect(after.onHand).toBeCloseTo(before.onHand - 3, 4)
})
})