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

const basicData = {
  id: '364',
  type: '其它出库',
  data: '{"strJson":"{\\"ReqOutStocks\\":[{\\"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\\"}]}"}',
  scrq: '2023-04-13 15:38:02',
  accessType: '1',
  startTime: null,
  endTime: null,
  page: 0,
  limit: 0,
};

describe('接口日志', function () {
  beforeEach(function () {
    beforeSetup();
    intoMenu('系统日志', '接口日志');
  });

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

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

  it('table', function () {
    validateTableList('gs_interface_log_table');
    validateTableSearch(
      'gs_interface_log_table',
      [
        {id: 'type', type: 'select', value: '质检信息'},
        {id: 'accessType', type: 'select', value: '0'},
        'data',
        {id: 'dates', type: 'date'},
      ],
      {
        toolId: 'gs_interface_log_filter',
        url: '/queryList/getAccess',
      },
    );
    validateExport('gs_interface_log_table');
  });
});
