Quellcode durchsuchen

test: 增加盘点测试

xyh vor 3 Jahren
Ursprung
Commit
ac9dc2b722

+ 193 - 0
cypress/e2e/incentory.cy.ts

@@ -0,0 +1,193 @@
+import {
+  beforeSetup,
+  exportIntercept,
+  generateNetworkResult,
+  intercept,
+  intoMenu,
+  successIntercept,
+  tableBtnClick,
+  validateExport,
+  validateTableList,
+  validateTableSearch,
+} from './utils';
+
+const basicData = {
+    id: '10',
+    storageLocationCode: null,
+    accountSleeve: null,
+    storageLocationName: null,
+    amount: null,
+    gsAmount: null,
+    plateAmount: null,
+    name: null,
+    total: null,
+    wllbCode: null,
+    materialId: null,
+    scrq: '2023-04-11 17:08:43',
+    plateId: null,
+    supplierId: null,
+    serial: null,
+    attribute: null,
+    uuid: '400807081608876032',
+    title: '2023',
+    producBatch: null,
+    wllbCodes: null,
+    storageLocationCodes: null,
+    accountSleeves: null,
+    accountName: null,
+    startTime: null,
+    endTime: null,
+    userId: '3',
+    userName: 'admin',
+    page: 0,
+    limit: 0,
+    modifyUser: null,
+    modifyTime: null,
+  },
+  basicData2 = {
+    id: '9430',
+    storageLocationCode: null,
+    accountSleeve: '8130',
+    storageLocationName: null,
+    amount: '0',
+    gsAmount: '54.00000000',
+    plateAmount: null,
+    name: '分体式直流充电机;240kW;六路;偏矩阵;200-1000V;EC风机;交流电表;B型',
+    total: null,
+    wllbCode: '3907060140030264',
+    materialId: '00000000000000070387',
+    scrq: null,
+    plateId: null,
+    supplierId: null,
+    serial: null,
+    attribute: null,
+    uuid: '400807081608876032',
+    title: null,
+    producBatch: null,
+    wllbCodes: null,
+    storageLocationCodes: null,
+    accountSleeves: null,
+    accountName: '青岛特来电智能设备有限公司',
+    startTime: null,
+    endTime: null,
+    userId: null,
+    userName: null,
+    page: 0,
+    limit: 0,
+    modifyUser: null,
+    modifyTime: null,
+  },
+  basicData3 = {
+    id: '58',
+    storageLocationCode: 'B3-10-4',
+    accountSleeve: '8130',
+    storageLocationName: 'B3-10-4',
+    amount: '6.00',
+    gsAmount: null,
+    plateAmount: null,
+    name: '六角螺母\\\\M16;4;彩锌;粗;GB/T41-2000\\\\',
+    total: '2.00',
+    wllbCode: '3415100010390008',
+    materialId: null,
+    scrq: '2023-04-11 17:43:17',
+    plateId: '10',
+    supplierId: 'EC00276',
+    serial: null,
+    attribute: null,
+    uuid: '400807081608876032',
+    title: null,
+    producBatch: null,
+    wllbCodes: null,
+    storageLocationCodes: null,
+    accountSleeves: null,
+    accountName: null,
+    startTime: null,
+    endTime: null,
+    userId: null,
+    userName: null,
+    page: 0,
+    limit: 0,
+    modifyUser: null,
+    modifyTime: null,
+  };
+
+describe('盘点明细', function () {
+  beforeEach(function () {
+    beforeSetup();
+    intoMenu('库内管理', '盘点明细');
+  });
+
+  beforeEach(function () {
+    intercept('/inventory/getInventoryDataList', function ({search, reply}) {
+      generateNetworkResult({search, reply, basicData, title: 'title'});
+    });
+
+    intercept('/inventory/getInventoryPlates', function ({search, reply}) {
+      generateNetworkResult({
+        search,
+        reply,
+        basicData: basicData2,
+        title: 'wllbCode',
+        skipCondition: name => name === 'uuid',
+      });
+    });
+
+    successIntercept('/inventory/addInventoryPlate');
+    exportIntercept(['/inventory/export', '/inventory/exportEntering']);
+  });
+
+  it('table', function () {
+    validateTableList('inventory_table');
+    validateTableSearch(
+      'inventory_table',
+      ['inventory', 'userName', {id: 'inventoryDates', type: 'date'}],
+      {
+        toolId: 'inventory_filter',
+        url: '/inventory/getInventoryDataList',
+      },
+    );
+  });
+
+  it('detail table', function () {
+    tableBtnClick('inventory_table', 0);
+    validateTableList('inventory_detail_table');
+    validateTableSearch(
+      'inventory_detail_table',
+      [
+        'wllbCode',
+        'name',
+        {type: 'select', id: 'accountSleeves', value: '8130'},
+      ],
+      {
+        toolId: 'inventory_detail_filter',
+        url: '/inventory/getInventoryPlates',
+      },
+    );
+    validateExport('inventory_detail_table');
+  });
+
+  it('log table', function () {
+    // 会影响到其他的路由
+    intercept('/inventory/getInventory', function ({search, reply}) {
+      generateNetworkResult({
+        search,
+        reply,
+        basicData: basicData3,
+        title: 'wllbCode',
+        skipCondition: name => name === 'uuid',
+      });
+    });
+
+    tableBtnClick('inventory_table', 1);
+    validateTableList('inventory_log_table');
+    validateTableSearch(
+      'inventory_log_table',
+      ['wllbCodes', 'name', 'storageLocationCodes', 'storageLocationName'],
+      {
+        toolId: 'inventory_log_filter',
+        url: '/inventory/getInventory',
+      },
+    );
+    validateExport('inventory_log_table');
+  });
+});

