Skip to content

Commit

Permalink
fix: test restore from history error
Browse files Browse the repository at this point in the history
  • Loading branch information
scarqin committed Feb 9, 2023
1 parent 3cfbeb5 commit 7a2f05d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ApiStoreService } from '../../service/store/api-state.service';
nz-popover
nzPopoverOverlayClassName="background-popover preview-env"
[nzPopoverContent]="envParams"
(nzTooltipVisibleChange)="onVisibleChange($event)"
nzTooltipPlacement="left"
nzPopoverPlacement="bottomRight"
nzPopoverTrigger="click"
Expand Down Expand Up @@ -100,10 +101,14 @@ export class EnvSelectComponent implements OnInit {
private effect: ApiEffectService,
private testUtils: ApiTestUtilService
) {}
onVisibleChange($event) {
if ($event) {
this.gloablParams = this.getGlobalParams();
}
}
ngOnInit() {
makeObservable(this);
this.effect.updateEnvList();
this.gloablParams = this.getGlobalParams();

autorun(() => {
this.renderEnvList = this.store.getEnvList.map(it => ({ label: it.name, value: it.id }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { LanguageService } from 'eo/workbench/browser/src/app/core/services/language/language.service';
import { TabViewComponent } from 'eo/workbench/browser/src/app/modules/eo-ui/tab/tab.model';
import { ApiEditUtilService } from 'eo/workbench/browser/src/app/pages/workspace/project/api/http/edit/api-edit-util.service';
import {
BEFORE_DATA,
AFTER_DATA,
Expand Down Expand Up @@ -136,7 +137,8 @@ export class ApiTestComponent implements OnInit, AfterViewInit, OnDestroy, TabVi
private testServer: TestServerService,
private projectApi: ProjectApiService,
private lang: LanguageService,
private elementRef: ElementRef
private elementRef: ElementRef,
private apiEdit: ApiEditUtilService
) {
this.initBasicForm();
this.testServer.init(message => {
Expand Down Expand Up @@ -387,7 +389,7 @@ export class ApiTestComponent implements OnInit, AfterViewInit, OnDestroy, TabVi
//Add test history
this.apiTest.addHistory({
apiUuid: this.model.request.apiUuid || '-1',
request: this.model.request,
request: this.apiEdit.formatUIApiDataToStorage(this.model.request),
response: message.response
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class ApiTestUtilService {
if (!(val.isRequired && val.name)) {
return acc;
}
return { ...acc, [val.name]: val.paramAttr?.example || '' };
return { ...acc, [val.name]: val['paramAttr.example'] || val.paramAttr?.example || '' };
}, {});
Object.keys(restByName).forEach(restName => {
try {
Expand Down Expand Up @@ -189,6 +189,10 @@ export class ApiTestUtilService {
});
break;
}
case ApiBodyType.Raw: {
binaryRawData = result.requestParams.bodyParams?.[0]?.binaryRawData;
break;
}
case ApiBodyType.Binary: {
binaryRawData = '';
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export abstract class TestServerService implements TestServer {
//@ts-ignore
files: val.files?.map(file => file.content),
paramType: val.dataType === ApiParamsType.file ? '1' : '0',
paramInfo: val.paramAttr?.example
paramInfo: val['paramAttr.example'] || val.paramAttr?.example
}));
}
}
Expand Down

0 comments on commit 7a2f05d

Please sign in to comment.