From b4145bff9e7262b301d43d0b2a0fab2710186e8e Mon Sep 17 00:00:00 2001 From: lizhensheng Date: Thu, 1 Feb 2024 18:09:26 +0800 Subject: [PATCH 1/2] [test]: (Data Export) Add unit tests for detail component --- .../__snapshots__/index.test.tsx.snap | 11657 ++++++++++++++++ .../Detail/__tests__/index.test.tsx | 99 + .../ResultCard/AuditResultTag.tsx | 0 .../ResultCard/AuditResultTree.tsx | 73 + .../__tests__/AuditResultTag.test.tsx | 44 + .../__tests__/AuditResultTree.test.tsx | 24 + .../AuditResultTag.test.tsx.snap | 1292 ++ .../AuditResultTree.test.tsx.snap | 559 + .../__snapshots__/index.test.tsx.snap | 295 + .../ResultCard/__tests__/index.test.tsx | 30 + .../ResultCard/index.tsx | 19 +- .../ResultCard/index.type.ts | 0 .../__snapshots__/index.test.tsx.snap | 2140 +++ .../ExportTaskList/index.test.tsx | 44 + .../{TaskDetail => ExportTaskList}/index.tsx | 10 +- .../__snapshots__/index.test.tsx.snap | 467 + .../ExportDetail/OverviewList/index.test.tsx | 95 + .../TaskDetail/ResultCard/AuditResultTree.tsx | 101 - .../__snapshots__/index.test.tsx.snap | 2801 ++++ .../ExportDetail/__tests__/index.test.tsx | 62 + .../Detail/components/ExportDetail/index.tsx | 4 +- .../Detail/components/ExportDetail/style.ts | 160 + .../__snapshots__/index.test.tsx.snap | 113 + .../PageHeaderAction/__tests__/index.test.tsx | 77 + .../__tests__/useActionButtonState.test.tsx | 227 + .../components/PageHeaderAction/index.tsx | 9 +- .../PageHeaderAction/useActionButtonState.ts | 16 +- .../__snapshots__/index.test.tsx.snap | 124 + .../RejectWorkflowModal/index.test.tsx | 94 + .../RejectWorkflowModal/index.tsx | 6 +- .../__snapshots__/index.test.tsx.snap | 39 + .../components/RejectReason/index.test.tsx | 30 + .../WorkflowHistorySteps.tsx | 36 - .../__snapshots__/index.test.tsx.snap | 421 + .../__tests__/index.test.tsx | 31 + .../__snapshots__/index.redux.test.ts.snap | 123 + .../hooks/__tests__/index.redux.test.ts | 125 + .../__tests__/useExportDetailAction.test.ts | 115 + .../__tests__/useInitDataWithRequest.test.ts | 103 + .../Detail/hooks/useExportDetailAction.ts | 6 +- .../Detail/hooks/useInitDataWithRequest.ts | 97 +- .../testUtils/mockUseActionButtonState.ts | 32 + .../mockUseDataExportDetailReduxManage.ts | 94 + .../testUtils/mockUseExportDetailAction.ts | 19 + .../src/testUtils/mockApi/dataExport/data.ts | 56 +- .../src/testUtils/mockApi/dataExport/index.ts | 45 + .../shared/lib/api/base/service/common.d.ts | 4 +- 47 files changed, 21778 insertions(+), 240 deletions(-) create mode 100644 packages/base/src/page/DataExportManagement/Detail/__tests__/__snapshots__/index.test.tsx.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/__tests__/index.test.tsx rename packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/{TaskDetail => ExportTaskList}/ResultCard/AuditResultTag.tsx (100%) create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/AuditResultTree.tsx create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/AuditResultTag.test.tsx create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/AuditResultTree.test.tsx create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/AuditResultTag.test.tsx.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/AuditResultTree.test.tsx.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/index.test.tsx.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/index.test.tsx rename packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/{TaskDetail => ExportTaskList}/ResultCard/index.tsx (86%) rename packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/{TaskDetail => ExportTaskList}/ResultCard/index.type.ts (100%) create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/__snapshots__/index.test.tsx.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/index.test.tsx rename packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/{TaskDetail => ExportTaskList}/index.tsx (90%) create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/OverviewList/__snapshots__/index.test.tsx.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/OverviewList/index.test.tsx delete mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/ResultCard/AuditResultTree.tsx create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/__tests__/__snapshots__/index.test.tsx.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/__tests__/index.test.tsx create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/__snapshots__/index.test.tsx.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/index.test.tsx create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/useActionButtonState.test.tsx create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/RejectReason/RejectWorkflowModal/__snapshots__/index.test.tsx.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/RejectReason/RejectWorkflowModal/index.test.tsx create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/RejectReason/__snapshots__/index.test.tsx.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/RejectReason/index.test.tsx delete mode 100644 packages/base/src/page/DataExportManagement/Detail/components/WorkflowRecordInfo/WorkflowHistorySteps.tsx create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/WorkflowRecordInfo/__tests__/__snapshots__/index.test.tsx.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/components/WorkflowRecordInfo/__tests__/index.test.tsx create mode 100644 packages/base/src/page/DataExportManagement/Detail/hooks/__tests__/__snapshots__/index.redux.test.ts.snap create mode 100644 packages/base/src/page/DataExportManagement/Detail/hooks/__tests__/index.redux.test.ts create mode 100644 packages/base/src/page/DataExportManagement/Detail/hooks/__tests__/useExportDetailAction.test.ts create mode 100644 packages/base/src/page/DataExportManagement/Detail/hooks/__tests__/useInitDataWithRequest.test.ts create mode 100644 packages/base/src/page/DataExportManagement/Detail/testUtils/mockUseActionButtonState.ts create mode 100644 packages/base/src/page/DataExportManagement/Detail/testUtils/mockUseDataExportDetailReduxManage.ts create mode 100644 packages/base/src/page/DataExportManagement/Detail/testUtils/mockUseExportDetailAction.ts diff --git a/packages/base/src/page/DataExportManagement/Detail/__tests__/__snapshots__/index.test.tsx.snap b/packages/base/src/page/DataExportManagement/Detail/__tests__/__snapshots__/index.test.tsx.snap new file mode 100644 index 000000000..d2e8146f7 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/__tests__/__snapshots__/index.test.tsx.snap @@ -0,0 +1,11657 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test base/DataExport/Detail should match snapshot 1`] = ` + +
+
+
+
+ + + + + + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + 导出成功 + +
+
+ mysql-1_20240130113114 +
+
+ desc +
+
+
+
+ 导出结果 +
+
+
+
+ + + + +
+
+
+
+
+
+
+
+ + + + + + +
+
+
+
+
+
+
+
    +
  • + + 共 0 条数据 + +
  • +
  • + +
  • +
  • + + 1 + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+
+
+
+
+
+ +`; + +exports[`test base/DataExport/Detail should match snapshot 2`] = ` + +
+
+
+
+ + + + + + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + 导出成功 + +
+
+ mysql-1_20240130113114 +
+
+ desc +
+
+
+
+ 导出结果 +
+
+
+
+ + + + +
+
+
+
+
+
+
+
    +
  • +
    +
    +
    +
    + + # + 1 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 2 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 3 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 4 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 5 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 6 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
+
+
+
+
    +
  • + + 共 6 条数据 + +
  • +
  • + +
  • +
  • + + 1 + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+
