diff --git a/console/atest-ui/src/components/EditButton.vue b/console/atest-ui/src/components/EditButton.vue new file mode 100644 index 00000000..f252388b --- /dev/null +++ b/console/atest-ui/src/components/EditButton.vue @@ -0,0 +1,47 @@ + + + diff --git a/console/atest-ui/src/views/TestCase.vue b/console/atest-ui/src/views/TestCase.vue index c98f8e14..ede0f41e 100644 --- a/console/atest-ui/src/views/TestCase.vue +++ b/console/atest-ui/src/views/TestCase.vue @@ -7,6 +7,7 @@ import type { Pair, TestResult, TestCaseWithSuite, TestCase } from './types' import { NewSuggestedAPIsQuery, CreateFilter, GetHTTPMethods, FlattenObject } from './types' import { Cache } from './cache' import { API } from './net' +import EditButton from '../components/EditButton.vue' import type { RunTestCaseRequest } from './net' import { UIAPI } from './net-vue' import type { TestCaseResponse } from './cache' @@ -23,7 +24,6 @@ import 'codemirror/addon/merge/merge.css' import DiffMatchPatch from 'diff-match-patch'; - window.diff_match_patch = DiffMatchPatch; window.DIFF_DELETE = -1; window.DIFF_INSERT = 1; @@ -380,25 +380,25 @@ function downloadResponseFile(){ API.DownloadResponseFile({ body: testResult.value.body }, (e) => { - if (e && e.data) { - try { - const bytes = atob(e.data); - const blob = new Blob([bytes], { type: 'mimeType' }); - const link = document.createElement('a'); - link.href = window.URL.createObjectURL(blob); - link.download = e.filename.substring("isFilePath-".length); - - document.body.appendChild(link); - link.click(); - - window.URL.revokeObjectURL(link.href); - document.body.removeChild(link); - } catch (error) { - console.error('Error during file download:', error); + if (e && e.data) { + try { + const bytes = atob(e.data); + const blob = new Blob([bytes], { type: 'mimeType' }); + const link = document.createElement('a'); + link.href = window.URL.createObjectURL(blob); + link.download = e.filename.substring("isFilePath-".length); + + document.body.appendChild(link); + link.click(); + + window.URL.revokeObjectURL(link.href); + document.body.removeChild(link); + } catch (error) { + console.error('Error during file download:', error); + } + } else { + console.error('No data to download.'); } - } else { - console.error('No data to download.'); - } }) } @@ -877,6 +877,13 @@ Magic.Keys(() => { duplicateTestCase() } }, ['Alt+KeyO']) + +const renameTestCase = (name: string) => { + const suiteName = props.suite + API.RenameTestCase(suiteName, suiteName, props.name, name, (d) => { + emit('updated', suiteName, name) + }) +}