import { describe, expect, it } from 'vitest' import { reworkRelabelApplications } from './relabelRework' describe('tail-order relabel rework candidates', () => { it('uses each return relabel application instead of the aggregate completed status', () => { const applications = [ { relabelNo: 'RL-1', status: 'CUSTOMER_CONFIRM_PENDING', quantity: 1, createdAt: '', statusLabel: '' }, { relabelNo: 'RL-2', status: 'COMPLETED', quantity: 1, createdAt: '', statusLabel: '' }, { relabelNo: 'RL-3', status: 'PROCESSING', quantity: 1, createdAt: '', statusLabel: '' }, ] expect(reworkRelabelApplications({ relabelOrderNo: '', relabelApplications: applications, relabelStatusCode: 'COMPLETED' }).map(item => item.relabelNo)).toEqual(['RL-1', 'RL-3']) }) it('preserves the existing single-application entry and excludes confirmed orders', () => { expect(reworkRelabelApplications({ relabelOrderNo: 'RL-1', relabelStatusCode: 'CUSTOMER_CONFIRM_PENDING' })).toHaveLength(1) expect(reworkRelabelApplications({ relabelOrderNo: 'RL-1', relabelStatusCode: 'READY_FOR_OUTBOUND' })).toEqual([]) expect(reworkRelabelApplications({ relabelOrderNo: '', relabelStatusCode: 'PROCESSING' })).toEqual([]) }) })