+
+
+
+
+ +`; + +exports[`test base/DataExport/Detail should match snapshot 3`] = ` + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + 导出成功 + +
+
+ mysql-1_20240130113114 +
+
+ desc +
+
+
+
+ 导出结果 +
+
+
+
+ + + + +
+
+
+
+
+
+
+
    +
  • +
    +
    +
    +
    + + # + 1 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 2 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 3 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 4 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 5 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 6 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
+
+
+
+
    +
  • + + 共 6 条数据 + +
  • +
  • + +
  • +
  • + + 1 + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+
+
+
+
+
+ +`; + +exports[`test base/DataExport/Detail should match snapshot 4`] = ` + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + 导出成功 + +
+
+ mysql-1_20240130113114 +
+
+ desc +
+
+
+
+ 导出结果 +
+
+
+
+ + + + +
+
+
+
+
+
+
+
    +
  • +
    +
    +
    +
    + + # + 1 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 2 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 3 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 4 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 5 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 6 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
+
+
+
+
    +
  • + + 共 6 条数据 + +
  • +
  • + +
  • +
  • + + 1 + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+
+
+
+
+
+ +`; + +exports[`test base/DataExport/Detail should match snapshot with reject workflow 1`] = ` + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + 已驳回 + +
+
+ mysql-1_20240130113114 +
+
+ desc +
+
+
+ + + +
+
+ admin驳回了当前工单,驳回原因为: + +
+
+ 当工单被驳回时,工单创建者需要对其进行修改,然后重新提交审核。(目前暂不支持修改工单。) +
+
+
+
+
+ 导出结果 +
+
+
+
+ + + + +
+
+
+
+
+
+
+
    +
  • +
    +
    +
    +
    + + # + 1 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 2 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 3 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 4 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 5 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 6 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                                  
    +                                    
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
+
+
+
+
    +
  • + + 共 6 条数据 + +
  • +
  • + +
  • +
  • + + 1 + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+
