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

const basicData = {
  id: '77',
  askGoodsId: '0002',
  entryNumber: null,
  productionCode: null,
  storageLocationName: 'B3-10-4',
  userName: 'PDA',
  realName: 'PDA测试',
  materialId: null,
  wbs: '2',
  measurementId: null,
  num: '1.0',
  outNum: null,
  askGoodsCode: null,
  companyNumber: null,
  companyCode: null,
  sqrq: null,
  departmentId: null,
  departmentName: null,
  department: '喷塑班组',
  departmentCode: null,
  name: null,
  code: null,
  sourceType: null,
  moveType: null,
  materialName: '六角螺母\\\\M16;4;彩锌;粗;GB/T41-2000\\\\',
  materialCode: null,
  uniqueCode: null,
  storageLocationCode: null,
  supplierId: null,
  serial: '5',
  type: '邀请出库',
  userId: null,
  scrq: '2023-04-13 10:30:06',
  supplierName: '西安特来电智能充电科技有限公司',
  producDate: null,
  wllbCode: '3415100010390008',
  page: 0,
  limit: 0,
  askGoodsType: null,
  startTime: null,
  endTime: null,
  process: null,
  askGoodsApplyType: null,
  partType: null,
  attribute: null,
  deliveryId: null,
  customerName: null,
  customerCode: null,
  warehouseWhere: null,
  companyName: null,
  storageCode: 'CK2304130001',
  accountSleeve: null,
  inventoryId: null,
  storageLocationCodeRk: null,
  accountName: null,
  requestTypeNumber: null,
  requestTypeName: null,
  ifCommodity: null,
  amount: null,
};

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

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

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

  it('table', function () {
    selectAllFilters('raw_out_stream_filter', 12);
    validateTableList('raw_out_stream_table');
    validateTableSearch(
      'raw_out_stream_table',
      [
        'storageCode',
        'askGoodsCode',
        'wllbCode',
        'materialName',
        {id: 'department', type: 'select', value: '00029999'},
        'storageLocationName',
        'userName',
        'realName',
        {id: 'startTime', type: 'date'},
        {id: 'supplierId', type: 'select', value: 'EC92255'},
        'wbs',
        {id: 'accountSleeve', type: 'select', value: '8130'},
      ],
      {
        toolId: 'raw_out_stream_filter',
        url: '/askGoods/getRemoval',
      },
    );
    validateExport('raw_out_stream_table');
  });
});
