-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Execute
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Execute
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/console/atest-ui/src/views/net.ts b/console/atest-ui/src/views/net.ts
index 4765cb6..fc4eb14 100644
--- a/console/atest-ui/src/views/net.ts
+++ b/console/atest-ui/src/views/net.ts
@@ -16,147 +16,147 @@ limitations under the License.
import { Cache } from './cache'
async function DefaultResponseProcess(response: any) {
- if (!response.ok) {
- switch (response.status) {
- case 401:
- throw new Error("Unauthenticated")
- }
+ if (!response.ok) {
+ switch (response.status) {
+ case 401:
+ throw new Error("Unauthenticated")
+ }
- const message = await response.json().then((data :any) => data.message)
- throw new Error(message)
- } else {
- return response.json()
- }
+ const message = await response.json().then((data: any) => data.message)
+ throw new Error(message)
+ } else {
+ return response.json()
+ }
}
interface AppVersion {
- version: string
- commit: string
- date: string
+ version: string
+ commit: string
+ date: string
}
function safeToggleFunc(toggle?: (e: boolean) => void) {
- if (!toggle) {
- return (e: boolean) => {}
- }
- return toggle
+ if (!toggle) {
+ return (e: boolean) => { }
+ }
+ return toggle
}
function GetVersion(callback?: (v: AppVersion) => void) {
- const requestOptions = {
- method: 'GET',
- }
- fetch('/api/v1/version', requestOptions)
- .then(DefaultResponseProcess)
- .then(emptyOrDefault(callback))
+ const requestOptions = {
+ method: 'GET',
+ }
+ fetch('/api/v1/version', requestOptions)
+ .then(DefaultResponseProcess)
+ .then(emptyOrDefault(callback))
}
interface TestSuite {
- store: string
- name: string
- api: string
- kind: string
+ store: string
+ name: string
+ api: string
+ kind: string
}
function CreateTestSuite(suite: TestSuite,
- callback: (d: any) => void, errHandle?: (e: any) => void | null) {
- const requestOptions = {
- method: 'POST',
- headers: {
- 'X-Store-Name': suite.store,
- 'X-Auth': getToken()
- },
- body: JSON.stringify({
- name: suite.name,
- api: suite.api,
- kind: suite.kind
- })
- }
+ callback: (d: any) => void, errHandle?: (e: any) => void | null) {
+ const requestOptions = {
+ method: 'POST',
+ headers: {
+ 'X-Store-Name': suite.store,
+ 'X-Auth': getToken()
+ },
+ body: JSON.stringify({
+ name: suite.name,
+ api: suite.api,
+ kind: suite.kind
+ })
+ }
- fetch('/api/v1/suites', requestOptions)
- .then(DefaultResponseProcess)
- .then(callback).catch(emptyOrDefault(errHandle))
+ fetch('/api/v1/suites', requestOptions)
+ .then(DefaultResponseProcess)
+ .then(callback).catch(emptyOrDefault(errHandle))
}
interface ImportSource {
- store: string
- url: string
- kind: string
+ store: string
+ url: string
+ kind: string
}
function UpdateTestSuite(suite: any,
- callback: (d: any) => void, errHandle?: (e: any) => void | null) {
- const requestOptions = {
- method: 'PUT',
- headers: {
- 'X-Store-Name': Cache.GetCurrentStore().name,
- 'X-Auth': getToken()
- },
- body: JSON.stringify(suite)
- }
- fetch(`/api/v1/suites/${suite.name}`, requestOptions)
- .then(DefaultResponseProcess)
- .then(callback).catch(emptyOrDefault(errHandle))
+ callback: (d: any) => void, errHandle?: (e: any) => void | null) {
+ const requestOptions = {
+ method: 'PUT',
+ headers: {
+ 'X-Store-Name': Cache.GetCurrentStore().name,
+ 'X-Auth': getToken()
+ },
+ body: JSON.stringify(suite)
+ }
+ fetch(`/api/v1/suites/${suite.name}`, requestOptions)
+ .then(DefaultResponseProcess)
+ .then(callback).catch(emptyOrDefault(errHandle))
}
function GetTestSuite(name: string,
- callback: (d: any) => void, errHandle?: (e: any) => void) {
- const store = Cache.GetCurrentStore()
- const requestOptions = {
- headers: {
- 'X-Store-Name': store.name,
- 'X-Auth': getToken()
+ callback: (d: any) => void, errHandle?: (e: any) => void) {
+ const store = Cache.GetCurrentStore()
+ const requestOptions = {
+ headers: {
+ 'X-Store-Name': store.name,
+ 'X-Auth': getToken()
+ }
}
- }
- fetch(`/api/v1/suites/${name}`, requestOptions)
- .then(DefaultResponseProcess)
- .then(callback).catch(emptyOrDefault(errHandle))
+ fetch(`/api/v1/suites/${name}`, requestOptions)
+ .then(DefaultResponseProcess)
+ .then(callback).catch(emptyOrDefault(errHandle))
}
function DeleteTestSuite(name: string,
- callback: (d: any) => void, errHandle?: (e: any) => void | null) {
- const requestOptions = {
- method: 'DELETE',
- headers: {
- 'X-Store-Name': Cache.GetCurrentStore().name,
- 'X-Auth': getToken()
+ callback: (d: any) => void, errHandle?: (e: any) => void | null) {
+ const requestOptions = {
+ method: 'DELETE',
+ headers: {
+ 'X-Store-Name': Cache.GetCurrentStore().name,
+ 'X-Auth': getToken()
+ }
}
- }
- fetch(`/api/v1/suites/${name}`, requestOptions)
- .then(DefaultResponseProcess)
- .then(callback).catch(emptyOrDefault(errHandle))
+ fetch(`/api/v1/suites/${name}`, requestOptions)
+ .then(DefaultResponseProcess)
+ .then(callback).catch(emptyOrDefault(errHandle))
}
function ConvertTestSuite(suiteName: string, genertor: string,
- callback: (d: any) => void, errHandle?: (e: any) => void | null) {
- const requestOptions = {
- method: 'POST',
- headers: {
- 'X-Store-Name': Cache.GetCurrentStore().name,
- 'X-Auth': getToken()
- },
- body: JSON.stringify({
- Generator: genertor,
- TestSuite: suiteName
- })
- }
- fetch(`/api/v1/converters/convert`, requestOptions)
- .then(DefaultResponseProcess)
- .then(callback).catch(emptyOrDefault(errHandle))
+ callback: (d: any) => void, errHandle?: (e: any) => void | null) {
+ const requestOptions = {
+ method: 'POST',
+ headers: {
+ 'X-Store-Name': Cache.GetCurrentStore().name,
+ 'X-Auth': getToken()
+ },
+ body: JSON.stringify({
+ Generator: genertor,
+ TestSuite: suiteName
+ })
+ }
+ fetch(`/api/v1/converters/convert`, requestOptions)
+ .then(DefaultResponseProcess)
+ .then(callback).catch(emptyOrDefault(errHandle))
}
function DuplicateTestSuite(sourceSuiteName: string, targetSuiteName: string,
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
const requestOptions = {
- method: 'POST',
- headers: {
- 'X-Store-Name': Cache.GetCurrentStore().name,
- 'X-Auth': getToken()
- },
- body: JSON.stringify({
- sourceSuiteName: sourceSuiteName,
- targetSuiteName: targetSuiteName,
- })
+ method: 'POST',
+ headers: {
+ 'X-Store-Name': Cache.GetCurrentStore().name,
+ 'X-Auth': getToken()
+ },
+ body: JSON.stringify({
+ sourceSuiteName: sourceSuiteName,
+ targetSuiteName: targetSuiteName,
+ })
}
fetch(`/api/v1/suites/${sourceSuiteName}/duplicate`, requestOptions)
.then(DefaultResponseProcess)
@@ -164,209 +164,209 @@ function DuplicateTestSuite(sourceSuiteName: string, targetSuiteName: string,
}
const RenameTestSuite = (sourceSuiteName: string, targetSuiteName: string,
- callback: (d: any) => void, errHandle?: (e: any) => void | null) => {
- const requestOptions = {
- method: 'POST',
- headers: {
- 'X-Store-Name': Cache.GetCurrentStore().name,
- 'X-Auth': getToken()
- },
- body: JSON.stringify({
- sourceSuiteName: sourceSuiteName,
- targetSuiteName: targetSuiteName,
- })
- }
- fetch(`/api/v1/suites/${sourceSuiteName}/rename`, requestOptions)
- .then(DefaultResponseProcess)
- .then(callback).catch(errHandle)
+ callback: (d: any) => void, errHandle?: (e: any) => void | null) => {
+ const requestOptions = {
+ method: 'POST',
+ headers: {
+ 'X-Store-Name': Cache.GetCurrentStore().name,
+ 'X-Auth': getToken()
+ },
+ body: JSON.stringify({
+ sourceSuiteName: sourceSuiteName,
+ targetSuiteName: targetSuiteName,
+ })
+ }
+ fetch(`/api/v1/suites/${sourceSuiteName}/rename`, requestOptions)
+ .then(DefaultResponseProcess)
+ .then(callback).catch(errHandle)
}
function ImportTestSuite(source: ImportSource, callback: (d: any) => void,
- errHandle?: (e: any) => void | null) {
- const requestOptions = {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- 'X-Store-Name': source.store,
- 'X-Auth': getToken()
- },
- body: JSON.stringify(source)
- }
+ errHandle?: (e: any) => void | null) {
+ const requestOptions = {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-Store-Name': source.store,
+ 'X-Auth': getToken()
+ },
+ body: JSON.stringify(source)
+ }
- fetch(`/api/v1/suites/import`, requestOptions).
- then(DefaultResponseProcess).then(callback).catch(errHandle)
+ fetch(`/api/v1/suites/import`, requestOptions).
+ then(DefaultResponseProcess).then(callback).catch(errHandle)
}
export interface TestCase {
- suiteName: string
- name: string
- request: any
+ suiteName: string
+ name: string
+ request: any
}
interface HistoryTestCase {
- historyCaseID : string,
- suiteName: string
- caseName: string
+ historyCaseID: string,
+ suiteName: string
+ caseName: string
}
function CreateTestCase(testcase: TestCase,
- callback: (d: any) => void, errHandle?: (e: any) => void | null) {
- const requestOptions = {
- method: 'POST',
- headers: {
- 'X-Store-Name': Cache.GetCurrentStore().name,
- 'X-Auth': getToken()
- },
- body: JSON.stringify({
- suiteName: testcase.suiteName,
- data: {
- name: testcase.name,
- request: testcase.request
- }
- })
- }
+ callback: (d: any) => void, errHandle?: (e: any) => void | null) {
+ const requestOptions = {
+ method: 'POST',
+ headers: {
+ 'X-Store-Name': Cache.GetCurrentStore().name,
+ 'X-Auth': getToken()
+ },
+ body: JSON.stringify({
+ suiteName: testcase.suiteName,
+ data: {
+ name: testcase.name,
+ request: testcase.request
+ }
+ })
+ }
- fetch(`/api/v1/suites/${testcase.suiteName}/cases`, requestOptions)
- .then(DefaultResponseProcess)
- .then(callback).catch(emptyOrDefault(errHandle))
+ fetch(`/api/v1/suites/${testcase.suiteName}/cases`, requestOptions)
+ .then(DefaultResponseProcess)
+ .then(callback).catch(emptyOrDefault(errHandle))
}
function UpdateTestCase(testcase: any,
- callback: (d: any) => void, errHandle?: (e: any) => void | null,
- toggle?: (e: boolean) => void) {
+ callback: (d: any) => void, errHandle?: (e: any) => void | null,
+ toggle?: (e: boolean) => void) {
const requestOptions = {
- method: 'PUT',
- headers: {
- 'X-Store-Name': Cache.GetCurrentStore().name,
- 'X-Auth': getToken()
- },
- body: JSON.stringify(testcase)
+ method: 'PUT',
+ headers: {
+ 'X-Store-Name': Cache.GetCurrentStore().name,
+ 'X-Auth': getToken()
+ },
+ body: JSON.stringify(testcase)
}
safeToggleFunc(toggle)(true)
fetch(`/api/v1/suites/${testcase.suiteName}/cases/${testcase.data.name}`, requestOptions)
- .then(DefaultResponseProcess)
- .then(callback).catch(emptyOrDefault(errHandle))
- .finally(() => {
- safeToggleFunc(toggle)(false)
- })
+ .then(DefaultResponseProcess)
+ .then(callback).catch(emptyOrDefault(errHandle))
+ .finally(() => {
+ safeToggleFunc(toggle)(false)
+ })
}
function GetTestCase(req: TestCase,
- callback: (d: any) => void, errHandle?: (e: any) => void | null) {
- const requestOptions = {
- headers: {
- 'X-Store-Name': Cache.GetCurrentStore().name,
- 'X-Auth': getToken()
+ callback: (d: any) => void, errHandle?: (e: any) => void | null) {
+ const requestOptions = {
+ headers: {
+ 'X-Store-Name': Cache.GetCurrentStore().name,
+ 'X-Auth': getToken()
+ }
}
- }
- fetch(`/api/v1/suites/${req.suiteName}/cases/${req.name}`, requestOptions)
- .then(DefaultResponseProcess)
- .then(callback).catch(emptyOrDefault(errHandle))
+ fetch(`/api/v1/suites/${req.suiteName}/cases/${req.name}`, requestOptions)
+ .then(DefaultResponseProcess)
+ .then(callback).catch(emptyOrDefault(errHandle))
}
function ListTestCase(suite: string, store: string,
- callback: (d: any) => void, errHandle?: (e: any) => void | null) {
- const requestOptions = {
- headers: {
- 'X-Store-Name': store,
- 'X-Auth': getToken()
+ callback: (d: any) => void, errHandle?: (e: any) => void | null) {
+ const requestOptions = {
+ headers: {
+ 'X-Store-Name': store,
+ 'X-Auth': getToken()
+ }
}
- }
- fetch(`/api/v1/suites/${suite}/cases`, requestOptions)
- .then(DefaultResponseProcess)
- .then(callback).catch(emptyOrDefault(errHandle))
+ fetch(`/api/v1/suites/${suite}/cases`, requestOptions)
+ .then(DefaultResponseProcess)
+ .then(callback).catch(emptyOrDefault(errHandle))
}
function DeleteTestCase(testcase: TestCase,
- callback: (d: any) => void, errHandle?: (e: any) => void | null) {
+ callback: (d: any) => void, errHandle?: (e: any) => void | null) {
const requestOptions = {
- method: 'DELETE',
- headers: {
- 'X-Store-Name': Cache.GetCurrentStore().name,
- 'X-Auth': getToken()
- },
- body: JSON.stringify({
- suite: testcase.suiteName,
- testcase: testcase.name
- })
+ method: 'DELETE',
+ headers: {
+ 'X-Store-Name': Cache.GetCurrentStore().name,
+ 'X-Auth': getToken()
+ },
+ body: JSON.stringify({
+ suite: testcase.suiteName,
+ testcase: testcase.name
+ })
}
fetch(`/api/v1/suites/${testcase.suiteName}/cases/${testcase.name}`, requestOptions)
- .then(callback).catch(emptyOrDefault(errHandle))
+ .then(callback).catch(emptyOrDefault(errHandle))
}
interface RunTestCaseRequest {
- suiteName: string
- name: string
- parameters: any
+ suiteName: string
+ name: string
+ parameters: any
}
interface BatchRunTestCaseRequest {
- count: number
- interval: string
- request: RunTestCaseRequest
+ count: number
+ interval: string
+ request: RunTestCaseRequest
}
function RunTestCase(request: RunTestCaseRequest,
- callback: (d: any) => void, errHandle?: (e: any) => void | null) {
- const requestOptions = {
- method: 'POST',
- headers: {
- 'X-Store-Name': Cache.GetCurrentStore().name,
- 'X-Auth': getToken()
- },
- body: JSON.stringify({
- suite: request.suiteName,
- testcase: request.name,
- parameters: request.parameters
- })
- }
- fetch(`/api/v1/suites/${request.suiteName}/cases/${request.name}/run`, requestOptions)
- .then(DefaultResponseProcess)
- .then(callback).catch(emptyOrDefault(errHandle))
+ callback: (d: any) => void, errHandle?: (e: any) => void | null) {
+ const requestOptions = {
+ method: 'POST',
+ headers: {
+ 'X-Store-Name': Cache.GetCurrentStore().name,
+ 'X-Auth': getToken()
+ },
+ body: JSON.stringify({
+ suite: request.suiteName,
+ testcase: request.name,
+ parameters: request.parameters
+ })
+ }
+ fetch(`/api/v1/suites/${request.suiteName}/cases/${request.name}/run`, requestOptions)
+ .then(DefaultResponseProcess)
+ .then(callback).catch(emptyOrDefault(errHandle))
}
const BatchRunTestCase = (request: BatchRunTestCaseRequest,
- callback: (d: any) => void, errHandle?: (e: any) => void | null) => {
- const requestOptions = {
- method: 'POST',
- headers: {
- 'X-Store-Name': Cache.GetCurrentStore().name,
- 'Accept': 'text/event-stream',
- 'X-Auth': getToken()
- },
- body: JSON.stringify({
- suiteName: request.request.suiteName,
- caseName: request.request.name,
- parameters: request.request.parameters,
- count: request.count,
- interval: request.interval,
- })
- }
- fetch(`/api/v1/batchRun`, requestOptions)
- .then((response: any) => {
- if (response.ok) {
- const read = (reader: any) => {
- reader.read().then((data: any) => {
- if (data.done) {
- return;
+ callback: (d: any) => void, errHandle?: (e: any) => void | null) => {
+ const requestOptions = {
+ method: 'POST',
+ headers: {
+ 'X-Store-Name': Cache.GetCurrentStore().name,
+ 'Accept': 'text/event-stream',
+ 'X-Auth': getToken()
+ },
+ body: JSON.stringify({
+ suiteName: request.request.suiteName,
+ caseName: request.request.name,
+ parameters: request.request.parameters,
+ count: request.count,
+ interval: request.interval,
+ })
+ }
+ fetch(`/api/v1/batchRun`, requestOptions)
+ .then((response: any) => {
+ if (response.ok) {
+ const read = (reader: any) => {
+ reader.read().then((data: any) => {
+ if (data.done) {
+ return;
+ }
+
+ const value = data.value;
+ const chunk = new TextDecoder().decode(value, { stream: true });
+ callback(JSON.parse(chunk).result.testCaseResult[0]);
+ read(reader);
+ });
+ }
+ read(response.body.getReader());
+ } else {
+ return DefaultResponseProcess(response)
}
-
- const value = data.value;
- const chunk = new TextDecoder().decode(value, { stream: true });
- callback(JSON.parse(chunk).result.testCaseResult[0]);
- read(reader);
- });
- }
- read(response.body.getReader());
- } else {
- return DefaultResponseProcess(response)
- }
- }).catch(emptyOrDefault(errHandle))
+ }).catch(emptyOrDefault(errHandle))
}
function DuplicateTestCase(sourceSuiteName: string, targetSuiteName: string,
- sourceTestCaseName: string, targetTestCaseName: string,
- callback: (d: any) => void, errHandle?: ((reason: any) => PromiseLike