Bladeren bron

test: 增加生产领料测试

xyh 2 jaren geleden
bovenliggende
commit
606d37e66a

+ 178 - 0
cypress/e2e/productionRequisition.cy.ts

@@ -0,0 +1,178 @@
+import {
+  beforeSetup,
+  exportIntercept,
+  generateNetworkResult,
+  intercept,
+  intoMenu,
+  selectAllFilters,
+  selectClick,
+  successIntercept,
+  validateDelete,
+  validateExport,
+  validatePut,
+  validateTableList,
+  validateTableSearch,
+} from './utils';
+
+const basicData = {
+  id: '57',
+  askGoodsId: 'LLDID123',
+  entryNumber: '1234',
+  productionCode: 'LLDCODE123',
+  storageLocationName: null,
+  userName: null,
+  realName: null,
+  materialId: '00000000000000012522',
+  wbs: '111',
+  measurementId: null,
+  num: '2',
+  outNum: '0',
+  askGoodsCode: 'LLDCODE123',
+  companyNumber: '8130',
+  companyCode: null,
+  sqrq: '2023-04-13',
+  departmentId: null,
+  departmentName: '采购中心(公共) ',
+  department: null,
+  departmentCode: null,
+  name: null,
+  code: null,
+  sourceType: '8',
+  moveType: '207',
+  materialName: '加强筋;8T.K42.600.0210',
+  materialCode: '8TK426000210',
+  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: null,
+  attribute: null,
+  deliveryId: null,
+  customerName: null,
+  customerCode: null,
+  warehouseWhere: null,
+  companyName: '青岛特来电智能设备有限公司',
+  storageCode: null,
+  accountSleeve: null,
+  inventoryId: null,
+  storageLocationCodeRk: null,
+  accountName: null,
+  requestTypeNumber: null,
+  requestTypeName: null,
+  ifCommodity: null,
+  amount: '0',
+};
+
+describe('生产领料明细', function () {
+  beforeEach(function () {
+    beforeSetup();
+    intoMenu('出库管理', '生产领料明细');
+  });
+
+  beforeEach(function () {
+    intercept('/queryList/getAskGoods', function ({reply, search}) {
+      generateNetworkResult({
+        search,
+        reply,
+        basicData,
+        title: 'askGoodsCode',
+        skipCondition: name => name === 'type',
+      });
+    });
+    intercept('/queryList/getInvite', function ({reply, search}) {
+      generateNetworkResult({
+        search,
+        reply,
+        basicData,
+        title: 'askGoodsCode',
+        skipCondition: name => name === 'type',
+      });
+    });
+
+    successIntercept(['/askGoods/delAskGoods', '/invite/delAskGoods']);
+    exportIntercept([
+      '/queryList/getAskGoodsExcel',
+      '/queryList/getInviteExcel',
+    ]);
+  });
+
+  function validateTable(label?: string, callback?: () => void) {
+    selectAllFilters('production_requisition_filter', 11);
+    validateTableList('production_requisition_table');
+    validateTableSearch(
+      'production_requisition_table',
+      [
+        'askGoodsCode',
+        'productionCode',
+        'materialCode',
+        'materialName',
+        {id: 'companyCode', type: 'select', value: '8130'},
+        {id: 'departmentCode', type: 'select', value: '00029999'},
+        'moveType',
+        'sourceType',
+        'entryNumber',
+        'wbs',
+      ],
+      {
+        toolId: 'production_requisition_filter',
+        url: '/queryList/getAskGoods',
+      },
+    );
+
+    callback?.();
+
+    validateExport('production_requisition_table');
+
+    const {validateAdd} = validatePut(
+      'production_requisition_modal',
+      'production_requisition_table',
+      {label: label ?? '生产领料单'},
+    );
+
+    validateAdd([
+      'requestOrderId',
+      'requestOrderNo',
+      'prodOrderNo',
+      'requestTypeName',
+      'requestTypeNumber',
+      {id: 'materialId', type: 'keySelect'},
+      {id: 'measUnitId', type: 'keySelect'},
+      {id: 'orderCount', type: 'field', value: '10'},
+      {id: 'companyNo', type: 'keySelect'},
+      {id: 'ifCommodity', type: 'select'},
+      {id: 'useDepartment', type: 'select'},
+      'entryNumber',
+      'WBS',
+    ]);
+
+    validateDelete('production_requisition_table', label ?? '生产领料单', {
+      eq: 0,
+      title: 'page-1',
+    });
+  }
+
+  it('table', () => validateTable());
+
+  it.only('non-standard table', function () {
+    selectClick('filter_type', 1);
+    cy.getTestId('search_btn').click();
+
+    validateTable('非生产领料单', function () {
+      selectClick('filter_type', 1);
+      cy.getTestId('search_btn').click();
+    });
+  });
+});

+ 1 - 0
packages/app/src/pages/production-requisition/filter/index.tsx

@@ -58,6 +58,7 @@ const Filter: FC = function () {
         filterData={filterList}
         fixedMap={fixedMap}
         sourceMap={sourceMap}
+        testId='production_requisition_filter'
       />
 
       <FilterSelectorModal

+ 3 - 3
packages/app/src/pages/production-requisition/table/hooks.tsx

@@ -14,7 +14,7 @@ import {context} from '../context';
 
 const columns: ColumnsType<ProductionRequisitionListData> = [
   {
-    title: '领料单号',
+    title: '领料单号',
     dataIndex: 'askGoodsCode',
     key: 'askGoodsCode',
     width: MIDDLE_TABLE_WIDTH,
@@ -118,14 +118,14 @@ export function useColumns(refetch: () => void) {
       key: 'id',
       fixed: 'right',
       width: SMALL_TABLE_WIDTH,
-      render(_, {id}) {
+      render(_, {id, askGoodsCode}) {
         return (
           <>
             <Button
               type='text'
               danger
               loading={pendingId === id}
-              onClick={onDelete(id)}
+              onClick={onDelete(id, askGoodsCode)}
             >
               删除
             </Button>

+ 1 - 0
packages/app/src/pages/production-requisition/table/index.tsx

@@ -58,6 +58,7 @@ const TableList: FC = function () {
           count={count}
           pageContext={pageContext}
           searchContext={searchContext}
+          data-testid='production_requisition_table'
         />
       </Card>
 

+ 2 - 1
packages/app/src/pages/production-requisition/table/modal/index.tsx

@@ -41,9 +41,10 @@ const AddModal: FC<Props> = function (props) {
       isLoading={isLoading}
       title={`新增${type === '1' ? '' : '非'}生产领料单`}
       onSubmit={onSubmit}
+      testId='production_requisition_modal'
     >
       <ModalField control={control} label='领料单ID' name='requestOrderId' />
-      <ModalField control={control} label='领料单号' name='requestOrderNo' />
+      <ModalField control={control} label='领料单号' name='requestOrderNo' />
       <ModalField control={control} label='生产订单号' name='prodOrderNo' />
       <ModalField
         control={control}