|
|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
import { Button, Space, Tree, Collapse, Divider, Message } from '@arco-design/web-react';
|
|
|
|
|
import { Button, Space, Tree, Collapse, Divider, Message, Modal } from '@arco-design/web-react';
|
|
|
|
|
import { IconLeft, IconPlus, IconEdit, IconDelete, IconLink, IconSend } from '@arco-design/web-react/icon';
|
|
|
|
|
import styles from './style/testInstance.module.less';
|
|
|
|
|
import { getComponentDesign } from '@/api/componentDevelopProcess';
|
|
|
|
|
import { getComponentTestCaseList, submitTestCase } from '@/api/componentTestCase';
|
|
|
|
|
import { getComponentTestCaseList, submitTestCase, deleteTestCase } from '@/api/componentTestCase';
|
|
|
|
|
import TestCaseModal from './TestCaseModal';
|
|
|
|
|
|
|
|
|
|
const CollapseItem = Collapse.Item;
|
|
|
|
|
@ -15,6 +15,7 @@ const TestInstance = ({ instance, parentId, onBack }: { instance: any; parentId:
|
|
|
|
|
const [modalVisible, setModalVisible] = useState(false);
|
|
|
|
|
const [selectedOperationIdent, setSelectedOperationIdent] = useState('');
|
|
|
|
|
const [activeOperationIdent, setActiveOperationIdent] = useState('');
|
|
|
|
|
const [editingTestCase, setEditingTestCase] = useState(null);
|
|
|
|
|
|
|
|
|
|
const getDesign = async () => {
|
|
|
|
|
const res: any = await getComponentDesign(parentId);
|
|
|
|
|
@ -39,9 +40,38 @@ const TestInstance = ({ instance, parentId, onBack }: { instance: any; parentId:
|
|
|
|
|
|
|
|
|
|
const handleAddTestCase = (operationIdent: string) => {
|
|
|
|
|
setSelectedOperationIdent(operationIdent);
|
|
|
|
|
setEditingTestCase(null);
|
|
|
|
|
setModalVisible(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleEditTestCase = (testCase: any, operationIdent: string) => {
|
|
|
|
|
setSelectedOperationIdent(operationIdent);
|
|
|
|
|
setEditingTestCase(testCase);
|
|
|
|
|
setModalVisible(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleDeleteTestCase = (testCase: any) => {
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
title: '确认删除',
|
|
|
|
|
content: `确定要删除测试用例"${testCase.testCaseName}"吗?`,
|
|
|
|
|
okText: '确定',
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
onOk: async () => {
|
|
|
|
|
try {
|
|
|
|
|
const res: any = await deleteTestCase(testCase.id);
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
Message.success('删除成功');
|
|
|
|
|
getTestCaseList();
|
|
|
|
|
} else {
|
|
|
|
|
Message.error(res.msg || '删除失败');
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
Message.error('删除失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleModalOk = async (values: any) => {
|
|
|
|
|
const params = {
|
|
|
|
|
...values,
|
|
|
|
|
@ -59,6 +89,7 @@ const TestInstance = ({ instance, parentId, onBack }: { instance: any; parentId:
|
|
|
|
|
|
|
|
|
|
const handleModalCancel = () => {
|
|
|
|
|
setModalVisible(false);
|
|
|
|
|
setEditingTestCase(null);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
@ -149,8 +180,18 @@ const TestInstance = ({ instance, parentId, onBack }: { instance: any; parentId:
|
|
|
|
|
<span className={styles['item-text']}>{child.testCaseName}</span>
|
|
|
|
|
<div className={styles['item-actions']}>
|
|
|
|
|
<IconSend />
|
|
|
|
|
<IconEdit />
|
|
|
|
|
<IconDelete />
|
|
|
|
|
<IconEdit
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
handleEditTestCase(child, item.operationIdent);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<IconDelete
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
handleDeleteTestCase(child);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
@ -273,6 +314,7 @@ const TestInstance = ({ instance, parentId, onBack }: { instance: any; parentId:
|
|
|
|
|
design={design.operates}
|
|
|
|
|
visible={modalVisible}
|
|
|
|
|
operationIdent={selectedOperationIdent}
|
|
|
|
|
editingData={editingTestCase}
|
|
|
|
|
onCancel={handleModalCancel}
|
|
|
|
|
onOk={handleModalOk}
|
|
|
|
|
/>}
|
|
|
|
|
|