diff --git a/src/workbench/browser/src/app/pages/api/test/api-test.component.html b/src/workbench/browser/src/app/pages/api/test/api-test.component.html index 3c281854..d0b60ea8 100644 --- a/src/workbench/browser/src/app/pages/api/test/api-test.component.html +++ b/src/workbench/browser/src/app/pages/api/test/api-test.component.html @@ -76,21 +76,21 @@ - Prescript + Before script {{ apiData.restParams | apiParamsNum }} - + - Post script + After Script {{ apiData.restParams | apiParamsNum }} - + diff --git a/src/workbench/browser/src/app/pages/api/test/api-test.component.ts b/src/workbench/browser/src/app/pages/api/test/api-test.component.ts index d568586c..526ace09 100644 --- a/src/workbench/browser/src/app/pages/api/test/api-test.component.ts +++ b/src/workbench/browser/src/app/pages/api/test/api-test.component.ts @@ -41,6 +41,8 @@ export class ApiTestComponent implements OnInit, OnDestroy { parameters: [], hostUri: '', }; + beforeScript = ''; + afterScript = ''; status: 'start' | 'testing' | 'tested' = 'start'; waitSeconds = 0; tabIndexRes = 0; @@ -149,9 +151,13 @@ export class ApiTestComponent implements OnInit, OnDestroy { this.testServer.send('unitTest', { id: this.apiTab.tabID, action: 'ajax', - data: this.testServer.formatRequestData(this.apiData, { - env: this.env, - }), + data: { + beforeScript: this.beforeScript, + afterScript: this.afterScript, + ...this.testServer.formatRequestData(this.apiData, { + env: this.env, + }), + }, }); this.status$.next('testing'); } diff --git a/src/workbench/browser/src/app/shared/components/api-script/api-script.component.ts b/src/workbench/browser/src/app/shared/components/api-script/api-script.component.ts index 49d90f06..d4bee664 100644 --- a/src/workbench/browser/src/app/shared/components/api-script/api-script.component.ts +++ b/src/workbench/browser/src/app/shared/components/api-script/api-script.component.ts @@ -1,7 +1,7 @@ import { SelectionModel } from '@angular/cdk/collections'; import { FlatTreeControl } from '@angular/cdk/tree'; // import { FlatTreeControl } from 'ng-zorro-antd/node_modules/@angular/cdk/tree'; -import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; import { EoEditorComponent } from 'eo/workbench/browser/src/app/eoui/editor/eo-editor/eo-editor.component'; import { NzTreeFlatDataSource, NzTreeFlattener } from 'ng-zorro-antd/tree-view'; @@ -14,11 +14,10 @@ import { TREE_DATA } from './constant'; styleUrls: ['./api-script.component.scss'], }) export class ApiScriptComponent implements OnInit { - @Output() codeChange = new EventEmitter(); + @Input() code = ''; + @Output() codeChange: EventEmitter = new EventEmitter(); @ViewChild(EoEditorComponent, { static: false }) eoEditor?: EoEditorComponent; - private code = ''; - private transformer = (node: TreeNode, level: number): FlatNode => ({ ...node, expandable: !!node.children && node.children.length > 0, @@ -43,7 +42,6 @@ export class ApiScriptComponent implements OnInit { // @ts-ignore dataSource = new NzTreeFlatDataSource(this.treeControl, this.treeFlattener); - model = ''; constructor() { this.dataSource.setData(TREE_DATA); this.treeControl.expandAll(); @@ -54,7 +52,6 @@ export class ApiScriptComponent implements OnInit { hasChild = (_: number, node: FlatNode): boolean => node.expandable; handleChange(code) { - this.code = code; setTimeout(() => { this.codeChange.emit(code); }, 0);