|
|
@@ -71,7 +71,7 @@ export interface InputVariable {
|
|
|
export interface TestCase {
|
|
|
编号: string;
|
|
|
用例标题: string;
|
|
|
- 简短描述: string;
|
|
|
+ 描述: string;
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -88,7 +88,6 @@ const dealfilechange = async (event: Event) => {
|
|
|
//调用上传接口
|
|
|
const data = new FormData()
|
|
|
data.append('file',file)
|
|
|
-
|
|
|
const uploadConfig: AxiosRequestConfig = {
|
|
|
method: 'put',
|
|
|
url: 'http://47.120.7.208:8000/api/volumes/2/files?path=.',
|
|
|
@@ -105,11 +104,10 @@ const dealfilechange = async (event: Event) => {
|
|
|
let file_id = uploadResponse.data.id;
|
|
|
console.log(file_id);
|
|
|
console.log(JSON.stringify(uploadResponse.data));
|
|
|
-
|
|
|
// 上传文件成功,现在可以调用处理接口
|
|
|
const loadingInstance1 = ElLoading.service({
|
|
|
fullscreen: true,
|
|
|
- text: file.name + " 处理中"
|
|
|
+ text: file.name + " 生成测试用例中"
|
|
|
})
|
|
|
const data2: {
|
|
|
inputVariables: InputVariable[];
|
|
|
@@ -144,14 +142,18 @@ const dealfilechange = async (event: Event) => {
|
|
|
.then((response) => {
|
|
|
console.log(response.data.output)
|
|
|
const output = JSON.stringify(JSON.parse(response.data.output))
|
|
|
- const jsonIndex = output.indexOf("json")
|
|
|
- console.log(jsonIndex)
|
|
|
- const parsedOutput = output.substring(jsonIndex).replace(/json\\n/g, '').replace(/\\n/g, '').replace(/\\/g, '').replace(/ /g,'').replace(/```"/g,'');
|
|
|
+ const leftIndex = output.indexOf("[")
|
|
|
+ const rightIndex = output.indexOf("]")
|
|
|
+
|
|
|
+ const parsedOutput = output.substring(leftIndex,rightIndex+1).replace(/\\n/g, '').replace(/\\/g, '').replace(/ /g,'')
|
|
|
|
|
|
console.log(parsedOutput)
|
|
|
- const testCaseArray: TestCase[] = JSON.parse(parsedOutput) as TestCase[];
|
|
|
+ //const testCaseArray: TestCase[] = JSON.parse(parsedOutput) as TestCase[];
|
|
|
+ const testCaseArray = JSON.parse(parsedOutput);
|
|
|
console.log(testCaseArray)
|
|
|
- useStore.DocxList.push({ docxName: file.name, docxMessageList: testCaseArray, time: dayjs().format('YYYY-MM-DD HH:mm:ss'), actionList: [{description: "生成用例",time: dayjs().format('YYYY-MM-DD HH:mm:ss')}] })
|
|
|
+ useStore.DocxList.push({docxName: file.name, docxMessageList: testCaseArray, time: dayjs().format('YYYY-MM-DD HH:mm:ss'), actionList: [{description: "生成用例",time: dayjs().format('YYYY-MM-DD HH:mm:ss')}], testCaseList: []})
|
|
|
+ //持久化存储
|
|
|
+ useStore.saveDocxList()
|
|
|
loadingInstance1.close()
|
|
|
ElMessage({
|
|
|
message: '测试用例已生成,请点击确定跳转',
|
|
|
@@ -205,29 +207,6 @@ function uploadDocx() {
|
|
|
uploadInput.value.click()
|
|
|
}
|
|
|
|
|
|
-//解析后端传回的测试用例数据,已废弃
|
|
|
-function parseTestCases(testCaseString: string): any[] {
|
|
|
- const testCases: any[] = [];
|
|
|
- const regex = /\{"编号":"([^"]*)","用例标题":"([^"]*)","描述":"([^"]*)"\}/g;
|
|
|
- let match;
|
|
|
-
|
|
|
- // 使用正则表达式循环查找匹配项
|
|
|
- while ((match = regex.exec(testCaseString)) !== null) {
|
|
|
- // 提取编号、用例标题和简短描述
|
|
|
- const number = match[1];
|
|
|
- const title = match[2];
|
|
|
- const description = match[3];
|
|
|
-
|
|
|
- // 创建一个对象来保存用例信息,并添加到数组中
|
|
|
- testCases.push({
|
|
|
- 编号: number,
|
|
|
- 用例标题: title,
|
|
|
- 简短描述: description
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- return testCases;
|
|
|
-}
|
|
|
</script>
|
|
|
|
|
|
|