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

const basicData = {
  id: '30',
  noticeId: null,
  noticeCode: null,
  companyNumber: '8130',
  noticeTime: null,
  sourceType: null,
  moveType: null,
  entryNumber: null,
  productionCode: 'DD01',
  materialId: null,
  wbs: '',
  measurementId: null,
  num: null,
  type: null,
  warehousingNum: '20',
  page: 0,
  limit: 0,
  startTime: null,
  endTime: null,
  materialName: '酒精纸\\',
  companyName: null,
  wllbClass: null,
  materialCode: '2205010010020003',
  userId: '36',
  askGoodsId: null,
  wllbCode: '2205010010020003',
  serial: null,
  producBatch: '2023-04-12',
  attribute: null,
  storageLocationCode: 'XNKW000000',
  storageLocationName: null,
  storageCode: 'RK2304120007',
  seq: null,
  userName: 'PDA',
  realName: 'PDA测试',
  scrq: '2023-04-12 16:44:30',
  uniqueCode: null,
  partType: null,
  supplierId: null,
  capacity: null,
  accountName: '青岛特来电智能设备有限公司',
  wmsItemId: null,
  wmsId: null,
  code: null,
  name: null,
  warehouseWhere: null,
};

describe('半成品入库明细', function () {
  beforeEach(function () {
    beforeSetup();
    intoMenu('入库管理', '半成品入库明细');
  });

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

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

  it('table', function () {
    selectAllFilters('semi_in_stream_filter', 9);
    validateTableList('semi_in_stream_table');

    validateTableSearch(
      'semi_in_stream_table',
      [
        'storageCode',
        'productionCode',
        'wllbCode',
        'materialName',
        'wbs',
        'userName',
        'realName',
        {id: 'startTime', type: 'date'},
        {id: 'companyNumber', type: 'select', value: '8130'},
      ],
      {toolId: 'semi_in_stream_filter', url: '/warehousing/getProduct'},
    );

    validateExport('semi_in_stream_table');
  });
});
