Browse Source

添加导出e2e

xyh 2 years atrás
parent
commit
7b40c4ae22

+ 7 - 0
cypress/e2e/department.cy.ts

@@ -9,6 +9,8 @@ import {
   validateDelete,
   successIntercept,
   intercept,
+  exportIntercept,
+  validateExport,
 } from './utils';
 
 describe('部门管理', function() {
@@ -39,6 +41,7 @@ describe('部门管理', function() {
     successIntercept('/department/addDepartment');
     successIntercept('/department/updateDepartment');
     successIntercept('/department/delDepartment');
+    exportIntercept('/department/export');
   });
 
   const TABLE_NAME = 'department_table',
@@ -85,4 +88,8 @@ describe('部门管理', function() {
   it('删除部门', function() {
     validateDelete(TABLE_NAME, LABEL);
   });
+
+  it('导出', function() {
+    validateExport();
+  });
 });

+ 7 - 0
cypress/e2e/goods.cy.ts

@@ -12,6 +12,8 @@ import {
   validateTableSearch,
   successIntercept,
   intercept,
+  exportIntercept,
+  validateExport,
 } from './utils';
 
 describe('货品管理', function() {
@@ -37,6 +39,7 @@ describe('货品管理', function() {
     successIntercept('/goods/addGoods');
     successIntercept('/goods/delGoods');
     successIntercept('/goods/updateGoods');
+    exportIntercept('/goods/export');
   });
 
   const TABLE_NAME = 'goods_table',
@@ -106,4 +109,8 @@ describe('货品管理', function() {
   it('删除', function() {
     validateDelete(TABLE_NAME, LABEL);
   });
+
+  it('导出', function() {
+    validateExport();
+  });
 });

+ 7 - 0
cypress/e2e/role.cy.ts

@@ -11,6 +11,8 @@ import {
   normalIntercept,
   intercept,
   tableBtnClick,
+  exportIntercept,
+  validateExport,
 } from './utils';
 
 describe('角色管理', function() {
@@ -37,6 +39,7 @@ describe('角色管理', function() {
     successIntercept('/role/updateRole');
     successIntercept('/role/delRole');
     normalIntercept('/menu/getMenu', 'menu/all');
+    exportIntercept('/role/export');
   });
 
   const TABLE_NAME = 'role_table',
@@ -98,4 +101,8 @@ describe('角色管理', function() {
     cy.get('.ant-message-notice-content').should('include.text', '设置成功');
     cy.getTestId('role_tree_modal').should('not.exist');
   });
+
+  it('导出', function() {
+    validateExport();
+  });
 });

+ 7 - 0
cypress/e2e/storage.cy.ts

@@ -11,6 +11,8 @@ import {
   validateTableSearch,
   successIntercept,
   intercept,
+  validateExport,
+  exportIntercept,
 } from './utils';
 
 describe('库位管理', function() {
@@ -48,6 +50,7 @@ describe('库位管理', function() {
     successIntercept('/storage/addStorage');
     successIntercept('/storage/updateStorage');
     successIntercept('/storage/delStorage');
+    exportIntercept('/storage/export');
   });
 
   const TABLE_NAME = 'storage_table',
@@ -108,4 +111,8 @@ describe('库位管理', function() {
       validateSelect('select_storageIsNotDisable', '启用');
     });
   });
+
+  it('导出', function() {
+    validateExport();
+  });
 });

+ 7 - 0
cypress/e2e/user.cy.ts

@@ -12,6 +12,8 @@ import {
   validateTableSearch,
   successIntercept,
   intercept,
+  validateExport,
+  exportIntercept,
 } from './utils';
 
 describe('用户管理', function() {
@@ -45,6 +47,7 @@ describe('用户管理', function() {
     successIntercept('/user/delUser');
     successIntercept('/user/addUser');
     successIntercept('/user/updateUser');
+    exportIntercept('/user/userExport');
   });
 
   const TABLE_NAME = 'user_table',
@@ -104,4 +107,8 @@ describe('用户管理', function() {
       validateSelect('select_userRole', '物流管理员');
     });
   });
+
+  it('导出', function() {
+    validateExport();
+  });
 });

+ 3 - 0
cypress/e2e/utils/setup.ts

@@ -61,3 +61,6 @@ export function optionsIntercept() {
   normalIntercept('/storage/getStorageAll', 'storage/options');
 }
 
+export function exportIntercept(url: string) {
+  successIntercept(url).as('export');
+}

+ 10 - 0
cypress/e2e/utils/utils.ts

@@ -130,3 +130,13 @@ export function validateDelete(
 
   cy.get('.ant-message-notice-content').should('include.text', '删除成功');
 }
+
+export function validateExport() {
+  cy.getTestId('export_btn').click();
+
+  cy.getTestId('export_btn').should('have.class', 'ant-btn-loading');
+
+  cy.wait('@export');
+
+  cy.getTestId('export_btn').should('not.have.class', 'ant-btn-loading');
+}

+ 2 - 2
package.json

@@ -23,8 +23,8 @@
     "test": "pnpm -F app test",
     "test:watch": "pnpm -F app test:watch",
     "test:coverage": "pnpm -F app test:coverage",
-    "e2e": "cypress open",
-    "e2e:run": "cypress run -b chrome"
+    "cypress": "cypress open",
+    "cypress:run": "cypress run -b chrome"
   },
   "devDependencies": {
     "@types/jest": "^29.2.5",

+ 8 - 1
packages/app/src/components/filter-button-group/index.tsx

@@ -34,7 +34,14 @@ const FiterButtonGroup: FC<Props> = function({
           >
             查询
           </Button>
-          {onExport && <Button loading={isExporting} type='default' onClick={onExport}>导出</Button>}
+          {onExport && <Button
+            data-testid='export_btn'
+            loading={isExporting}
+            type='default'
+            onClick={onExport}
+          >
+            导出
+          </Button>}
         </Space>
       </Col>
     </>