+ 8 - 2
cypress/e2e/utils/setup.ts

@@ -90,8 +90,14 @@ export function optionsIntercept() {
   normalIntercept('/userMaterial/getUser', 'options/user');
 }
 
-export function exportIntercept(url: string) {
-  successIntercept(url).as('export');
+export function exportIntercept(urls: string | string[]) {
+  if (Array.isArray(urls)) {
+    urls.forEach(function (url) {
+      successIntercept(url);
+    });
+    return;
+  }
+  successIntercept(urls).as('export');
 }
 
 export function beforeSetup(autoLogin = true) {

+ 1 - 1
packages/app/src/pages/inventory-detail/filter/index.tsx

@@ -30,7 +30,7 @@ const Filter: FC = function () {
 
   return (
     <Card>
-      <FilterFieldWrapper onSearch={onSearch}>
+      <FilterFieldWrapper onSearch={onSearch} testId='inventory_detail_filter'>
         <FilterField
           label='物料编号'
           name='wllbCode'

+ 5 - 1
packages/app/src/pages/inventory-detail/index.tsx

@@ -3,6 +3,7 @@ import {FC} from 'react';
 import {context, contextState, pageContext, searchContext} from './context';
 import Filter from './filter';
 import TableList from './table';
+import {MODAL_PAGE_SIZE_LIST} from '@utils';
 
 type Porps = {
   uuid: string;
@@ -11,7 +12,10 @@ type Porps = {
 const InventoryDetail: FC<Porps> = function ({uuid}) {
   return (
     <TableSearchProvider context={context} state={{...contextState, uuid}}>
-      <PageProvider context={pageContext}>
+      <PageProvider
+        context={pageContext}
+        initPageSize={MODAL_PAGE_SIZE_LIST[0]}
+      >
         <SearchProvider context={searchContext}>
           <section className='content-main'>
             <Filter />

+ 3 - 0
packages/app/src/pages/inventory-detail/table/index.tsx

@@ -13,6 +13,7 @@ import {InventoryChildListData} from '@models';
 import {
   HUGE_TABLE_WIDTH,
   MIDDLE_TABLE_WIDTH,
+  MODAL_PAGE_SIZE_LIST,
   NORMAL_TABLE_WIDTH,
   SMALL_TABLE_WIDTH,
 } from '@utils';
@@ -79,6 +80,8 @@ const TableList: FC = function () {
         count={count}
         pageContext={pageContext}
         searchContext={searchContext}
+        data-testid='inventory_detail_table'
+        pageSizeList={MODAL_PAGE_SIZE_LIST}
       />
     </Card>
   );

+ 1 - 1
packages/app/src/pages/inventory-log/filter/index.tsx

@@ -33,7 +33,7 @@ const Filter: FC = function () {
 
   return (
     <Card>
-      <FilterFieldWrapper onSearch={onSearch}>
+      <FilterFieldWrapper onSearch={onSearch} testId='inventory_log_filter'>
         <FilterField
           label='物料编号'
           name='wllbCodes'

+ 5 - 1
packages/app/src/pages/inventory-log/index.tsx

@@ -3,6 +3,7 @@ import {FC} from 'react';
 import {context, contextState, pageContext, searchContext} from './context';
 import Filter from './filter';
 import TableList from './table';
+import {MODAL_PAGE_SIZE_LIST} from '@utils';
 
 type Props = {
   uuid: string;
@@ -11,7 +12,10 @@ type Props = {
 const InventoryLog: FC<Props> = function ({uuid}) {
   return (
     <TableSearchProvider context={context} state={{...contextState, uuid}}>
-      <PageProvider context={pageContext}>
+      <PageProvider
+        context={pageContext}
+        initPageSize={MODAL_PAGE_SIZE_LIST[0]}
+      >
         <SearchProvider context={searchContext}>
           <section className='content-main'>
             <Filter />

+ 7 - 1
packages/app/src/pages/inventory-log/table/index.tsx

@@ -10,7 +10,11 @@ import {Card} from 'antd';
 import {Table, TableTools} from '@components';
 import {ColumnsType} from 'antd/es/table';
 import {InventoryLogListData} from '@models';
-import {HUGE_TABLE_WIDTH, NORMAL_TABLE_WIDTH} from '@utils';
+import {
+  HUGE_TABLE_WIDTH,
+  MODAL_PAGE_SIZE_LIST,
+  NORMAL_TABLE_WIDTH,
+} from '@utils';
 
 const columns: ColumnsType<InventoryLogListData> = [
   {title: '物料编号', dataIndex: 'wllbCode', width: NORMAL_TABLE_WIDTH},
@@ -64,6 +68,8 @@ const TableList: FC = function () {
         pageContext={pageContext}
         searchContext={searchContext}
         columns={columns}
+        data-testid='inventory_log_table'
+        pageSizeList={MODAL_PAGE_SIZE_LIST}
       />
     </Card>
   );

+ 1 - 1
packages/app/src/pages/inventory/filter/index.tsx

@@ -34,7 +34,7 @@ const Filter: FC = function () {
 
   return (
     <Card>
-      <FilterFieldWrapper onSearch={onSearch}>
+      <FilterFieldWrapper onSearch={onSearch} testId='inventory_filter'>
         <FilterField
           label='盘点标题'
           name='inventory'

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

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