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

const basicData = {
  dataVal:
    '{"SourceBillDate":"20230131","GIReqBillID":"00000000000000040443","WMSID":"46","SourceType":"8","MoveType":"Z32","Creator":"测试","WareHouse":"a031bb4f-3eb6-49df-9","IsRed":0,"BillItems":[{"FlexField1":"00000000000007160127","GIReqBillID":"00000000000000040443","FlexField1Code":"2210003715-20221020-03-001","Quantity":"1.0","Material":"00000000000000057927","FlexField1Name":"宝应高铁站-欧变-2210003715-20221020-03-001","GIReqBillItemID":"0002"},{"FlexField1":"00000000000007160127","GIReqBillID":"00000000000000040443","FlexField1Code":"2210003715-20221020-03-001","Quantity":"6.0","Material":"00000000000000057926","FlexField1Name":"宝应高铁站-欧变-2210003715-20221020-03-001","GIReqBillItemID":"0001"}],"WMSCode":"WMSCode001"}',
  errorInfo: '出库数量大于要货申请行可出库总数量！',
  scrq: '2023-04-13 15:38:02',
  transmissionType: 1,
  id: 247,
  type: '其它入库',
  url: 'http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreateMakeUpOtherOutStock',
};

describe('gs错误日志', function () {
  beforeEach(function () {
    beforeSetup();
    intoMenu('系统日志', 'GS错误日志');
  });

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

    exportIntercept('/queryList/getErrorExcel');
    successIntercept('/gsPlugOut/anew');
  });

  it('table', function () {
    validateTableList('error_log_table');
    validateTableSearch(
      'error_log_table',
      ['url', 'errorInfo', 'dataVal', 'type', {id: 'date', type: 'date'}],
      {
        toolId: 'error_log_filter',
        url: '/queryList/getErrorList',
      },
    );
  });

  it('operation', function () {
    validateExport('error_log_table');

    // 重试
    tableBtnClick('error_log_table', 0);
    validateMessageContent('已重试');
  });
});