+
+
+
+
+ +`; diff --git a/packages/base/src/page/DataExportManagement/Detail/__tests__/index.test.tsx b/packages/base/src/page/DataExportManagement/Detail/__tests__/index.test.tsx new file mode 100644 index 000000000..f59f95a04 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/__tests__/index.test.tsx @@ -0,0 +1,99 @@ +import { useParams } from 'react-router-dom'; +import dataExport from '../../../../testUtils/mockApi/dataExport'; +import { + mockDataExportDetailRedux, + mockUseDataExportDetailReduxManage +} from '../testUtils/mockUseDataExportDetailReduxManage'; +import { superRender } from '../../../../testUtils/customRender'; +import WorkflowDetail from '..'; +import { act, fireEvent, screen } from '@testing-library/react'; +import { GetDataExportWorkflowResponseData } from '../../../../testUtils/mockApi/dataExport/data'; +import { + WorkflowRecordStatusEnum, + WorkflowStepStateEnum +} from '@actiontech/shared/lib/api/base/service/common.enum'; + +jest.mock('react-router-dom', () => { + return { + ...jest.requireActual('react-router-dom'), + useParams: jest.fn() + }; +}); + +describe('test base/DataExport/Detail', () => { + const workflowID = '1001'; + + const useParamsMock: jest.Mock = useParams as jest.Mock; + beforeEach(() => { + jest.useFakeTimers(); + mockUseDataExportDetailReduxManage(); + dataExport.GetDataExportWorkflow(); + dataExport.BatchGetDataExportTask(); + dataExport.ListDataExportTaskSQLs(); + useParamsMock.mockReturnValue({ workflowID }); + }); + + afterEach(() => { + jest.useRealTimers(); + jest.clearAllMocks(); + jest.clearAllTimers(); + }); + + it('should match snapshot', async () => { + const { baseElement } = superRender(); + expect(baseElement).toMatchSnapshot(); + + await act(async () => jest.advanceTimersByTime(3000)); + expect(baseElement).toMatchSnapshot(); + await act(async () => jest.advanceTimersByTime(3000)); + expect(baseElement).toMatchSnapshot(); + + fireEvent.click(screen.getByText('工单详情')); + expect(baseElement).toMatchSnapshot(); + }); + + it('should match snapshot with reject workflow', async () => { + const rejectWorkflowData = { + ...GetDataExportWorkflowResponseData, + workflow_record: { + ...GetDataExportWorkflowResponseData.workflow_record, + status: WorkflowRecordStatusEnum.rejected, + workflow_step_list: [ + { + number: 1, + type: '', + assignee_user_list: [ + { + uid: '700200', + name: 'admin' + } + ], + operation_user: { + uid: '700200', + name: 'admin' + }, + operation_time: '2024-01-30T11:32:12.271+08:00', + state: WorkflowStepStateEnum.rejected + } + ] + } + }; + mockUseDataExportDetailReduxManage({ workflowInfo: rejectWorkflowData }); + + const { baseElement } = superRender(); + await act(async () => jest.advanceTimersByTime(3000)); + await act(async () => jest.advanceTimersByTime(3000)); + expect(baseElement).toMatchSnapshot(); + expect( + screen.queryByText( + '当工单被驳回时,工单创建者需要对其进行修改,然后重新提交审核。(目前暂不支持修改工单。)' + ) + ).toBeInTheDocument(); + }); + + it('should executed clearAllDetailState when unmount component', () => { + const { unmount } = superRender(); + unmount(); + expect(mockDataExportDetailRedux.clearAllDetailState).toBeCalledTimes(1); + }); +}); diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/ResultCard/AuditResultTag.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/AuditResultTag.tsx similarity index 100% rename from packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/ResultCard/AuditResultTag.tsx rename to packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/AuditResultTag.tsx diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/AuditResultTree.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/AuditResultTree.tsx new file mode 100644 index 000000000..ab22d2103 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/AuditResultTree.tsx @@ -0,0 +1,73 @@ +import type { DataNode } from 'antd/es/tree'; +import { IconArrowDown } from '@actiontech/shared/lib/Icon'; +import { useMemo } from 'react'; +import { useTranslation } from 'react-i18next'; +import { IAuditSQLResult } from '@actiontech/shared/lib/api/base/service/common'; +import AuditResultMessage from 'sqle/src/components/AuditResultMessage'; +import { ExportResultTreeStyleWrapper } from '../../style'; + +const AuditResultTree: React.FC<{ auditResult?: IAuditSQLResult[] }> = ({ + auditResult +}) => { + const { t } = useTranslation(); + + const treeData: DataNode[] = useMemo(() => { + const defaultTreeData: DataNode[] = [ + { + title: ( + + {t('dmsDataExport.detail.exportResult.taskDetail.auditResult')} + + ), + key: 'audit_tree_title', + children: [ + { + title: '-', + key: 'empty_tree', + isLeaf: true + } + ] + } + ]; + if (!auditResult || !auditResult?.length) { + return defaultTreeData; + } + + return [ + { + title: ( + + {t('dmsDataExport.detail.exportResult.taskDetail.auditResult')} + + ), + key: 'audit_tree_title', + children: auditResult.map((item, index) => { + return { + title: ( + + ), + key: index, + isLeaf: true + }; + }) + } + ]; + }, [auditResult, t]); + + return ( + } + treeData={treeData} + selectable={false} + /> + ); +}; + +export default AuditResultTree; diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/AuditResultTag.test.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/AuditResultTag.test.tsx new file mode 100644 index 000000000..af6393565 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/AuditResultTag.test.tsx @@ -0,0 +1,44 @@ +import { RuleResV1LevelEnum } from '@actiontech/shared/lib/api/sqle/service/common.enum'; +import { superRender } from '../../../../../../../../testUtils/customRender'; +import AuditResultTag from '../AuditResultTag'; + +describe('test base/DataExport/Detail/ExportDetail/ExportTaskList/AuditResultTag', () => { + it('should match snapshot', () => { + expect(superRender()).toMatchSnapshot(); + expect( + superRender( + + ) + ).toMatchSnapshot(); + + expect( + superRender( + + ) + ).toMatchSnapshot(); + + expect( + superRender( + + ) + ).toMatchSnapshot(); + + expect( + superRender( + + ) + ).toMatchSnapshot(); + + expect( + superRender( + + ) + ).toMatchSnapshot(); + }); +}); diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/AuditResultTree.test.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/AuditResultTree.test.tsx new file mode 100644 index 000000000..4aef910b6 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/AuditResultTree.test.tsx @@ -0,0 +1,24 @@ +import { RuleResV1LevelEnum } from '@actiontech/shared/lib/api/sqle/service/common.enum'; +import { superRender } from '../../../../../../../../testUtils/customRender'; +import AuditResultTree from '../AuditResultTree'; + +describe('test base/DataExport/Detail/ExportDetail/ExportTaskList/AuditResultTree ', () => { + it('should match snapshot', () => { + expect(superRender()).toMatchSnapshot(); + + expect( + superRender( + + ) + ).toMatchSnapshot(); + }); +}); diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/AuditResultTag.test.tsx.snap b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/AuditResultTag.test.tsx.snap new file mode 100644 index 000000000..14deb936f --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/AuditResultTag.test.tsx.snap @@ -0,0 +1,1292 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test base/DataExport/Detail/ExportDetail/ExportTaskList/AuditResultTag should match snapshot 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+ + + + + + + + + + 审核通过 + + +
+ , + "container":
+ + + + + + + + + + 审核通过 + + +
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`test base/DataExport/Detail/ExportDetail/ExportTaskList/AuditResultTag should match snapshot 2`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+ + + + + + + + + + 审核通过 + + +
+
+
+
+ + + + + + + + + + 1 + + +
+
+
+ , + "container":
+
+
+ + + + + + + + + + 1 + + +
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`test base/DataExport/Detail/ExportDetail/ExportTaskList/AuditResultTag should match snapshot 3`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+ + + + + + + + + + 审核通过 + + +
+
+
+
+ + + + + + + + + + 1 + + +
+
+
+
+
+
+ , + "container":
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`test base/DataExport/Detail/ExportDetail/ExportTaskList/AuditResultTag should match snapshot 4`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+ + + + + + + + + + 审核通过 + + +
+
+
+
+ + + + + + + + + + 1 + + +
+
+
+
+
+
+
+
+
+ + + + + + + + + + 1 + + +
+
+
+ , + "container":
+
+
+ + + + + + + + + + 1 + + +
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`test base/DataExport/Detail/ExportDetail/ExportTaskList/AuditResultTag should match snapshot 5`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+ + + + + + + + + + 审核通过 + + +
+
+
+
+ + + + + + + + + + 1 + + +
+
+
+
+
+
+
+
+
+ + + + + + + + + + 1 + + +
+
+
+
+
+
+ + + + + + + + + + 1 + + +
+
+
+ , + "container":
+
+
+ + + + + + + + + + 1 + + +
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`test base/DataExport/Detail/ExportDetail/ExportTaskList/AuditResultTag should match snapshot 6`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+ + + + + + + + + + 审核通过 + + +
+
+
+
+ + + + + + + + + + 1 + + +
+
+
+
+
+
+
+
+
+ + + + + + + + + + 1 + + +
+
+
+
+
+
+ + + + + + + + + + 1 + + +
+
+
+
+
+
+ + + + + + + + + + 1 + + +
+
+ + + + + + + + + + 1 + + +
+
+ + + + + + + + + + 1 + + +
+
+
+ , + "container":
+
+
+ + + + + + + + + + 1 + + +
+
+ + + + + + + + + + 1 + + +
+
+ + + + + + + + + + 1 + + +
+
+
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/AuditResultTree.test.tsx.snap b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/AuditResultTree.test.tsx.snap new file mode 100644 index 000000000..e065d7651 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/AuditResultTree.test.tsx.snap @@ -0,0 +1,559 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test base/DataExport/Detail/ExportDetail/ExportTaskList/AuditResultTree should match snapshot 1`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+
+ +
+ +
+ , + "container":
+
+
+ +
+ +
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; + +exports[`test base/DataExport/Detail/ExportDetail/ExportTaskList/AuditResultTree should match snapshot 2`] = ` +Object { + "asFragment": [Function], + "baseElement": +
+
+
+ +
+ +
+
+
+
+ +
+ +
+ , + "container":
+
+
+ +
+ +
, + "debug": [Function], + "findAllByAltText": [Function], + "findAllByDisplayValue": [Function], + "findAllByLabelText": [Function], + "findAllByPlaceholderText": [Function], + "findAllByRole": [Function], + "findAllByTestId": [Function], + "findAllByText": [Function], + "findAllByTitle": [Function], + "findByAltText": [Function], + "findByDisplayValue": [Function], + "findByLabelText": [Function], + "findByPlaceholderText": [Function], + "findByRole": [Function], + "findByTestId": [Function], + "findByText": [Function], + "findByTitle": [Function], + "getAllByAltText": [Function], + "getAllByDisplayValue": [Function], + "getAllByLabelText": [Function], + "getAllByPlaceholderText": [Function], + "getAllByRole": [Function], + "getAllByTestId": [Function], + "getAllByText": [Function], + "getAllByTitle": [Function], + "getByAltText": [Function], + "getByDisplayValue": [Function], + "getByLabelText": [Function], + "getByPlaceholderText": [Function], + "getByRole": [Function], + "getByTestId": [Function], + "getByText": [Function], + "getByTitle": [Function], + "queryAllByAltText": [Function], + "queryAllByDisplayValue": [Function], + "queryAllByLabelText": [Function], + "queryAllByPlaceholderText": [Function], + "queryAllByRole": [Function], + "queryAllByTestId": [Function], + "queryAllByText": [Function], + "queryAllByTitle": [Function], + "queryByAltText": [Function], + "queryByDisplayValue": [Function], + "queryByLabelText": [Function], + "queryByPlaceholderText": [Function], + "queryByRole": [Function], + "queryByTestId": [Function], + "queryByText": [Function], + "queryByTitle": [Function], + "rerender": [Function], + "unmount": [Function], +} +`; diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/index.test.tsx.snap b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/index.test.tsx.snap new file mode 100644 index 000000000..d440e320f --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/__snapshots__/index.test.tsx.snap @@ -0,0 +1,295 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test base/DataExport/Detail/ExportTaskList/ResultCard should match snapshot 1`] = ` +
+
+
+
+
+ + # + 2 + +
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ 导出内容 +
+
+
+
+          
+            
+ + 1 + + + SELECT + + + + 1 + + ; +
+
+
+
+
+
+ +
+ +
+
+ +
+ +
+
+
+`; diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/index.test.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/index.test.tsx new file mode 100644 index 000000000..d9c7522e9 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/__tests__/index.test.tsx @@ -0,0 +1,30 @@ +import { fireEvent, screen } from '@testing-library/react'; +import ExportResultCard from '..'; +import { superRender } from '../../../../../../../../testUtils/customRender'; +import { ListDataExportTaskSQLsResponseData } from '../../../../../../../../testUtils/mockApi/dataExport/data'; +import { mockDataExportDetailRedux } from '../../../../../testUtils/mockUseDataExportDetailReduxManage'; +import { Copy } from '@actiontech/shared'; + +describe('test base/DataExport/Detail/ExportTaskList/ResultCard', () => { + it('should match snapshot', () => { + const mockCopyTextByTextareaSpy = jest.fn(); + jest + .spyOn(Copy, 'copyTextByTextarea') + .mockImplementation(mockCopyTextByTextareaSpy); + + const { container } = superRender( + + ); + + expect(container).toMatchSnapshot(); + + fireEvent.click(screen.getAllByText('复制SQL语句')[0]); + expect(mockCopyTextByTextareaSpy).toBeCalledTimes(1); + expect(mockCopyTextByTextareaSpy).toBeCalledWith( + ListDataExportTaskSQLsResponseData[1].sql + ); + }); +}); diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/ResultCard/index.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/index.tsx similarity index 86% rename from packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/ResultCard/index.tsx rename to packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/index.tsx index 8c052cb0c..ff021bb3c 100644 --- a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/ResultCard/index.tsx +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/index.tsx @@ -6,9 +6,11 @@ import HighlightCode from 'sqle/src/utils/HighlightCode'; import AuditResultTree from './AuditResultTree'; import { ExportContentStyleWrapper, - ExportResultCardStyleWrapper + ExportResultCardStyleWrapper, + ExportResultTreeStyleWrapper } from '../../style'; import AuditResultTag from './AuditResultTag'; +import { IconArrowDown } from '@actiontech/shared/lib/Icon'; const ExportResultCard: React.FC = (props) => { const { t } = useTranslation(); @@ -61,26 +63,23 @@ const ExportResultCard: React.FC = (props) => {
- {/* 后端暂时给不到数据,先隐藏 */} - {/* - } - /> */} + switcherIcon={} + />
); diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/ResultCard/index.type.ts b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/index.type.ts similarity index 100% rename from packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/ResultCard/index.type.ts rename to packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/ResultCard/index.type.ts diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/__snapshots__/index.test.tsx.snap b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/__snapshots__/index.test.tsx.snap new file mode 100644 index 000000000..072e4b685 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/__snapshots__/index.test.tsx.snap @@ -0,0 +1,2140 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test ExportTaskList should match snapshot 1`] = ` +
+
+
+
+
+
+ + + + + + +
+
+
+
+
+
+
+
    +
  • + + 共 0 条数据 + +
  • +
  • + +
  • +
  • + + 1 + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+`; + +exports[`test ExportTaskList should match snapshot 2`] = ` +
+
+
+
+
+
    +
  • +
    +
    +
    +
    + + # + 1 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                      
    +                        
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 2 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                      
    +                        
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 3 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                      
    +                        
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 4 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                      
    +                        
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 5 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                      
    +                        
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 6 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                      
    +                        
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
+
+
+
+
    +
  • + + 共 6 条数据 + +
  • +
  • + +
  • +
  • + + 1 + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+`; diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/index.test.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/index.test.tsx new file mode 100644 index 000000000..6827c277b --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/index.test.tsx @@ -0,0 +1,44 @@ +import { mockUseCurrentProject } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentProject'; +import { + mockDataExportDetailRedux, + mockUseDataExportDetailReduxManage +} from '../../../testUtils/mockUseDataExportDetailReduxManage'; +import dataExport from '../../../../../../testUtils/mockApi/dataExport'; +import { superRender } from '../../../../../../testUtils/customRender'; +import ExportTaskList from '.'; +import { act } from '@testing-library/react'; +import { mockProjectInfo } from '@actiontech/shared/lib/testUtil/mockHook/data'; + +describe('test ExportTaskList', () => { + let getDataExportTaskSQLsSpy: jest.SpyInstance; + beforeEach(() => { + jest.useFakeTimers(); + getDataExportTaskSQLsSpy = dataExport.ListDataExportTaskSQLs(); + mockUseCurrentProject(); + mockUseDataExportDetailReduxManage(); + }); + + afterEach(() => { + jest.useRealTimers(); + jest.clearAllMocks(); + jest.clearAllTimers(); + }); + + it('should match snapshot', async () => { + const { container } = superRender(); + + expect(container).toMatchSnapshot(); + + await act(async () => jest.advanceTimersByTime(3000)); + expect(getDataExportTaskSQLsSpy).toBeCalledTimes(1); + + expect(getDataExportTaskSQLsSpy).toBeCalledWith({ + project_uid: mockProjectInfo.projectID, + data_export_task_uid: mockDataExportDetailRedux.curTaskID, + page_index: 1, + page_size: 20 + }); + + expect(container).toMatchSnapshot(); + }); +}); diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/index.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/index.tsx similarity index 90% rename from packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/index.tsx rename to packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/index.tsx index 49e2b7854..14d84fb46 100644 --- a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/index.tsx +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/ExportTaskList/index.tsx @@ -1,5 +1,4 @@ import { List, Result } from 'antd'; -import { DataSourceResultListStyleWrapper } from 'sqle/src/page/Order/AuditDetail/style'; import useDataExportDetailReduxManage from '../../../hooks/index.redux'; import { useRequest } from 'ahooks'; import dms from '@actiontech/shared/lib/api/base/service/dms'; @@ -10,8 +9,9 @@ import { import { useCurrentProject } from '@actiontech/shared/lib/global'; import { useTranslation } from 'react-i18next'; import ResultCard from './ResultCard'; +import { ExportTaskListStyleWrapper } from '../style'; -const TaskDetail: React.FC = () => { +const ExportTaskList: React.FC = () => { const { t } = useTranslation(); const { projectID } = useCurrentProject(); const { pagination } = useTableRequestParams(); @@ -34,7 +34,7 @@ const TaskDetail: React.FC = () => { } ); return ( - + { ) }} /> - + ); }; -export default TaskDetail; +export default ExportTaskList; diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/OverviewList/__snapshots__/index.test.tsx.snap b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/OverviewList/__snapshots__/index.test.tsx.snap new file mode 100644 index 000000000..bf91f2580 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/OverviewList/__snapshots__/index.test.tsx.snap @@ -0,0 +1,467 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test base/DataExport/Detail/OverviewList should match snapshot 1`] = ` +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 数据源 + + 状态 + + 导出方式 + + 导出文件类型 + + 导出开始时间 + + 导出结束时间 + +
