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

const basicData = {
  id: '50',
  noticeId: '00000000000000000024',
  noticeCode: 'SYS202304081555149178913',
  companyNumber: '8130',
  noticeTime: '2023-01-31',
  sourceType: '0',
  moveType: '109',
  entryNumber: '0005',
  productionCode: null,
  materialId: '00000000000000072550',
  wbs: ' ',
  measurementId: '00000000000000000001',
  num: '2.0',
  type: null,
  warehousingNum: '2',
  page: 0,
  limit: 0,
  startTime: null,
  endTime: null,
  materialName: '瑞银;一体式电表;DJZ1226;600A',
  companyName: '青岛特来电智能设备有限公司',
  wllbClass: null,
  materialCode: '5TK540010437W87',
  userId: null,
  askGoodsId: null,
  wllbCode: null,
  serial: null,
  producBatch: null,
  attribute: null,
  storageLocationCode: null,
  storageLocationName: null,
  storageCode: null,
  seq: null,
  userName: null,
  realName: null,
  scrq: null,
  uniqueCode: null,
  partType: '原材料',
  supplierId: null,
  capacity: null,
  accountName: null,
  wmsItemId: null,
  wmsId: null,
  code: null,
  name: null,
  warehouseWhere: null,
};

describe('其他入库', function () {
  beforeEach(function () {
    beforeSetup();
    intoMenu('入库管理', '其他入库');
  });

  beforeEach(function () {
    intercept('/queryList/getOtherReceivingGoods', function ({search, reply}) {
      generateNetworkResult({reply, search, basicData, title: 'noticeCode'});
    });

    successIntercept('/warehousing/delOtherReceivingGoods');
  });

  it('table', function () {
    selectAllFilters('other_in_filter', 7);

    validateTableList('other_in_table');

    validateTableSearch(
      'other_in_table',
      [
        'noticeCode',
        'materialCode',
        'materialName',
        {id: 'startTime', type: 'date'},
        {id: 'companyNumber', type: 'select', value: '8130'},
        'wbs',
        {id: 'type', type: 'select', value: '1'},
      ],
      {
        toolId: 'other_in_filter',
        url: '/queryList/getOtherReceivingGoods',
      },
    );
  });

  it('opertaion', function () {
    validateDelete('other_in_table', '其他入库', {eq: 0, title: 'page-1'});
  });
});
