// Скрипт для тестирования фильтрации поставок фулфилмента const testData = [ // Тестовая поставка товаров (с услугами) { id: 'order1', consumableType: 'SELLER_CONSUMABLES', status: 'SUPPLIER_APPROVED', items: [ { id: 'item1', recipe: { services: [ { id: 'service1', name: 'Упаковка' }, { id: 'service2', name: 'Маркировка' } ] }, // Есть услуги = товары product: { name: 'Товар 1' } } ] }, // Тестовая поставка расходников (без услуг) { id: 'order2', consumableType: 'SELLER_CONSUMABLES', status: 'SUPPLIER_APPROVED', items: [ { id: 'item2', recipe: { services: [] }, // Нет услуг = расходники product: { name: 'Расходник 1' } } ] }, // Поставка фулфилмента (не селлер) { id: 'order3', consumableType: 'FULFILLMENT_CONSUMABLES', status: 'SUPPLIER_APPROVED', items: [ { id: 'item3', recipe: { services: [] }, product: { name: 'Расходник ФФ' } } ] } ] // Тест фильтрации товаров (логика из FulfillmentGoodsOrdersTab) function testGoodsFiltering(orders) { return orders.filter((order) => { const isSellerConsumables = order.consumableType === 'SELLER_CONSUMABLES' const hasServices = order.items?.some(item => item.recipe?.services && item.recipe.services.length > 0) const isGoodsOnly = isSellerConsumables && hasServices console.log(`📦 ТОВАРЫ - Заказ ${order.id}:`, { isSellerConsumables, hasServices, isGoodsOnly, result: isGoodsOnly ? '✅ ПОКАЗАТЬ' : '❌ СКРЫТЬ' }) return isGoodsOnly }) } // Тест фильтрации расходников (логика из FulfillmentConsumablesOrdersTab) function testConsumablesFiltering(orders) { return orders.filter((order) => { const isSellerConsumables = order.consumableType === 'SELLER_CONSUMABLES' const hasServices = order.items?.some(item => item.recipe?.services && item.recipe.services.length > 0) const isConsumablesOnly = isSellerConsumables && !hasServices console.log(`🔧 РАСХОДНИКИ - Заказ ${order.id}:`, { isSellerConsumables, hasServices, isConsumablesOnly, result: isConsumablesOnly ? '✅ ПОКАЗАТЬ' : '❌ СКРЫТЬ' }) return isConsumablesOnly }) } console.log('🧪 ТЕСТИРОВАНИЕ ФИЛЬТРАЦИИ ПОСТАВОК ФУЛФИЛМЕНТА\n') console.log('📋 ИСХОДНЫЕ ДАННЫЕ:') testData.forEach(order => { const servicesCount = order.items[0]?.recipe?.services?.length || 0 console.log(`- ${order.id}: ${order.consumableType}, услуг: ${servicesCount}`) }) console.log('\n📦 ТЕСТ ФИЛЬТРАЦИИ ТОВАРОВ:') const goodsResult = testGoodsFiltering(testData) console.log('Результат:', goodsResult.map(o => o.id)) console.log('\n🔧 ТЕСТ ФИЛЬТРАЦИИ РАСХОДНИКОВ:') const consumablesResult = testConsumablesFiltering(testData) console.log('Результат:', consumablesResult.map(o => o.id)) console.log('\n✅ ОЖИДАЕМЫЙ РЕЗУЛЬТАТ:') console.log('- Товары должны показать: order1 (есть услуги)') console.log('- Расходники должны показать: order2 (нет услуг)') console.log('- order3 не должен показываться нигде (не SELLER_CONSUMABLES)') console.log('\n🎯 ТЕСТ', goodsResult.length === 1 && goodsResult[0].id === 'order1' && consumablesResult.length === 1 && consumablesResult[0].id === 'order2' ? 'ПРОШЕЛ ✅' : 'ПРОВАЛЕН ❌' )