+
+ 操作 +
+
+ + + +
+
+
+ mysql-1 + +
+ + + + + + + + 导出成功 + +
+
+ SQL + + CSV + + 2024-01-30 11:32:15 + + 2024-01-30 11:32:15 + +
+
+
+ +
+
+
+
+ mysql-1 + +
+ + + + + + + + 正在导出 + +
+
+ SQL + + CSV + + 2024-01-30 11:32:15 + + 2024-01-30 11:32:15 + +
+
+
+ +
+
+
+
+ mysql-1 + +
+ + + + + + + + + 导出失败 + +
+
+ SQL + + CSV + + 2024-01-30 11:32:15 + + 2024-01-30 11:32:15 + +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+`; diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/OverviewList/index.test.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/OverviewList/index.test.tsx new file mode 100644 index 000000000..79c2d9c28 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/OverviewList/index.test.tsx @@ -0,0 +1,95 @@ +import { mockUseCurrentProject } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentProject'; +import { mockUseCurrentUser } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentUser'; +import { + mockDataExportDetailRedux, + mockUseDataExportDetailReduxManage +} from '../../../testUtils/mockUseDataExportDetailReduxManage'; +import { superRender } from '../../../../../../testUtils/customRender'; +import OverviewList from '.'; +import { act, fireEvent, screen } from '@testing-library/react'; +import { getAllBySelector } from '@actiontech/shared/lib/testUtil/customQuery'; +import dataExport from '../../../../../../testUtils/mockApi/dataExport'; +import { mockProjectInfo } from '@actiontech/shared/lib/testUtil/mockHook/data'; +import MockDate from 'mockdate'; + +describe('test base/DataExport/Detail/OverviewList', () => { + beforeEach(() => { + MockDate.set('2024-01-30 10:00:00'); + jest.useFakeTimers(); + mockUseCurrentProject(); + mockUseCurrentUser({ + uid: mockDataExportDetailRedux.workflowInfo.create_user?.uid + }); + + mockUseDataExportDetailReduxManage(); + }); + + afterEach(() => { + jest.clearAllMocks(); + jest.clearAllTimers(); + jest.useFakeTimers(); + MockDate.reset(); + }); + + it('should match snapshot', () => { + const { container } = superRender(); + + expect(container).toMatchSnapshot(); + + fireEvent.click(getAllBySelector('.ant-table-row')[0]); + expect(mockDataExportDetailRedux.updateCurTaskID).toBeCalledTimes(1); + expect(mockDataExportDetailRedux.updateCurTaskID).toBeCalledWith( + mockDataExportDetailRedux.taskInfos[0].task_uid + ); + }); + + it('should not render download button when current user is not workflow creator', () => { + mockUseCurrentUser({ + uid: mockDataExportDetailRedux.workflowInfo.create_user?.uid + '1' + }); + + superRender(); + expect(screen.queryByText('操作')).not.toBeInTheDocument(); + expect(screen.queryByText('下载数据')).not.toBeInTheDocument(); + }); + + it('should send download request when click download button', async () => { + const downloadSpy = dataExport.DownloadDataExportTask(); + superRender(); + expect(screen.queryByText('操作')).toBeInTheDocument(); + + fireEvent.click(screen.getAllByText('下载数据')[0]); + expect(mockDataExportDetailRedux.updateCurTaskID).not.toBeCalled(); + + expect(screen.getAllByText('下载数据')[1].closest('button')).toHaveClass( + 'ant-btn-loading' + ); + + expect(downloadSpy).toBeCalledTimes(1); + expect(downloadSpy).toBeCalledWith( + { + project_uid: mockProjectInfo.projectID, + data_export_task_uid: mockDataExportDetailRedux.taskInfos[0].task_uid + }, + { responseType: 'blob' } + ); + await act(async () => jest.advanceTimersByTime(3000)); + expect( + screen.getAllByText('下载数据')[1].closest('button') + ).not.toHaveClass('ant-btn-loading'); + }); + + it('should disabled when workflow status is not finish or export time has expired', () => { + const downloadSpy = dataExport.DownloadDataExportTask(); + MockDate.set('2024-01-31 15:00:00'); + superRender(); + + expect(screen.getAllByText('下载数据')[0].closest('button')).toBeDisabled(); + + expect(screen.getAllByText('下载数据')[1].closest('button')).toBeDisabled(); + + expect(downloadSpy).toBeCalledTimes(0); + + MockDate.reset(); + }); +}); diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/ResultCard/AuditResultTree.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/ResultCard/AuditResultTree.tsx deleted file mode 100644 index 77460a53c..000000000 --- a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/TaskDetail/ResultCard/AuditResultTree.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import type { DataNode } from 'antd/es/tree'; -import { IconArrowDown } from '@actiontech/shared/lib/Icon'; -import { useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import rule_template from '@actiontech/shared/lib/api/sqle/service/rule_template/index'; -import { ResponseCode } from '@actiontech/shared/lib/enum'; -import { IAuditSQLResult } from '@actiontech/shared/lib/api/base/service/common'; -import AuditResultMessage from 'sqle/src/components/AuditResultMessage'; -import { DataSourceAuditResultTreeStyleWrapper } from 'sqle/src/page/Order/AuditDetail/style'; - -const AuditResultTree: React.FC<{ auditResult?: IAuditSQLResult[] }> = ({ - auditResult -}) => { - const { t } = useTranslation(); - - const [treeData, setTreeData] = useState([ - { - title: ( - - {t('dmsDataExport.detail.exportResult.taskDetail.auditResult')} - - ), - key: 'audit_tree_title', - children: [ - { - title: '-', - key: 'empty_tree', - isLeaf: true - } - ] - } - ]); - - const onLoadData = (node: DataNode) => { - const filterRuleNames = ( - auditResult?.map((v) => v.rule_name ?? '') ?? [] - ).filter((v) => !!v); - - if (!filterRuleNames.length) { - return Promise.resolve(); - } - return rule_template - .getRuleListV1({ - filter_rule_names: filterRuleNames.join(',') - }) - .then((res) => { - if (res.data.code === ResponseCode.SUCCESS) { - const { data } = res.data; - const newResult = auditResult?.map((item) => { - return { - annotation: - data?.find( - (i) => - i.rule_name === item.rule_name && i.db_type === item.db_type - )?.annotation ?? '', - ...item - }; - }); - - if (newResult) { - setTreeData([ - { - ...node, - children: newResult.map((item, index) => { - return { - title: ( - - ), - key: index, - isLeaf: true - }; - }) - } - ]); - } - } - }); - }; - - return ( - } - treeData={treeData} - selectable={false} - loadData={onLoadData} - > - ); -}; - -export default AuditResultTree; diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/__tests__/__snapshots__/index.test.tsx.snap b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/__tests__/__snapshots__/index.test.tsx.snap new file mode 100644 index 000000000..d7ebba217 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/__tests__/__snapshots__/index.test.tsx.snap @@ -0,0 +1,2801 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test base/DataExport/Detail/ExportDetail should match snapshot 1`] = ` +
+
+
+ 导出结果 +
+
+
+
+ + + + +
+
+
+
+
+
+
+
+ + + + + + +
+
+
+
+
+
+
+
    +
  • + + 共 0 条数据 + +
  • +
  • + +
  • +
  • + + 1 + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+
+`; + +exports[`test base/DataExport/Detail/ExportDetail should match snapshot 2`] = ` +
+
+
+ 导出结果 +
+
+
+
+ + + + +
+
+
+
+
+
+
+
    +
  • +
    +
    +
    +
    + + # + 1 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                        
    +                          
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 2 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                        
    +                          
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 3 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                        
    +                          
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 4 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                        
    +                          
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 5 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                        
    +                          
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
  • +
    +
    +
    +
    + + # + 6 + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + 导出内容 +
    +
    +
    +
    +                        
    +                          
    + + 1 + + + SELECT + + + + 1 + + ; +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
  • +
+
+
+
+
    +
  • + + 共 6 条数据 + +
  • +
  • + +
  • +
  • + + 1 + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+
+`; + +exports[`test base/DataExport/Detail/ExportDetail should match snapshot when curTaskID is undefined 1`] = ` +
+
+
+ 导出结果 +
+
+
+
+ + + + +
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 数据源 + + 状态 + + 导出方式 + + 导出文件类型 + + 导出开始时间 + + 导出结束时间 +
+ mysql-1 + +
+ + + + + + + + 导出成功 + +
+
+ SQL + + CSV + + 2024-01-30 11:32:15 + + 2024-01-30 11:32:15 +
+ mysql-1 + +
+ + + + + + + + 正在导出 + +
+
+ SQL + + CSV + + 2024-01-30 11:32:15 + + 2024-01-30 11:32:15 +
+ mysql-1 + +
+ + + + + + + + + 导出失败 + +
+
+ SQL + + CSV + + 2024-01-30 11:32:15 + + 2024-01-30 11:32:15 +
+
+
+
+
+
+
+
+
+`; diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/__tests__/index.test.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/__tests__/index.test.tsx new file mode 100644 index 000000000..7d57fbac0 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/__tests__/index.test.tsx @@ -0,0 +1,62 @@ +import { act, fireEvent, screen, waitFor } from '@testing-library/react'; +import ExportDetail from '..'; +import { superRender } from '../../../../../../testUtils/customRender'; +import dataExport from '../../../../../../testUtils/mockApi/dataExport'; +import { + mockDataExportDetailRedux, + mockUseDataExportDetailReduxManage +} from '../../../testUtils/mockUseDataExportDetailReduxManage'; +import { mockUseCurrentProject } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentProject'; +import { mockProjectInfo } from '@actiontech/shared/lib/testUtil/mockHook/data'; +import { getAllBySelector } from '@actiontech/shared/lib/testUtil/customQuery'; + +describe('test base/DataExport/Detail/ExportDetail', () => { + let getDataExportTaskSQLs: jest.SpyInstance; + beforeEach(() => { + jest.useFakeTimers(); + mockUseCurrentProject(); + getDataExportTaskSQLs = dataExport.ListDataExportTaskSQLs(); + }); + + afterEach(() => { + jest.clearAllMocks(); + jest.useRealTimers(); + jest.clearAllTimers(); + }); + it('should match snapshot', async () => { + mockUseDataExportDetailReduxManage(); + + const { container } = superRender(); + expect(container).toMatchSnapshot(); + + expect(getDataExportTaskSQLs).toBeCalledTimes(1); + expect(getDataExportTaskSQLs).toBeCalledWith({ + project_uid: mockProjectInfo.projectID, + data_export_task_uid: mockDataExportDetailRedux.curTaskID, + page_size: 20, + page_index: 1 + }); + await act(async () => jest.advanceTimersByTime(3000)); + expect(container).toMatchSnapshot(); + + fireEvent.click(screen.getByText('概览')); + expect(mockDataExportDetailRedux.updateCurTaskID).toBeCalledTimes(1); + expect(mockDataExportDetailRedux.updateCurTaskID).toBeCalledWith(null); + }); + + it('should match snapshot when curTaskID is undefined', async () => { + mockUseDataExportDetailReduxManage({ curTaskID: undefined }); + + const { container } = superRender(); + expect(container).toMatchSnapshot(); + expect(getDataExportTaskSQLs).toBeCalledTimes(0); + await act(async () => jest.advanceTimersByTime(3000)); + + fireEvent.click(getAllBySelector('.db-service-segmented-label-text')[1]); + + expect(mockDataExportDetailRedux.updateCurTaskID).toBeCalledTimes(1); + expect(mockDataExportDetailRedux.updateCurTaskID).toBeCalledWith( + mockDataExportDetailRedux.taskInfos[1].task_uid + ); + }); +}); diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/index.tsx b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/index.tsx index 5a63a4163..5a86be9a4 100644 --- a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/index.tsx +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/index.tsx @@ -4,7 +4,7 @@ import { SegmentedRowStyleWrapper } from '@actiontech/shared/lib/styleWrapper/el import { BasicSegmented, EmptyBox } from '@actiontech/shared'; import useDataExportDetailReduxManage from '../../hooks/index.redux'; import OverviewList from './OverviewList'; -import TaskDetail from './TaskDetail'; +import ExportTaskList from './ExportTaskList'; import DbServiceSegmentedLabel from '../../../Common/DbServiceSegmentedLabel'; import { AuditTaskResV1AuditLevelEnum } from '@actiontech/shared/lib/api/sqle/service/common.enum'; @@ -64,7 +64,7 @@ const ExportDetail: React.FC = () => { }> - + ); diff --git a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/style.ts b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/style.ts index 886431c69..ba393abe4 100644 --- a/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/style.ts +++ b/packages/base/src/page/DataExportManagement/Detail/components/ExportDetail/style.ts @@ -1,4 +1,5 @@ import { styled } from '@mui/material/styles'; +import { Tree } from 'antd'; export const WorkflowDetailExportResultStyleWrapper = styled('section')` margin-top: 40px; @@ -19,6 +20,119 @@ export const WorkflowDetailExportResultStyleWrapper = styled('section')` } `; +export const ExportTaskListStyleWrapper = styled('div')` + padding: 0 40px; + margin-bottom: 80px; + + &.data-source-result-scroll-infinite-list { + margin-bottom: 0; + } + + & .ant-list-items .ant-list-item { + padding: 0; + } + + & .data-source-result-list-pagination.result-list-pagination.ant-pagination { + justify-content: space-between; + margin: 0 !important; + padding: 16px 40px; + background-color: ${({ theme }) => + theme.sharedTheme.components.table.pagination.backgroundColor}; + border-top: ${({ theme }) => + theme.sharedTheme.components.table.pagination.border}; + position: fixed; + z-index: 999; + right: 0; + bottom: 0; + width: calc(100% - 220px); + display: flex; + + &::before { + content: ''; + flex: 1; + } + + .ant-pagination-total-text { + color: ${({ theme }) => + theme.sharedTheme.components.table.pagination.total.color}; + order: -1; + } + + .ant-pagination-prev { + margin-inline-end: 8px; + } + + .ant-pagination-item { + margin-inline-end: 8px; + + &:hover { + background-color: ${({ theme }) => + theme.sharedTheme.components.table.pagination.item + .hoverBackgroundColor}; + } + + a { + color: ${({ theme }) => + theme.sharedTheme.components.table.pagination.item.color}; + } + } + + .ant-pagination-item-active { + border: ${({ theme }) => + theme.sharedTheme.components.table.pagination.item.activeBorder}; + background-color: ${({ theme }) => + theme.sharedTheme.components.table.pagination.item + .activeBackgroundColor}; + + a { + color: ${({ theme }) => + theme.sharedTheme.components.table.pagination.item.activeColor}; + } + } + + .ant-pagination-options { + .ant-pagination-options-size-changer { + &:not(.ant-select-focused) { + .ant-select-selector:hover { + border: ${({ theme }) => + theme.sharedTheme.components.table.pagination.options + .hoverBorder}; + } + } + + .ant-select-selector { + height: 28px; + line-height: 28px; + padding: 0 8px; + width: 96px; + background-color: ${({ theme }) => + theme.sharedTheme.components.table.pagination.options + .backgroundColor}; + border: ${({ theme }) => + theme.sharedTheme.components.table.pagination.options.border}; + box-shadow: ${({ theme }) => + theme.sharedTheme.components.table.pagination.options.boxShadow}; + + .ant-select-selection-item { + padding-inline-start: 4px; + padding-inline-end: 0; + display: flex; + align-items: center; + color: ${({ theme }) => + theme.sharedTheme.components.table.pagination.options.itemColor}; + } + + .ant-select-selection-search { + input { + height: 28px; + } + } + } + } + } + } +`; + export const ExportResultCardStyleWrapper = styled('div')` width: 100%; border-radius: 8px; @@ -111,3 +225,49 @@ export const ExportContentStyleWrapper = styled('div')<{ : theme.sharedTheme.uiToken.colorTextTertiary}; margin-right: 4px; `; + +export const ExportResultTreeStyleWrapper = styled(Tree)` + &.ant-tree { + .ant-tree-indent { + display: none; + } + + .ant-tree-node-selected { + background-color: transparent !important; + } + + .ant-tree-switcher .ant-tree-switcher-leaf-line { + &::before { + border-right: 1px solid + ${({ theme }) => theme.sharedTheme.basic.colorGrayLine}; + } + + &::after { + border-bottom: 1px solid + ${({ theme }) => theme.sharedTheme.basic.colorGrayLine}; + } + } + + .ant-tree-switcher { + display: flex; + align-items: center; + justify-content: center; + + .ant-tree-switcher-icon { + margin-bottom: 2px; + } + } + + .audit-result-tree-title { + color: ${({ theme }) => theme.sharedTheme.uiToken.colorTextBase}; + } + + .audit-result-text-describe { + margin-left: 12px; + } + + .custom-icon-arrow-down { + color: ${({ theme }) => theme.sharedTheme.basic.colorFontGrayByWhite}; + } + } +`; diff --git a/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/__snapshots__/index.test.tsx.snap b/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/__snapshots__/index.test.tsx.snap new file mode 100644 index 000000000..266537902 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/__snapshots__/index.test.tsx.snap @@ -0,0 +1,113 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test base/DataExport/Detail/PageHeaderAction clicked workflow detail button 1`] = ` +
+
+
+ + + + + + +
+`; + +exports[`test base/DataExport/Detail/PageHeaderAction should match snapshot 1`] = ` +
+
+
+ + + + + + +
+`; diff --git a/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/index.test.tsx b/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/index.test.tsx new file mode 100644 index 000000000..e90b8bbc4 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/index.test.tsx @@ -0,0 +1,77 @@ +import { mockUseCurrentProject } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentProject'; +import { + mockActionButtonStateData, + mockUseActionButtonState +} from '../../../testUtils/mockUseActionButtonState'; +import { superRender } from '../../../../../../testUtils/customRender'; +import ExportDetailPageHeaderAction from '..'; +import { + mockDataExportDetailRedux, + mockUseDataExportDetailReduxManage +} from '../../../testUtils/mockUseDataExportDetailReduxManage'; +import { fireEvent, screen } from '@testing-library/react'; + +describe('test base/DataExport/Detail/PageHeaderAction', () => { + beforeEach(() => { + mockUseCurrentProject(); + mockUseActionButtonState(); + mockUseDataExportDetailReduxManage(); + }); + afterEach(() => { + jest.clearAllMocks(); + jest.clearAllTimers(); + }); + + it('should match snapshot', () => { + const { container } = superRender(); + expect(container).toMatchSnapshot(); + }); + + it('clicked workflow detail button', () => { + const { container } = superRender(); + fireEvent.click(screen.getByText('工单详情')); + expect(mockDataExportDetailRedux.updateWorkflowStepOpen).toBeCalledTimes(1); + expect(mockDataExportDetailRedux.updateWorkflowStepOpen).toBeCalledWith( + true + ); + expect(container).toMatchSnapshot(); + }); + + it('clicked close workflow button', () => { + superRender(); + fireEvent.click(screen.getByText('关闭工单')); + expect( + mockActionButtonStateData.closeWorkflowButtonMeta.action + ).toBeCalledTimes(1); + }); + + it('clicked approve workflow button', () => { + superRender(); + fireEvent.click(screen.getByText('审核通过')); + expect( + mockActionButtonStateData.approveWorkflowButtonMeta.action + ).toBeCalledTimes(1); + }); + + it('clicked rejected workflow button', () => { + superRender(); + fireEvent.click(screen.getByText('审核驳回')); + expect( + mockActionButtonStateData.rejectWorkflowButtonMeta.action + ).toBeCalledTimes(1); + }); + + it('clicked execute export workflow button', () => { + superRender(); + fireEvent.click(screen.getByText('执行导出')); + expect( + screen.queryByText( + '当前操作将立即执行导出工单下的所有任务,是否确认立即执行导出?' + ) + ).toBeInTheDocument(); + fireEvent.click(screen.getByText('确 认')); + expect( + mockActionButtonStateData.executeExportButtonMeta.action + ).toBeCalledTimes(1); + }); +}); diff --git a/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/useActionButtonState.test.tsx b/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/useActionButtonState.test.tsx new file mode 100644 index 000000000..981cbb4c2 --- /dev/null +++ b/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/__tests__/useActionButtonState.test.tsx @@ -0,0 +1,227 @@ +import { cleanup, renderHook } from '@testing-library/react'; +import useActionButtonState from '../useActionButtonState'; +import { + mockDataExportDetailRedux, + mockUseDataExportDetailReduxManage +} from '../../../testUtils/mockUseDataExportDetailReduxManage'; +import { mockUseCurrentUser } from '@actiontech/shared/lib/testUtil/mockHook/mockUseCurrentUser'; +import { + mockExportDetailActionData, + mockUseExportDetailAction +} from '../../../testUtils/mockUseExportDetailAction'; +import { IGetDataExportWorkflow } from '@actiontech/shared/lib/api/base/service/common'; +import { GetDataExportWorkflowResponseData } from '../../../../../../testUtils/mockApi/dataExport/data'; +import { WorkflowRecordStatusEnum } from '@actiontech/shared/lib/api/base/service/common.enum'; + +const notExistCurrentStepWorkflowInfo: IGetDataExportWorkflow = { + ...GetDataExportWorkflowResponseData, + workflow_record: { + ...GetDataExportWorkflowResponseData.workflow_record, + current_step_number: undefined + } +}; + +const waitForApproveStatusWorkflow: IGetDataExportWorkflow = { + ...GetDataExportWorkflowResponseData, + workflow_record: { + ...GetDataExportWorkflowResponseData.workflow_record, + status: WorkflowRecordStatusEnum.wait_for_approve + } +}; + +const rejectedStatusWorkflow: IGetDataExportWorkflow = { + ...GetDataExportWorkflowResponseData, + workflow_record: { + ...GetDataExportWorkflowResponseData.workflow_record, + status: WorkflowRecordStatusEnum.rejected + } +}; + +const waitForExportStatusWorkflow: IGetDataExportWorkflow = { + ...GetDataExportWorkflowResponseData, + workflow_record: { + ...GetDataExportWorkflowResponseData.workflow_record, + status: WorkflowRecordStatusEnum.wait_for_export + } +}; + +describe('test useActionButtonState', () => { + const messageApiSpy = { + info: jest.fn(), + success: jest.fn(), + error: jest.fn(), + warning: jest.fn(), + loading: jest.fn(), + open: jest.fn(), + destroy: jest.fn() + }; + + beforeEach(() => { + mockUseCurrentUser({ + uid: '700200' + }); + mockUseExportDetailAction(); + mockUseDataExportDetailReduxManage(); + }); + afterEach(() => { + jest.clearAllMocks(); + jest.clearAllTimers(); + }); + + it('render currentStep is undefined', () => { + mockUseDataExportDetailReduxManage({ + workflowInfo: notExistCurrentStepWorkflowInfo + }); + const { result } = renderHook(() => useActionButtonState(messageApiSpy)); + expect(result.current.approveWorkflowButtonMeta.hidden).toBeTruthy(); + expect(result.current.closeWorkflowButtonMeta.hidden).toBeTruthy(); + expect(result.current.approveWorkflowButtonMeta.hidden).toBeTruthy(); + expect(result.current.executeExportButtonMeta.hidden).toBeTruthy(); + }); + + it('render current user is not in workflow assignee user list', () => { + mockUseCurrentUser({ + uid: '7002001' + }); + + const { result } = renderHook(() => useActionButtonState(messageApiSpy)); + expect(result.current.approveWorkflowButtonMeta.hidden).toBeTruthy(); + expect(result.current.closeWorkflowButtonMeta.hidden).toBeTruthy(); + expect(result.current.approveWorkflowButtonMeta.hidden).toBeTruthy(); + }); + + it('render current user is not workflow creator', () => { + mockUseCurrentUser({ + uid: '7002001' + }); + const { result } = renderHook(() => useActionButtonState(messageApiSpy)); + expect(result.current.executeExportButtonMeta.hidden).toBeTruthy(); + }); + + it('render show close button', () => { + mockUseDataExportDetailReduxManage({ + workflowInfo: waitForApproveStatusWorkflow + }); + expect( + renderHook(() => useActionButtonState(messageApiSpy)).result.current + .closeWorkflowButtonMeta.hidden + ).toBeFalsy(); + + cleanup(); + jest.clearAllMocks(); + + mockUseDataExportDetailReduxManage({ + workflowInfo: rejectedStatusWorkflow + }); + + expect( + renderHook(() => useActionButtonState(messageApiSpy)).result.current + .closeWorkflowButtonMeta.hidden + ).toBeFalsy(); + + cleanup(); + jest.clearAllMocks(); + + mockUseDataExportDetailReduxManage({ + workflowInfo: waitForExportStatusWorkflow + }); + + expect( + renderHook(() => useActionButtonState(messageApiSpy)).result.current + .closeWorkflowButtonMeta.hidden + ).toBeTruthy(); + }); + + it('render show approve button', () => { + mockUseDataExportDetailReduxManage({ + workflowInfo: waitForApproveStatusWorkflow + }); + expect( + renderHook(() => useActionButtonState(messageApiSpy)).result.current + .approveWorkflowButtonMeta.hidden + ).toBeFalsy(); + + cleanup(); + jest.clearAllMocks(); + + mockUseDataExportDetailReduxManage({ + workflowInfo: rejectedStatusWorkflow + }); + + expect( + renderHook(() => useActionButtonState(messageApiSpy)).result.current + .approveWorkflowButtonMeta.hidden + ).toBeTruthy(); + }); + + it('render show reject button', () => { + mockUseDataExportDetailReduxManage({ + workflowInfo: waitForApproveStatusWorkflow + }); + expect( + renderHook(() => useActionButtonState(messageApiSpy)).result.current + .rejectWorkflowButtonMeta.hidden + ).toBeFalsy(); + + cleanup(); + jest.clearAllMocks(); + + mockUseDataExportDetailReduxManage({ + workflowInfo: rejectedStatusWorkflow + }); + + expect( + renderHook(() => useActionButtonState(messageApiSpy)).result.current + .rejectWorkflowButtonMeta.hidden + ).toBeTruthy(); + }); + + it('render show execute export button', () => { + mockUseDataExportDetailReduxManage({ + workflowInfo: waitForApproveStatusWorkflow + }); + expect( + renderHook(() => useActionButtonState(messageApiSpy)).result.current + .executeExportButtonMeta.hidden + ).toBeTruthy(); + + cleanup(); + jest.clearAllMocks(); + + mockUseDataExportDetailReduxManage({ + workflowInfo: waitForExportStatusWorkflow + }); + + expect( + renderHook(() => useActionButtonState(messageApiSpy)).result.current + .executeExportButtonMeta.hidden + ).toBeFalsy(); + }); + + it('execute button action', () => { + const workflowID = GetDataExportWorkflowResponseData.workflow_uid; + const { result } = renderHook(() => useActionButtonState(messageApiSpy)); + + result.current.approveWorkflowButtonMeta.action(); + expect(mockExportDetailActionData.approveWorkflow).toBeCalledTimes(1); + expect(mockExportDetailActionData.approveWorkflow).toBeCalledWith( + workflowID + ); + + result.current.closeWorkflowButtonMeta.action(); + expect(mockExportDetailActionData.closeWorkflow).toBeCalledTimes(1); + expect(mockExportDetailActionData.closeWorkflow).toBeCalledWith(workflowID); + + result.current.rejectWorkflowButtonMeta.action(); + expect(mockDataExportDetailRedux.updateWorkflowRejectOpen).toBeCalledTimes( + 1 + ); + expect(mockDataExportDetailRedux.updateWorkflowRejectOpen).toBeCalledWith( + true + ); + + result.current.executeExportButtonMeta.action(); + expect(mockExportDetailActionData.executeExport).toBeCalledTimes(1); + expect(mockExportDetailActionData.executeExport).toBeCalledWith(workflowID); + }); +}); diff --git a/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/index.tsx b/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/index.tsx index 6a099b4c5..f5e341001 100644 --- a/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/index.tsx +++ b/packages/base/src/page/DataExportManagement/Detail/components/PageHeaderAction/index.tsx @@ -2,13 +2,15 @@ import { useTranslation } from 'react-i18next'; import useDataExportDetailReduxManage from '../../hooks/index.redux'; import { ExportDetailPageHeaderExtraStyleWrapper } from './style'; import { BasicButton, EmptyBox } from '@actiontech/shared'; -import { Divider, Popconfirm } from 'antd'; +import { Divider, Popconfirm, message } from 'antd'; import useActionButtonState from './useActionButtonState'; import { useCurrentProject } from '@actiontech/shared/lib/global'; const ExportDetailPageHeaderAction: React.FC = () => { const { t } = useTranslation(); + const [messageApi, messageContextHolder] = message.useMessage(); + const { projectArchive } = useCurrentProject(); const { workflowStepOpen, updateWorkflowStepOpen } = @@ -19,16 +21,15 @@ const ExportDetailPageHeaderAction: React.FC = () => { }; const { - messageContentHolder, closeWorkflowButtonMeta, approveWorkflowButtonMeta, executeExportButtonMeta, rejectWorkflowButtonMeta - } = useActionButtonState(); + } = useActionButtonState(messageApi); return ( - {messageContentHolder} + {messageContextHolder}