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

const basicData = {
  id: '28',
  askGoodsId: '00000000000000040445',
  entryNumber: null,
  productionCode: null,
  storageLocationName: null,
  userName: null,
  realName: null,
  materialId: '00000000000000057928',
  wbs: '00000000000007160127',
  measurementId: '00000000000000000001',
  num: '1.0',
  outNum: '1',
  askGoodsCode: '710202301310003',
  companyNumber: '8130',
  companyCode: null,
  sqrq: '2023-01-31',
  departmentId: null,
  departmentName: null,
  department: '充电箱变产线',
  departmentCode: null,
  name: null,
  code: null,
  sourceType: '8',
  moveType: '209',
  materialName: '箱变非金属顶盖-左侧端盖总成1;5T.X22.000.0003',
  materialCode: '5TX220000003',
  uniqueCode: null,
  storageLocationCode: null,
  supplierId: null,
  serial: null,
  type: null,
  userId: null,
  scrq: null,
  supplierName: null,
  producDate: null,
  wllbCode: null,
  page: 0,
  limit: 0,
  askGoodsType: null,
  startTime: null,
  endTime: null,
  process: null,
  askGoodsApplyType: null,
  partType: '半成品',
  attribute: null,
  deliveryId: null,
  deliveryCode: null,
  customerName: null,
  customerCode: null,
  warehouseWhere: null,
  companyName: '青岛特来电智能设备有限公司',
  storageCode: null,
  accountSleeve: null,
  inventoryId: null,
  storageLocationCodeRk: null,
  accountName: null,
  requestTypeNumber: 'Z09',
  requestTypeName: '其他发货通知_青岛工厂',
  ifCommodity: '0',
  amount: null,
};

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

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

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

  it('table', function () {
    selectAllFilters('other_out_filter', 8);

    validateTableList('other_out_table');

    validateTableSearch(
      'other_out_table',
      [
        'askGoodsCode',
        'materialCode',
        'materialName',
        {id: 'startTime', type: 'date'},
        {id: 'companyNumber', type: 'select', value: '8130'},
        'wbs',
        {id: 'departmentCode', type: 'select', value: '00029999'},
        {id: 'type', type: 'select', value: '1'},
      ],
      {
        toolId: 'other_out_filter',
        url: '/queryList/getOtherShipments',
      },
    );
  });

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