forked from Gitlink/forgeplus-react
测试用例
This commit is contained in:
parent
f688d44455
commit
fd53c682cd
|
|
@ -32,7 +32,7 @@ export function initAxiosInterceptors(props) {
|
|||
// 判断网络是否连接
|
||||
initOnlineOfflineListener();
|
||||
|
||||
var proxy = "https://testforgeplus.trustie.net";
|
||||
var proxy = "https://testforgeplus.educoder.net";
|
||||
//响应前的设置
|
||||
axios.interceptors.request.use(
|
||||
config => {
|
||||
|
|
|
|||
|
|
@ -2,14 +2,9 @@ import React, { Component } from 'react';
|
|||
import { Spin } from 'antd';
|
||||
|
||||
class Loading extends Component {
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (!prevProps.error && this.props.error) {
|
||||
console.log(this.props.error)
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return ""
|
||||
return <div style={{height:"100vh",display:"flex",alignItems:"center",justifyContent:"center"}}><Spin /></div>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function Profile({
|
|||
|
||||
function checkProfile() {
|
||||
if(checkIfLogin()){
|
||||
if(!current_user.has_gitea_user || (current_user.has_gitea_user && !current_user.is_sync_pwd)){
|
||||
if(!current_user.has_gitea_user){
|
||||
setGiteaVisible(true);
|
||||
}else{
|
||||
if(!completeProfile){
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class NewHeader extends Component {
|
|||
}
|
||||
|
||||
getEducoderSetting=()=>{
|
||||
const url = `https://data.educoder.net/api/setting.json`;
|
||||
const url = `/setting.json`;
|
||||
axios.get(url).then(result=>{
|
||||
if(result && result.data){
|
||||
this.setState({
|
||||
|
|
|
|||
|
|
@ -27,14 +27,16 @@ function AllMenus({owner,projectsId,chooseFunc,update,defaultNames,defaultIds,op
|
|||
const [ author , setAuthor ] = useState(undefined);
|
||||
const [ tagList , setTagList ] = useState(undefined);
|
||||
const [ tag , setTag ] = useState(undefined);
|
||||
const [ cases , setCases ] = useState(undefined);
|
||||
const [ millstoneList , setMillstoneList ] = useState(undefined);
|
||||
const [ millstone , setMillstone ] = useState(undefined);
|
||||
const [ chargeList , setChargeList ] = useState(undefined);
|
||||
const [ caseList , setCaseList ] = useState(undefined);
|
||||
const [ charge , setCharge ] = useState(undefined);
|
||||
const [ statusList , setStatusList ] = useState(undefined);
|
||||
const [ prioritiesList , setPrioritiesList ] = useState(undefined);
|
||||
const [ ids , setIds ] = useState({author_id:undefined,issue_priorities_id:undefined,issue_tag_ids:undefined,milestone_id:undefined,sort_by:undefined,status_id:undefined,assigner_id:undefined});
|
||||
const [ names , setNames ] = useState({author_name:undefined,issue_priorities_name:undefined,issue_tag_name:undefined,milestone_name:undefined,sortby_name:undefined,status_name:undefined,assigner_name:undefined});
|
||||
const [ ids , setIds ] = useState({author_id:undefined,issue_priorities_id:undefined,issue_tag_ids:undefined,milestone_id:undefined,sort_by:undefined,status_id:undefined,assigner_id:undefined,test_case:undefined});
|
||||
const [ names , setNames ] = useState({author_name:undefined,issue_priorities_name:undefined,issue_tag_name:undefined,milestone_name:undefined,sortby_name:undefined,status_name:undefined,assigner_name:undefined,test_case:undefined});
|
||||
|
||||
useEffect(()=>{
|
||||
if(defaultNames){
|
||||
|
|
@ -80,6 +82,31 @@ function AllMenus({owner,projectsId,chooseFunc,update,defaultNames,defaultIds,op
|
|||
}
|
||||
})
|
||||
}
|
||||
// 获取测试用例
|
||||
useEffect(()=>{
|
||||
getCase();
|
||||
},[cases])
|
||||
|
||||
function getCase(){
|
||||
const url = `/v1/${owner}/${projectsId}/issues/test_cases`;
|
||||
axios.get(url,{
|
||||
params:{
|
||||
keyword:cases
|
||||
}
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
let menu = result.data.data;
|
||||
if(menu && menu.length>0){
|
||||
const l = menu.map(i=>{
|
||||
return {name:i.test_case,id:i.test_case}
|
||||
})
|
||||
setCaseList(l);
|
||||
}else{
|
||||
setCaseList([]);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
// 获取里程碑列表
|
||||
useEffect(()=>{
|
||||
getMillstone();
|
||||
|
|
@ -187,6 +214,15 @@ function AllMenus({owner,projectsId,chooseFunc,update,defaultNames,defaultIds,op
|
|||
lists={millstoneList} searchFunc={(value)=>setMillstone(value)}
|
||||
chooseFunc={(id,name)=>{let copy = {...ids,milestone_id:id && id.length>0 ? id.join(","):undefined};let copyname = { ...names,milestone_name:name};setNames(copyname);setIds(copy);chooseFunc(copy,copyname)}}
|
||||
/>
|
||||
<Menus
|
||||
update={update}
|
||||
ids={ids && ids.test_case}
|
||||
name={"测试用例"} size={"large"}
|
||||
names={names && names.test_case}
|
||||
lists={caseList} searchFunc={(value)=>setCases(value)}
|
||||
double={false}
|
||||
chooseFunc={(id,name)=>{let copy = {...ids,test_case:name};let copyname = { ...names,test_case:name};setNames(copyname);setIds(copy);chooseFunc(copy,copyname)}}
|
||||
/>
|
||||
<Menus
|
||||
update={update}
|
||||
ids={ids && ids.assigner_id}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
import React , { useEffect , useState } from 'react';
|
||||
import { AutoComplete } from 'antd';
|
||||
import axios from 'axios';
|
||||
import '../index.scss';
|
||||
|
||||
const { Option } = AutoComplete;
|
||||
|
||||
function CaseDrop({
|
||||
name , owner , projectsId , changeValue , value , onBlur
|
||||
}){
|
||||
const [ filterUnitList , setFilterUnitList ] = useState([]);
|
||||
const [ v , setV ] = useState(value);
|
||||
|
||||
useEffect(()=>{
|
||||
getCaseList(value);
|
||||
},[])
|
||||
|
||||
useEffect(()=>{
|
||||
setV(value);
|
||||
},[value])
|
||||
|
||||
useEffect(()=>{
|
||||
changeValue(v);
|
||||
getCaseList(v);
|
||||
},[v])
|
||||
|
||||
async function getCaseList(value){
|
||||
setV(value);
|
||||
const url = `/v1/${owner}/${projectsId}/issues/test_cases`;
|
||||
await axios.get(url,{
|
||||
params:{
|
||||
keyword:value
|
||||
}
|
||||
}).then(response=>{
|
||||
if(response && response.data){
|
||||
setFilterUnitList(response.data.data);
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
|
||||
return(
|
||||
<li>
|
||||
<span>{name}</span>
|
||||
<AutoComplete
|
||||
value={v}
|
||||
showSearch
|
||||
onChange={setV}
|
||||
placeholder={name}
|
||||
// options={filterUnitList && filterUnitList.map(item => ({ value: item.test_case,label:item.test_case }))}
|
||||
className={"boxStyles"}
|
||||
bordered={false}
|
||||
onBlur={()=>{if(onBlur){onBlur(v)}}}
|
||||
maxLength={100}
|
||||
>
|
||||
{
|
||||
filterUnitList && filterUnitList.length > 0 &&
|
||||
filterUnitList.map(i=>{
|
||||
return(
|
||||
<Option value={i.test_case}>{i.test_case}</Option>
|
||||
)
|
||||
})
|
||||
}
|
||||
</AutoComplete>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
export default CaseDrop;
|
||||
|
|
@ -64,6 +64,7 @@ function Datas({checkbox ,item , projectsId,owner}){
|
|||
{item.milestone_name}
|
||||
</Link>
|
||||
}
|
||||
<span style={{maxWidth:"100px"}} className="task-hide"><Tooltip placement={"bottom"} title={item.test_case}>{item.test_case}</Tooltip></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
import React , { useState , useEffect , useRef,useMemo} from 'react';
|
||||
import { Select , Spin } from 'antd';
|
||||
import debounce from 'lodash/debounce';
|
||||
|
||||
function DebounceSelect({ fetchOptions, debounceTimeout = 600, ...props }) {
|
||||
const [fetching, setFetching] = useState(false);
|
||||
const [options, setOptions] = useState([]);
|
||||
const fetchRef = useRef(0);
|
||||
|
||||
useEffect(()=>{
|
||||
fetchOptions("").then((newOptions) => {
|
||||
setOptions(newOptions);
|
||||
});
|
||||
},[])
|
||||
|
||||
const debounceFetcher = useMemo(() => {
|
||||
const loadOptions = (value) => {
|
||||
fetchRef.current += 1;
|
||||
const fetchId = fetchRef.current;
|
||||
setOptions([]);
|
||||
setFetching(true);
|
||||
fetchOptions(value).then((newOptions) => {
|
||||
if (fetchId !== fetchRef.current) {
|
||||
// for fetch callback order
|
||||
return;
|
||||
}
|
||||
setOptions(newOptions);
|
||||
setFetching(false);
|
||||
});
|
||||
};
|
||||
return debounce(loadOptions, debounceTimeout);
|
||||
}, [fetchOptions, debounceTimeout]);
|
||||
|
||||
return (
|
||||
<Select
|
||||
labelInValue
|
||||
filterOption={false}
|
||||
onSearch={debounceFetcher}
|
||||
notFoundContent={fetching ? <Spin size="small" /> : null}
|
||||
{...props}
|
||||
defaultActiveFirstOption={false}
|
||||
>
|
||||
{
|
||||
options && options.length >0 &&
|
||||
options.map((i)=>{
|
||||
return(
|
||||
<Select.Option value={i.value}>{i.value}</Select.Option>
|
||||
)
|
||||
})
|
||||
}
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
export default DebounceSelect
|
||||
|
|
@ -15,6 +15,7 @@ import axios from 'axios';
|
|||
import CommentList from '../Component/comments/list';
|
||||
import Claims from '../../claims/claims';
|
||||
import ChooseMenu from '../Component/chooseMenu';
|
||||
import CaseDrop from '../Component/caseDrop';
|
||||
|
||||
function Details(props){
|
||||
const owner = props.match.params.owner;
|
||||
|
|
@ -54,6 +55,7 @@ function Details(props){
|
|||
const [ branch_choose , setBranch_choose ] = useState([]);
|
||||
const [ rewardAmount , setRewardAmount ] = useState(undefined);
|
||||
const [ rewardFlag , setRewardFlag ] = useState(false);
|
||||
const [ caseValue, setCaseValue ] = useState(undefined);
|
||||
|
||||
const pathname = props.history.location.pathname;
|
||||
const permission = props && props.projectDetail && props.projectDetail.permission;
|
||||
|
|
@ -109,6 +111,7 @@ function Details(props){
|
|||
setMillstone_choose(data.milestone && data.milestone.id ? [data.milestone]:[]);
|
||||
setBranch_choose(data.branch_name ? [{name:data.branch_name}] : []);
|
||||
setRewardAmount(data.blockchain_token_num);
|
||||
setCaseValue(data.test_case);
|
||||
|
||||
data.start_date && setStartDate(moment(data.start_date).format('YYYY-MM-DD'));
|
||||
data.due_date && setDueDate(moment(data.due_date).format('YYYY-MM-DD'));
|
||||
|
|
@ -230,7 +233,7 @@ function Details(props){
|
|||
}
|
||||
|
||||
// 可单个编辑保存右侧的项(!copy:非复制状态下)
|
||||
function saveForeach(c,s,p,t,m,b,sDate,eDate,rewardAmount){
|
||||
function saveForeach(c,s,p,t,m,b,sDate,eDate,rewardAmount,caseValue){
|
||||
if(!copy){
|
||||
const url = `/v1/${owner}/${projectsId}/issues/${index}`;
|
||||
axios.patch(url,{
|
||||
|
|
@ -242,7 +245,8 @@ function Details(props){
|
|||
assigner_ids: c?c:undefined,
|
||||
start_date:sDate,
|
||||
due_date:eDate,
|
||||
blockchain_token_num:rewardAmount
|
||||
blockchain_token_num:rewardAmount,
|
||||
test_case:caseValue
|
||||
}).then(result=>{
|
||||
if(result){
|
||||
Init();
|
||||
|
|
@ -509,6 +513,7 @@ function Details(props){
|
|||
/>
|
||||
</li>
|
||||
}
|
||||
<CaseDrop name="测试用例" value={caseValue} owner={owner} projectsId={projectsId} changeValue={(v)=>setCaseValue(v)} onBlur={(v)=>saveForeach(undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,v)}/>
|
||||
<Date name="开始日期" today={start_date} setDate={(date)=>{setStartDate(date);saveForeach(undefined,undefined,undefined,undefined,undefined,undefined,date)}} editFlag={editFlag}/>
|
||||
<Date name="结束日期" today={due_date} setDate={(date)=>{setDueDate(date);saveForeach(undefined,undefined,undefined,undefined,undefined,undefined,undefined,date)}} editFlag={editFlag}/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import AddTagsBox from '../Component/addTagsBox';
|
|||
import Date from '../Component/date';
|
||||
import NewPanel from '../Component/newPanel';
|
||||
import axios from 'axios';
|
||||
import CaseDrop from '../Component/caseDrop';
|
||||
|
||||
function New(props){
|
||||
// history search 是否含有意见反馈标识
|
||||
|
|
@ -34,12 +35,12 @@ function New(props){
|
|||
const [ tag_choose , setTag_choose ] = useState([]);
|
||||
const [ millstone_choose , setMillstone_choose ] = useState([]);
|
||||
const [ branch_choose , setBranch_choose ] = useState([]);
|
||||
const [ caseValue, setCaseValue ] = useState(undefined);
|
||||
|
||||
const [ start_date, setStartDate ] = useState("");//moment().format('YYYY-MM-DD')
|
||||
const [ due_date, setDueDate ] = useState("");
|
||||
|
||||
const [ rewardAmount , setRewardAmount ] = useState(undefined);
|
||||
const [ rewardFlag , setRewardFlag ] = useState(false);
|
||||
|
||||
const owner = props.match.params.owner;
|
||||
const projectsId = props.match.params.projectsId;
|
||||
|
|
@ -194,7 +195,8 @@ function New(props){
|
|||
assigner_ids:a,
|
||||
attachment_ids:fileList,
|
||||
start_date,due_date,receivers_login,
|
||||
blockchain_token_num:rewardAmount
|
||||
blockchain_token_num:rewardAmount,
|
||||
test_case:caseValue
|
||||
}).then(result=>{
|
||||
if(result && result.data && result.data.project_issues_index){
|
||||
window.scrollTo(0,0);
|
||||
|
|
@ -293,6 +295,7 @@ function New(props){
|
|||
className="borderNo mt5" disabled={milepostId ? true : false}/>
|
||||
</li>
|
||||
}
|
||||
<CaseDrop name="测试用例" owner={owner} projectsId={projectsId} changeValue={(v)=>{console.log("case:",v);setCaseValue(v)}}/>
|
||||
<Date name="开始日期" today={start_date} setDate={(date)=>setStartDate(date)}/>
|
||||
<Date name="结束日期" today={due_date} setDate={(date)=>setDueDate(date)}/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -851,4 +851,20 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.boxStyles{
|
||||
margin-top: 10px!important;
|
||||
width: 100%;
|
||||
input,input[class~="ant-input"]:focus{
|
||||
border:none!important;
|
||||
padding:0px;
|
||||
}
|
||||
div[class~='ant-select-selection__placeholder']{
|
||||
margin-left: 0px!important;
|
||||
margin-right: 0px!important;
|
||||
}
|
||||
span[class~='ant-select-arrow']{
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -166,7 +166,6 @@ export function TPMIndexHOC(WrappedComponent) {
|
|||
tpmLoading: false,
|
||||
completeProfile:response.data.profile_completed
|
||||
})
|
||||
console.log("11:",response.data);
|
||||
if(response.data && response.data.login){
|
||||
if(!response.data.has_gitea_user){
|
||||
this.setState({
|
||||
|
|
|
|||
Loading…
Reference in New Issue