Bladeren bron

test: 增加销售单明细测试

xyh 2 jaren geleden
bovenliggende
commit
feb2be4c9a

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

@@ -132,6 +132,7 @@ describe('生产领料明细', function () {
       },
     );
 
+    // eslint-disable-next-line callback-return
     callback?.();
 
     validateExport('production_requisition_table');

+ 113 - 0
cypress/e2e/sell.cy.ts

@@ -0,0 +1,113 @@
+import {
+  beforeSetup,
+  exportIntercept,
+  generateNetworkResult,
+  intercept,
+  intoMenu,
+  selectAllFilters,
+  successIntercept,
+  validateDelete,
+  validateExport,
+  validatePut,
+  validateTableList,
+  validateTableSearch,
+} from './utils';
+
+const basicData = {
+  id: '115',
+  deliveryId: 'sdf2132141',
+  deliveryCode: 'eq123123',
+  companyNumber: '8130',
+  companyName: '青岛特来电智能设备有限公司',
+  customerCode: null,
+  customerName: '青岛海洲市政环境工程有限公司',
+  billsTime: '2023-03-27',
+  deliveryType: '1234',
+  sourceType: null,
+  moveType: '123123',
+  entryNumber: '4123',
+  materialId: '00000000000000012072',
+  materialName:
+    '交流路灯充电单桩包装纸箱\\\\单层瓦楞纸板(双面瓦楞纸板)\\附图纸\\\\',
+  materialCode: '2205010010010023',
+  wbs: '12',
+  measurementId: null,
+  gsDeliveryNum: '12',
+  gsCancelNum: '1',
+  outNum: '0',
+  userId: null,
+  storageCode: null,
+  storageLocationCode: null,
+  startTime: null,
+  endTime: null,
+  uniqueCode: null,
+  page: 0,
+  limit: 0,
+  attribute: null,
+  partType: null,
+  amount: '0',
+};
+
+describe('销售单明细', function () {
+  beforeEach(function () {
+    beforeSetup();
+    intoMenu('出库管理', '销售单明细');
+  });
+
+  beforeEach(function () {
+    intercept('/queryList/getDelivery', function ({reply, search}) {
+      generateNetworkResult({reply, search, basicData, title: 'deliveryId'});
+    });
+
+    successIntercept('/delivery/delDelivery');
+    exportIntercept('/queryList/getDeliveryExcel');
+  });
+
+  it('table', function () {
+    selectAllFilters('sell_order_filter', 11);
+    validateTableList('sell_order_table');
+    validateTableSearch(
+      'sell_order_table',
+      [
+        'deliveryId',
+        'materialCode',
+        'materialName',
+        {id: 'customerCode', type: 'select', value: 'EC92255'},
+        {id: 'companyNumber', type: 'select', value: '8130'},
+        {id: 'startTime', type: 'date'},
+        'wbs',
+        'sourceType',
+        'moveType',
+        'deliveryType',
+        'entryNumber',
+      ],
+      {
+        toolId: 'sell_order_filter',
+        url: '/queryList/getDelivery',
+      },
+    );
+  });
+
+  it('operation', function () {
+    const {validateAdd} = validatePut('sell_order_modal', 'sell_order_table', {
+      label: '销售单',
+    });
+
+    validateAdd([
+      'deliveryOrderId',
+      'deliveryOrderNo',
+      {id: 'materialId', type: 'keySelect'},
+      {id: 'measUnitId', type: 'select'},
+      {id: 'gsDeliveryCount', type: 'field', value: '10'},
+      {id: 'gsCancelDeliveryCount', type: 'field', value: '10'},
+      {id: 'customerNo', type: 'keySelect'},
+      {id: 'companyNumber', type: 'select'},
+      {id: 'deloveryGoodsType', type: 'select'},
+      'entryNumber',
+      'WBS',
+    ]);
+
+    validateDelete('sell_order_table', '销售单', {title: 'page-1', eq: 0});
+    validateExport('sell_order_table');
+  });
+});

+ 1 - 0
packages/app/src/pages/sell-order/filter/index.tsx

@@ -55,6 +55,7 @@ const Filter: FC = function () {
         isSearching={isSearching}
         onReset={onReset}
         filterData={filterList}
+        testId='sell_order_filter'
       />
 
       <FilterSelectorModal

+ 2 - 2
packages/app/src/pages/sell-order/table/hooks.tsx

@@ -116,14 +116,14 @@ export function useColumns(refetch: () => void) {
       key: 'id',
       fixed: 'right',
       width: SMALL_TABLE_WIDTH,
-      render(_, {id}) {
+      render(_, {id, deliveryId}) {
         return (
           <>
             <Button
               type='text'
               danger
               loading={pendingId === id}
-              onClick={onDelete(id)}
+              onClick={onDelete(id, deliveryId)}
             >
               删除
             </Button>

+ 1 - 0
packages/app/src/pages/sell-order/table/index.tsx

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

+ 1 - 0
packages/app/src/pages/sell-order/table/modal/index.tsx

@@ -43,6 +43,7 @@ const AddModal: FC<Props> = function (props) {
       isLoading={isLoading}
       onSubmit={onSubmit}
       title='新增销售单'
+      testId='sell_order_modal'
     >
       <ModalField control={control} label='销售单ID' name='deliveryOrderId' />
       <ModalField control={control} label='销售单编号' name='deliveryOrderNo' />