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

const basicData = {
  materialName: '六角螺母\\\\M16;4;彩锌;粗;GB/T41-2000\\\\',
  amount: '1.00',
  wllbCode: '3415100010390008',
  accountSleeve: '8400',
  storageLocationCode: 'B3-10-4',
  companyName: '青岛特来电智能充电设备有限公司',
  ustomerName: '西安特来电智能充电科技有限公司',
  wbs: '2',
  scrq: '2022-04-13 10:13:24',
  id: 8221,
  storageLocationName: 'B3-10-4',
  materialId: '00000000000000016029',
};

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

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

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

  it('table', function () {
    selectAllFilters('dead_product_filter', 6);
    validateTableList('dead_product_table');

    validateTableSearch(
      'dead_product_table',
      [
        'wllbCode',
        'materialName',
        'storageLocationName',
        {id: 'companyCode', type: 'select', value: '8130'},
        {id: 'ustomerCode', type: 'select', value: 'EC92255'},
        'wbs',
      ],
      {toolId: 'dead_product_filter', url: '/queryList/dullGoods'},
    );

    validateExport('dead_product_table');
  });
});
