import {
  beforeSetup,
  exportIntercept,
  generateNetworkResult,
  intercept,
  intoMenu,
  selectAllFilters,
  validateExport,
  validateTableList,
  validateTableSearch,
} from './utils';

const basicData = {
  id: '156',
  wllbCode: '3415100010390008',
  supplierId: null,
  supplierName: '西安特来电智能充电科技有限公司',
  serial: '2',
  producDate: '20221021',
  producBatch: '20221021',
  capacity: '1.00',
  process: null,
  seq: null,
  type: '扫码入库',
  userId: null,
  departmentId: null,
  storageLocationCode: null,
  scrq: '2023-04-13 09:38:15',
  userName: 'PDA',
  realName: 'PDA测试',
  departmentName: '仓库管理部',
  storageLocationName: 'B3-10-4',
  orderCode: '6202023040301356',
  startTime: null,
  endTime: null,
  materialName: '六角螺母\\\\M16;4;彩锌;粗;GB/T41-2000\\\\',
  page: 0,
  limit: 0,
  storageCode: 'RK2304130003',
  wbs: '2',
  accountSleeve: '8400',
  accountName: '青岛特来电智能充电设备有限公司',
  purchaseNum: '60',
  transmissionType: '1',
};

describe('原材料入库明细', function () {
  beforeEach(function () {
    beforeSetup();
    intoMenu('入库管理', '原材料入库明细');
  });

  beforeEach(function () {
    intercept('/warehousing/warehousingFlowing', function ({reply, search}) {
      generateNetworkResult({reply, search, basicData, title: 'storageCode'});
    });

    exportIntercept('/warehousing/export');
  });

  it('table', function () {
    selectAllFilters('raw_in_stream_filter', 11);
    validateTableList('raw_in_stream_table');
    validateExport('raw_in_stream_table');

    validateTableSearch(
      'raw_in_stream_table',
      [
        'storageCode',
        'orderCode',
        'materialName',
        'wllbCode',
        'storageLocationName',
        {id: 'supplierId', type: 'select', value: 'EC92255'},
        'wbs',
        'userName',
        'realName',
        {id: 'startTime', type: 'date'},
        {id: 'accountSleeve', type: 'select', value: '8130'},
      ],
      {toolId: 'raw_in_stream_filter', url: '/warehousing/warehousingFlowing'},
    );
  });
});
