b34b0dd7d6
Validators (Pushes and Pull Requests) / UI & Storage Validation (pull_request) Failing after 12s
Validators (Pushes and Pull Requests) / Database & Schema Validation (pull_request) Successful in 13s
Validators (Pushes and Pull Requests) / Core Validators & Database Setup (pull_request) Failing after 28s
Validators (Pushes and Pull Requests) / WBS & Audit Validations (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / .NET Contracts (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / Calibration & Performance (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / Operational Report & Decision Packet (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / CI Workflow Lint (pull_request) Failing after 10s
Validators (Pushes and Pull Requests) / Security & Secrets (pull_request) Successful in 12s
Validators (Pushes and Pull Requests) / Notify PR Results (pull_request) Successful in 2s
Frontend CI Pipeline / ci-frontend-8-steps (pull_request) Failing after 2m50s
112 lines
3.4 KiB
TypeScript
112 lines
3.4 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest'
|
|
import { setActivePinia, createPinia } from 'pinia'
|
|
import { useInventoryStore, useWarehouseStore } from '@/stores'
|
|
|
|
describe('Inventory Workflow Integration Tests', () => {
|
|
beforeEach(() => {
|
|
setActivePinia(createPinia())
|
|
})
|
|
|
|
describe('Stock Management', () => {
|
|
it('should update quantity correctly', async () => {
|
|
const inventoryStore = useInventoryStore()
|
|
|
|
// Initial state
|
|
expect(inventoryStore.totalQuantity).toBe(0)
|
|
|
|
// Update quantity
|
|
await inventoryStore.updateQuantity('item-001', 100)
|
|
expect(inventoryStore.totalQuantity).toBeGreaterThan(0)
|
|
})
|
|
|
|
it('should reserve and release quantity', async () => {
|
|
const inventoryStore = useInventoryStore()
|
|
|
|
// Setup
|
|
await inventoryStore.updateQuantity('item-001', 100)
|
|
const initial = inventoryStore.availableQuantity
|
|
|
|
// Reserve
|
|
await inventoryStore.reserveQuantity('item-001', 30)
|
|
expect(inventoryStore.availableQuantity).toBeLessThan(initial)
|
|
|
|
// Release
|
|
await inventoryStore.releaseQuantity('item-001', 30)
|
|
expect(inventoryStore.availableQuantity).toBe(initial)
|
|
})
|
|
|
|
it('should prevent overselling', async () => {
|
|
const inventoryStore = useInventoryStore()
|
|
|
|
await inventoryStore.updateQuantity('item-001', 50)
|
|
|
|
try {
|
|
await inventoryStore.reserveQuantity('item-001', 100)
|
|
expect.fail('Should throw error')
|
|
} catch (err: any) {
|
|
expect(err.message).toContain('Insufficient')
|
|
}
|
|
})
|
|
|
|
it('should track low stock items', async () => {
|
|
const inventoryStore = useInventoryStore()
|
|
|
|
// Setup low stock
|
|
await inventoryStore.updateQuantity('item-001', 5) // Below reorder level
|
|
|
|
const lowStock = inventoryStore.lowStockItems
|
|
expect(lowStock.length).toBeGreaterThan(0)
|
|
})
|
|
})
|
|
|
|
describe('Warehouse Integration', () => {
|
|
it('should coordinate inventory with warehouses', async () => {
|
|
const inventoryStore = useInventoryStore()
|
|
const warehouseStore = useWarehouseStore()
|
|
|
|
await warehouseStore.fetchWarehouses()
|
|
expect(warehouseStore.warehouseCount).toBeGreaterThanOrEqual(0)
|
|
|
|
// Inventory in warehouses
|
|
await inventoryStore.fetchInventory()
|
|
expect(inventoryStore.items).toBeDefined()
|
|
})
|
|
|
|
it('should update warehouse load based on inventory', async () => {
|
|
const warehouseStore = useWarehouseStore()
|
|
|
|
await warehouseStore.createWarehouse({
|
|
code: 'WH-TEST',
|
|
name: 'Test Warehouse',
|
|
location: 'Test Location',
|
|
capacity: 1000
|
|
})
|
|
|
|
const warehouses = warehouseStore.warehouses
|
|
expect(warehouses.length).toBeGreaterThan(0)
|
|
|
|
// Update load
|
|
const warehouse = warehouses[0]
|
|
await warehouseStore.updateLoad(warehouse.id, 500)
|
|
expect(warehouse.currentLoad).toBe(500)
|
|
})
|
|
|
|
it('should alert on overloaded warehouses', async () => {
|
|
const warehouseStore = useWarehouseStore()
|
|
|
|
await warehouseStore.createWarehouse({
|
|
code: 'WH-FULL',
|
|
name: 'Full Warehouse',
|
|
location: 'Location',
|
|
capacity: 100
|
|
})
|
|
|
|
const warehouse = warehouseStore.warehouses[0]
|
|
await warehouseStore.updateLoad(warehouse.id, 95) // 95% capacity
|
|
|
|
const overloaded = warehouseStore.overloadedWarehouses
|
|
expect(overloaded.some((w) => w.id === warehouse.id)).toBe(true)
|
|
})
|
|
})
|
|
})
|