+ {/* Scanner component */}
+
Scanner Viewport
+ {/* Item list */}
+
Item List
+ {/* Stock adjustment form */}
+
+
+ )
+
+ // Step 1: Simulate scan
+ const scannerEl = container.querySelector('[data-testid="scanner"]')
+ expect(scannerEl).toBeInTheDocument()
+
+ // Step 2: Simulate scan result (barcode matches item-1)
+ fireEvent.customEvent(scannerEl!, new CustomEvent('scan', { detail: { barcode: '1234567890' } }))
+
+ // Step 3: Verify item details populated
+ await waitFor(() => {
+ expect(screen.getByText(/Widget A/i)).toBeInTheDocument()
+ })
+
+ // Step 4: Adjust quantity
+ const quantityInput = container.querySelector('[data-testid="quantity-input"]') as HTMLInputElement
+ if (quantityInput) {
+ await user.clear(quantityInput)
+ await user.type(quantityInput, '5')
+ }
+
+ // Step 5: Submit check-in
+ const checkinButton = container.querySelector('[data-testid="checkin-button"]') as HTMLButtonElement
+ if (checkinButton) {
+ await user.click(checkinButton)
+ }
+
+ // Step 6: Verify API call
+ await waitFor(() => {
+ expect(mockAxios.post).toHaveBeenCalledWith(
+ '/operations/checkin',
+ expect.objectContaining({
+ itemId: 'item-1',
+ quantity: 5,
+ })
+ )
+ })
+ })
+
+ it('should handle no match found error', async () => {
+ const mockAxios = axios as any
+ mockAxios.get.mockResolvedValueOnce({ data: mockItemListResponse })
+
+ const { container } = render(
+