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

const basicData = {
  id: '1',
  deliveryCode: '1234',
  askGoodsId: null,
  entryNumber: null,
  productionCode: null,
  storageLocationName: null,
  userName: 'admin',
  realName: '超管',
  materialId: null,
  wbs: '1',
  measurementId: null,
  num: '100',
  outNum: null,
  askGoodsCode: null,
  companyNumber: '8130',
  companyCode: null,
  sqrq: null,
  departmentId: null,
  departmentName: null,
  department: null,
  departmentCode: null,
  name: null,
  code: null,
  sourceType: null,
  moveType: null,
  materialName: '汽车充电终端;6M;250A;落地式;带急停;双枪;A3系列;标准版2',
  materialCode: '3907060140040522',
  uniqueCode: null,
  storageLocationCode: null,
  supplierId: null,
  serial: null,
  type: null,
  userId: '3',
  scrq: '2022-10-09',
  supplierName: null,
  producDate: null,
  wllbCode: '3907060140040522',
  page: 0,
  limit: 0,
  askGoodsType: null,
  startTime: null,
  endTime: null,
  process: null,
  askGoodsApplyType: null,
  partType: null,
  attribute: null,
  deliveryId: '1',
  customerName: '西安特来电智能充电科技有限公司',
  customerCode: 'EC00276',
  warehouseWhere: null,
  companyName: '青岛特来电智能设备有限公司',
  storageCode: 'BH741203309',
  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/getRemovalHalf', function ({reply, search}) {
      generateNetworkResult({search, reply, basicData, title: 'deliveryCode'});
    });

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

  it('table', function () {
    selectAllFilters('product_out_stream_filter', 10);
    validateTableList('product_out_stream_table');
    validateTableSearch(
      'product_out_stream_table',
      [
        'deliveryCode',
        'storageCode',
        'wllbCode',
        'materialName',
        'userName',
        'realName',
        'wbs',
        {id: 'companyCode', type: 'select', value: '8130'},
        {id: 'customerCode', type: 'select', value: 'EC92255'},
        {id: 'startTime', type: 'date'},
      ],
      {
        toolId: 'product_out_stream_filter',
        url: '/askGoods/getRemovalHalf',
      },
    );
    validateExport('product_out_stream_table');
  });
});
