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

const basicData = {
  id: '9',
  noticeId: null,
  noticeCode: '12312412318427128341',
  companyNumber: '8130',
  noticeTime: null,
  sourceType: null,
  moveType: null,
  entryNumber: null,
  productionCode: null,
  materialId: null,
  wbs: ' ',
  measurementId: null,
  num: null,
  type: null,
  warehousingNum: null,
  page: 0,
  limit: 0,
  startTime: null,
  endTime: null,
  materialName: '标贴-出厂二维码-G2.5-80kW单桩',
  companyName: null,
  wllbClass: null,
  materialCode: '8TK541080160',
  userId: '36',
  askGoodsId: null,
  wllbCode: '8TK541080160',
  serial: 'TAIU2RT160',
  producBatch: '20230404',
  attribute: '',
  storageLocationCode: '111002C01K',
  storageLocationName: '111002C01K',
  storageCode: 'RK2304040022',
  seq: null,
  userName: 'PDA',
  realName: 'PDA测试',
  scrq: '2023-04-04 18:18:23',
  uniqueCode: null,
  partType: null,
  supplierId: null,
  capacity: '1',
  accountName: '青岛特来电智能设备有限公司',
  wmsItemId: null,
  wmsId: null,
  code: null,
  name: null,
  warehouseWhere: null,
};

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

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

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

  it('table', function () {
    validateExport('product_in_stream_table');

    selectAllFilters('product_in_stream_filter', 11);

    validateTableList('product_in_stream_table');
    validateTableSearch(
      'product_in_stream_table',
      [
        'storageCode',
        'productionCode',
        'wllbCode',
        'materialName',
        'userName',
        'realName',
        'storageLocationName',
        'wbs',
        {id: 'startTime', type: 'date'},
        'attribute',
        {id: 'companyNumber', type: 'select', value: '8130'},
      ],
      {toolId: 'product_in_stream_filter', url: '/warehousing/getHalf'},
    );
  });
});
