|
@@ -11,7 +11,7 @@ import {
|
|
|
EyeOutlined,
|
|
|
} from '@ant-design/icons';
|
|
|
|
|
|
-import {recurrent,severity} from './const'
|
|
|
+import { recurrent, severity, bug_categories } from './const';
|
|
|
|
|
|
const formItemLayout = {
|
|
|
labelCol: {
|
|
@@ -25,26 +25,22 @@ const formItemLayout = {
|
|
|
const Step2 = (props) => {
|
|
|
const [form] = Form.useForm();
|
|
|
const [addCaseForm] = Form.useForm();
|
|
|
- const { data, dispatch, reportCommonInfo, testCaseList ,caseBugList} = props;
|
|
|
- // console.log(reportCommonInfo,props)
|
|
|
+ const [addBugForm] = Form.useForm();
|
|
|
+ const { data, dispatch, reportCommonInfo, testCaseList, caseBugList,categories } = props;
|
|
|
+
|
|
|
const [showTaskRecommendModal, setTaskRecommendModal] = useState(false);
|
|
|
const [showAddTestCaseModal, setAddTestCaseModal] = useState(false);
|
|
|
const [showAddBugModal, setAddTestBugModal] = useState(false);
|
|
|
-
|
|
|
const currentTestCaseRef = useRef({});
|
|
|
-
|
|
|
- const [isAddCaseStatus , setIsAddCaseStatus ] = useState(true);
|
|
|
- const [currActiveTestCase , setCurrActiveTestCase ] = useState({});
|
|
|
+ const [isAddCaseStatus, setIsAddCaseStatus] = useState(true);
|
|
|
+ const [currActiveTestCase, setCurrActiveTestCase] = useState({});
|
|
|
|
|
|
|
|
|
if (!data) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- const { validateFields, getFieldsValue } = addCaseForm;
|
|
|
-
|
|
|
const handleAddOrEditTestCase = () => {
|
|
|
-
|
|
|
addCaseForm.validateFields().then((res) => {
|
|
|
let formData = new FormData();
|
|
|
// formData.append("id", values.reportName);
|
|
@@ -53,30 +49,30 @@ const Step2 = (props) => {
|
|
|
formData.append('front', res.front);
|
|
|
formData.append('behind', res.behind);
|
|
|
formData.append('description', res.description);
|
|
|
- if(!isAddCaseStatus){
|
|
|
+ if (!isAddCaseStatus) {
|
|
|
//处理编辑用例
|
|
|
- formData.append('id',currentTestCaseRef.current.id);
|
|
|
+ formData.append('id', currentTestCaseRef.current.id);
|
|
|
dispatch({
|
|
|
type: 'editReport/updateTestCase',
|
|
|
payload: {
|
|
|
formData,
|
|
|
- report_id:reportCommonInfo.id
|
|
|
+ report_id: reportCommonInfo.id,
|
|
|
},
|
|
|
- }).then((res)=>{
|
|
|
- if(res&&res.status === 200){
|
|
|
+ }).then((res) => {
|
|
|
+ if (res && res.status === 200) {
|
|
|
message.success('修改成功!');
|
|
|
}
|
|
|
});
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//处理添加用例
|
|
|
dispatch({
|
|
|
type: 'editReport/createTestCase',
|
|
|
payload: {
|
|
|
formData,
|
|
|
- report_id:reportCommonInfo.id
|
|
|
+ report_id: reportCommonInfo.id,
|
|
|
},
|
|
|
- }).then((res)=>{
|
|
|
- if(res&&res.id){
|
|
|
+ }).then((res) => {
|
|
|
+ if (res && res.id) {
|
|
|
message.success('添加成功!');
|
|
|
}
|
|
|
});
|
|
@@ -86,34 +82,87 @@ const Step2 = (props) => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const handleClickTestCase = (caseItem)=>{
|
|
|
- setCurrActiveTestCase(caseItem)
|
|
|
+ const handleAddBug = () => {
|
|
|
+ addBugForm.validateFields().then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ let formData = new FormData();
|
|
|
+ formData.append('report_id', reportCommonInfo.id);
|
|
|
+ formData.append('name', res.name);
|
|
|
+ formData.append('front', res.front);
|
|
|
+ formData.append('behind', res.behind);
|
|
|
+ formData.append('description', res.description);
|
|
|
+ });
|
|
|
+ // if (true) {
|
|
|
+ // //新建bug的逻辑
|
|
|
+ // setAddTestBugModal(true);
|
|
|
+ // dispatch({
|
|
|
+ // type: 'editReport/createTestCase',
|
|
|
+ // payload: {
|
|
|
+ // report_id:reportCommonInfo.id
|
|
|
+ // },
|
|
|
+ // }).then((res)=>{
|
|
|
+ // if(res&&res.id){
|
|
|
+ // message.success('添加成功!');
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // //编辑bug的逻辑
|
|
|
+ // }
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleClickTestCase = (caseItem) => {
|
|
|
+ setCurrActiveTestCase(caseItem);
|
|
|
dispatch({
|
|
|
type: 'editReport/getCaseBugList',
|
|
|
payload: caseItem.id,
|
|
|
});
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
const handleEditTestCase = (item) => {
|
|
|
setIsAddCaseStatus(false);
|
|
|
currentTestCaseRef.current = item;
|
|
|
- addCaseForm.setFieldsValue(currentTestCaseRef.current)
|
|
|
+ addCaseForm.setFieldsValue(currentTestCaseRef.current);
|
|
|
setAddTestCaseModal(true);
|
|
|
};
|
|
|
|
|
|
- const handleClickAddCase = ()=>{
|
|
|
+ const handleClickAddCase = () => {
|
|
|
currentTestCaseRef.current = {};
|
|
|
addCaseForm.resetFields();
|
|
|
setAddTestCaseModal(true);
|
|
|
- }
|
|
|
+ };
|
|
|
+
|
|
|
+ // const handleEditBug = (item) => {
|
|
|
+ // setIsAddCaseStatus(false);
|
|
|
+ // currentTestCaseRef.current = item;
|
|
|
+ // addBugForm.setFieldsValue(currentTestCaseRef.current)
|
|
|
+ // setAddTestCaseModal(true);
|
|
|
+ // };
|
|
|
|
|
|
+ const handleClickAddBug = () => {
|
|
|
+ addBugForm.resetFields();
|
|
|
+ setAddTestBugModal(true);
|
|
|
+ };
|
|
|
|
|
|
useEffect(() => {
|
|
|
+ //判断是否已经有报告
|
|
|
dispatch({
|
|
|
- type: 'editReport/getTestCaseList',
|
|
|
- payload: {report_id:reportCommonInfo.id},
|
|
|
+ type: 'editReport/getReportInfo',
|
|
|
+ payload: {
|
|
|
+ case_take_id: '1718-1718',
|
|
|
+ worker_id: 1,
|
|
|
+ },
|
|
|
+ }).then(() => {
|
|
|
+ //有报告,获取对应信息。没有就直接转去了第一步
|
|
|
+ dispatch({
|
|
|
+ type: 'editReport/getTestCaseList',
|
|
|
+ payload: { report_id: reportCommonInfo.id },
|
|
|
+ });
|
|
|
+ dispatch({
|
|
|
+ type: 'editReport/getCategories',
|
|
|
+ payload: { examId: 1945 },
|
|
|
+ });
|
|
|
});
|
|
|
- }, [dispatch,reportCommonInfo]);
|
|
|
+ }, [dispatch]);
|
|
|
|
|
|
return (
|
|
|
<div>
|
|
@@ -161,7 +210,9 @@ const Step2 = (props) => {
|
|
|
<Row gutter={10} style={{ marginBottom: 10 }}>
|
|
|
<Col span={20}><h3>测试用例列表</h3></Col>
|
|
|
<Col span={4}>
|
|
|
- <Button size="small" onClick={()=>{handleClickAddCase()}}>
|
|
|
+ <Button size="small" onClick={() => {
|
|
|
+ handleClickAddCase();
|
|
|
+ }}>
|
|
|
<PlusOutlined className={styles.addIcon} />
|
|
|
用例
|
|
|
</Button>
|
|
@@ -170,20 +221,22 @@ const Step2 = (props) => {
|
|
|
</div>
|
|
|
|
|
|
<div className={styles.testCaseList}>
|
|
|
- {testCaseList.length && testCaseList.map((item) => {
|
|
|
+ {testCaseList && testCaseList.map((item) => {
|
|
|
return (
|
|
|
- <div className={`${styles.testCaseItem} ${currActiveTestCase.id===item.id ? styles.activeCase :""}`}
|
|
|
- key={item.id}
|
|
|
- onClick={()=>{
|
|
|
- handleClickTestCase(item)}}>
|
|
|
- <Row gutter={10}>
|
|
|
- <Col span={21}><p>{item.name}</p></Col>
|
|
|
- <Col span={3}>
|
|
|
- <EditOutlined className={styles.editTestBug}
|
|
|
- onClick={() => handleEditTestCase(item)} />
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- </div>);
|
|
|
+ <div
|
|
|
+ className={`${styles.testCaseItem} ${currActiveTestCase.id === item.id ? styles.activeCase : ''}`}
|
|
|
+ key={item.id}
|
|
|
+ onClick={() => {
|
|
|
+ handleClickTestCase(item);
|
|
|
+ }}>
|
|
|
+ <Row gutter={10}>
|
|
|
+ <Col span={21}><p>{item.name}</p></Col>
|
|
|
+ <Col span={3}>
|
|
|
+ <EditOutlined className={styles.editTestBug}
|
|
|
+ onClick={() => handleEditTestCase(item)} />
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+ </div>);
|
|
|
})}
|
|
|
</div>
|
|
|
</Col>
|
|
@@ -192,7 +245,7 @@ const Step2 = (props) => {
|
|
|
<Row gutter={10} style={{ marginBottom: 10 }}>
|
|
|
<Col span={20}><h3>缺陷列表</h3></Col>
|
|
|
<Col span={2}>
|
|
|
- <Button size="small" onClick={() => setAddTestBugModal(true)}>
|
|
|
+ <Button size="small" onClick={() => handleClickAddBug()}>
|
|
|
<PlusOutlined className={styles.addIcon} />
|
|
|
缺陷
|
|
|
</Button>
|
|
@@ -205,23 +258,25 @@ const Step2 = (props) => {
|
|
|
</Col>
|
|
|
</Row>
|
|
|
<div className={styles.testBugList}>
|
|
|
- {caseBugList.map((item)=>{
|
|
|
- return (<div className={styles.testBugItem} key={item.id}>
|
|
|
- <Row gutter={10}>
|
|
|
+ {caseBugList.map((item) => {
|
|
|
+ return (
|
|
|
+ <div className={styles.testBugItem} key={item.detail.id}>
|
|
|
+ <Row gutter={10}>
|
|
|
<Col span={20}>
|
|
|
<div><span className={styles.bugItemTitle}>Bug标题:</span>{item.detail.title}</div>
|
|
|
<div><span className={styles.bugItemTitle}>复现程度:</span>{recurrent.get(item.detail.recurrent)}</div>
|
|
|
<div><span className={styles.bugItemTitle}>严重程度:</span>{item.detail.severity}</div>
|
|
|
- <div><span className={styles.bugItemTitle}>缺陷分类:</span>{severity.get(item.detail.bug_category)}</div>
|
|
|
+ <div><span className={styles.bugItemTitle}>缺陷分类:</span>{severity.get(item.detail.bug_category)}
|
|
|
+ </div>
|
|
|
</Col>
|
|
|
<Col span={4}>
|
|
|
<Button size='small' style={{ marginTop: 10 }}>
|
|
|
<EyeOutlined />详情</Button>
|
|
|
</Col>
|
|
|
</Row>
|
|
|
- </div>)
|
|
|
+ </div>
|
|
|
+ );
|
|
|
})}
|
|
|
-
|
|
|
</div>
|
|
|
</Col>
|
|
|
|
|
@@ -238,7 +293,9 @@ const Step2 = (props) => {
|
|
|
onClick={() => {
|
|
|
setAddTestCaseModal(false);
|
|
|
}}>取消</Button>]}
|
|
|
- onCancel={() => {setAddTestCaseModal(false)}}
|
|
|
+ onCancel={() => {
|
|
|
+ setAddTestCaseModal(false);
|
|
|
+ }}
|
|
|
>
|
|
|
<ExclamationCircleFilled className={styles.addModalInfo} />为了评分准确,请勿提交重复测试用例
|
|
|
<Form
|
|
@@ -257,7 +314,7 @@ const Step2 = (props) => {
|
|
|
},
|
|
|
]}
|
|
|
>
|
|
|
- <Input/>
|
|
|
+ <Input />
|
|
|
</Form.Item>
|
|
|
<Form.Item
|
|
|
label="前置条件"
|
|
@@ -269,7 +326,7 @@ const Step2 = (props) => {
|
|
|
},
|
|
|
]}
|
|
|
>
|
|
|
- <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }}/>
|
|
|
+ <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }} />
|
|
|
</Form.Item>
|
|
|
<Form.Item
|
|
|
label="测试步骤"
|
|
@@ -281,7 +338,7 @@ const Step2 = (props) => {
|
|
|
},
|
|
|
]}
|
|
|
>
|
|
|
- <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }}/>
|
|
|
+ <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }} />
|
|
|
</Form.Item>
|
|
|
<Form.Item
|
|
|
label="预期结果"
|
|
@@ -293,19 +350,27 @@ const Step2 = (props) => {
|
|
|
},
|
|
|
]}
|
|
|
>
|
|
|
- <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }}/>
|
|
|
+ <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }} />
|
|
|
</Form.Item>
|
|
|
</Form>
|
|
|
</Modal>
|
|
|
|
|
|
<Modal title="添加用例缺陷" visible={showAddBugModal} width={720}
|
|
|
- onOk={() => setAddTestBugModal(false)}
|
|
|
- onCancel={() => setAddTestBugModal(false)}
|
|
|
- >
|
|
|
+ footer={[
|
|
|
+ <Button key='submit' type="primary" htmlType="submit" onClick={handleClickAddBug}>确定</Button>,
|
|
|
+ <Button key='cancel' htmlType="button" style={{ marginLeft: '10px' }}
|
|
|
+ onClick={() => { handleAddBug();}}>取消</Button>]}
|
|
|
+ onCancel={() => {
|
|
|
+ setAddTestBugModal(false);
|
|
|
+ }}
|
|
|
+ >
|
|
|
<ExclamationCircleFilled className={styles.addModalInfo} />为了评分准确,请勿提交重复Bug
|
|
|
<Form
|
|
|
labelCol={{ span: 4 }}
|
|
|
+ form={addBugForm}
|
|
|
+ {...formItemLayout}
|
|
|
layout="horizontal"
|
|
|
+ className={styles.stepForm}
|
|
|
>
|
|
|
<Form.Item
|
|
|
label="测试题目"
|
|
@@ -317,7 +382,7 @@ const Step2 = (props) => {
|
|
|
},
|
|
|
]}
|
|
|
>
|
|
|
- <Input autoSize/>
|
|
|
+ <Input />
|
|
|
</Form.Item>
|
|
|
<Form.Item
|
|
|
label="前置条件"
|
|
@@ -329,7 +394,7 @@ const Step2 = (props) => {
|
|
|
},
|
|
|
]}
|
|
|
>
|
|
|
- <Input.TextArea autoSize/>
|
|
|
+ <Input.TextArea autoSize />
|
|
|
</Form.Item>
|
|
|
<Form.Item
|
|
|
label="三级页面"
|
|
@@ -344,7 +409,9 @@ const Step2 = (props) => {
|
|
|
<Row gutter={5}>
|
|
|
<Col span={8}>
|
|
|
<Select>
|
|
|
- <Select.Option value="demo">Demo1</Select.Option>
|
|
|
+ {categories.map((item)=>{
|
|
|
+ return <Select.Option value="demo" key={item.item}>{item.item}</Select.Option>
|
|
|
+ })}
|
|
|
</Select>
|
|
|
</Col>
|
|
|
<Col span={8}>
|
|
@@ -389,7 +456,7 @@ const Step2 = (props) => {
|
|
|
</Form.Item>
|
|
|
<Form.Item
|
|
|
label="复现程度"
|
|
|
- name="testName"
|
|
|
+ name="recurrent"
|
|
|
rules={[
|
|
|
{
|
|
|
required: true,
|
|
@@ -401,17 +468,17 @@ const Step2 = (props) => {
|
|
|
<Select.Option value="demo">Demo</Select.Option>
|
|
|
</Select>
|
|
|
</Form.Item>
|
|
|
- <Form.Item
|
|
|
- label="上传截图"
|
|
|
- name="testName"
|
|
|
- >
|
|
|
- <Upload
|
|
|
- action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
|
|
|
- listType="picture"
|
|
|
- >
|
|
|
- <Button icon={<UploadOutlined />}>Upload</Button>
|
|
|
- </Upload>
|
|
|
- </Form.Item>
|
|
|
+ {/*<Form.Item*/}
|
|
|
+ {/* label="上传截图"*/}
|
|
|
+ {/* name="testName"*/}
|
|
|
+ {/*>*/}
|
|
|
+ {/* <Upload*/}
|
|
|
+ {/* action="https://www.mocky.io/v2/5cc8019d300000980a055e76"*/}
|
|
|
+ {/* listType="picture"*/}
|
|
|
+ {/* >*/}
|
|
|
+ {/* <Button icon={<UploadOutlined />}>Upload</Button>*/}
|
|
|
+ {/* </Upload>*/}
|
|
|
+ {/*</Form.Item>*/}
|
|
|
</Form>
|
|
|
</Modal>
|
|
|
<Modal title="任务推荐" visible={showTaskRecommendModal} onOk={() => setTaskRecommendModal(false)}
|
|
@@ -430,4 +497,5 @@ export default connect(({ editReport, loading }) => ({
|
|
|
reportCommonInfo: editReport.reportCommonInfo,
|
|
|
testCaseList: editReport.testCaseList,
|
|
|
caseBugList: editReport.caseBugList,
|
|
|
+ categories:editReport.categories
|
|
|
}))(Step2);
|