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

const basicData = {
  unitOfMeasurement: null,
  wllbClass: '金属紧固件',
  companyCode: '8400',
  supplierName: '西安特来电智能充电科技有限公司',
  code: '3415100010390008',
  supplierId: 'EC00276',
  year: 2023,
  storageLocationCode: 'B3-10-4',
  companyName: '青岛特来电智能充电设备有限公司',
  wbs: '2',
  sum: 3,
  maxNum: null,
  warehouseName: '充电设备事业部原材料库',
  warehouseCode: '2000',
  month: 4,
  accountSleeve: '8400',
  name: '六角螺母\\\\M16;4;彩锌;粗;GB/T41-2000\\\\',
  id: 8221,
  storageLocationName: 'B3-10-4',
  day: 365,
  partType: '原材料',
};

describe('库存明细', function () {
  beforeEach(function () {
    beforeSetup();
    intoMenu('库内管理', '库存明细');
  });

  beforeEach(function () {
    intercept('/queryList/storageLocation', function ({search, reply}) {
      generateNetworkResult({
        search,
        reply,
        basicData,
        title: 'code',
        skipCondition: name => name === 'groupBy',
      });
    });

    exportIntercept('/queryList/exportStorageLocation');
  });

  it('库存明细', function () {
    selectAllFilters('stock_filter', 11);
    validateTableList('stock_table');
    validateTableSearch(
      'stock_table',
      [
        'wllbCode',
        'materialName',
        'storageLocationName',
        {id: 'companyCode', type: 'select', value: '8130'},
        {id: 'warehouseId', type: 'select', value: '2bdf33b8-4326-47e8-b'},
        {id: 'supplierId', type: 'select', value: 'EC92255'},
        'wbs',
        'partType',
        {id: 'wllbClass', type: 'select', value: '危化品'},
        {
          id: 'unitOfMeasurement',
          type: 'select',
          value: '00000000000000000001',
        },
      ],
      {
        toolId: 'stock_filter',
        url: '/queryList/storageLocation',
      },
    );
    validateExport('stock_table');
  });
});
