Skip to content

Commit

Permalink
test(e2e): api operate
Browse files Browse the repository at this point in the history
  • Loading branch information
scarqin committed Mar 10, 2023
1 parent 8d5736c commit 9c2b059
Show file tree
Hide file tree
Showing 21 changed files with 555 additions and 135 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"release": "npm-run-all -s electron:build:web electron:tsc && npx esno scripts/build.ts --publish=always && node scripts/upload.js",
"test": "npm-run-all --serial test:*",
"e2e": "cd test/e2e&&npx playwright test -c playwright.config.ts",
"test:e2e": "npm-run-all -s start:web test:e2e",
"test:e2e": "yarn e2e",
"clear:electron:tsc": "tsc --build --clean",
"electron:tsc": "tsc -p tsconfig.json",
"electron:dev": "npm run electron:tsc && electron . --development",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<button
eo-ng-button
nzType="text"
class="flex items-center justify-center icon"
class="flex items-center justify-center icon pc-setting-btn"
i18n-nzTooltipTitle
eoNgFeedbackTooltip
[nzTooltipMouseEnterDelay]="0.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ApiParamsTypeJsonOrXml } from '../api.model';
const titleHash = new Map()
.set('xml', $localize`Import XML`)
.set('json', $localize`Import JSON`)
.set('formData', $localize`Import Form-data`)
.set('formData', $localize`Import Form-Data`)
.set('header', $localize`Import Header`)
.set('query', $localize`Import Query`);

Expand Down Expand Up @@ -80,6 +80,7 @@ export class ParamsImportComponent implements OnInit {
} catch (error) {}
} else if (['formData', 'header'].includes(this.contentType)) {
const arr = form2json(clipText);
console.log(arr);
if (Array.isArray(arr) && arr.length && clipText.split(':').length > 1) {
this.paramCode = clipText;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class EoTableProComponent implements OnInit, OnChanges {
}

btnClick(btnItem, index, item, apis) {
console.log('eo-table-pro:btnClick:', btnItem, index, item, apis);
// console.log('eo-table-pro:btnClick:', btnItem, index, item, apis);
if (btnItem.click) {
btnItem.click(item, index, apis);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import { StoreService } from 'eo/workbench/browser/src/app/shared/store/state.se
<section class="w-1/2">
<form nz-form [formGroup]="validatePasswordForm" nzLayout="vertical">
<nz-form-item>
<nz-form-label [nzSpan]="24" nzRequired i18n>New password</nz-form-label>
<nz-form-label [nzSpan]="24" nzRequired i18n nzFor="newPassword">New password</nz-form-label>
<nz-form-control i18n-nzErrorTip nzErrorTip="Please input your new password">
<input type="password" eo-ng-input formControlName="newPassword" placeholder="" i18n-placeholder />
<input type="password" eo-ng-input formControlName="newPassword" id="newPassword" placeholder="" i18n-placeholder />
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="24" nzRequired i18n>Confirm new password</nz-form-label>
<nz-form-label [nzSpan]="24" nzRequired i18n nzFor="confirmPassword">Confirm new password</nz-form-label>
<nz-form-control [nzErrorTip]="confirmPasswordErrorTpl">
<input type="password" eo-ng-input formControlName="confirmPassword" placeholder="" i18n-placeholder />
<input type="password" eo-ng-input formControlName="confirmPassword" id="confirmPassword" placeholder="" i18n-placeholder />
<ng-template #confirmPasswordErrorTpl let-control>
<ng-container *ngIf="control.hasError('required')" i18n> Please input your confirm new password </ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
i18n-placeholder
placeholder="Enter URL"
name="uri"
(blur)="blurUri()"
eo-ng-input
(input)="updateParamsbyUri(model.request.uri)"
(input)="updateParamsbyUri()"
formControlName="uri"
[(ngModel)]="model.request.uri"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,21 @@ export class ApiTestComponent implements OnInit, AfterViewInit, OnDestroy, TabVi
this.modelChange.emit(this.model);
});
}
updateParamsbyUri(url) {
updateParamsbyUri() {
this.model.request.requestParams.queryParams = syncUrlAndQuery(
this.model.request.uri,
this.model.request.requestParams.queryParams
).query;
}
blurUri() {
this.model.request.requestParams.restParams = [
...generateRestFromUrl(this.model.request.uri, this.model.request.requestParams.restParams)
];
}
bindGetApiParamNum(params) {
return new ApiParamsNumPipe().transform(params);
}

/**
* Judge has edit manualy
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { ApiBodyType } from 'eo/workbench/browser/src/app/modules/api-shared/api.model';
import { BodyParam, HeaderParam } from 'eo/workbench/browser/src/app/shared/services/storage/db/models/apiData';

export enum ApiTestParamsTypeFormData {
text = 'string',
file = 'file'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,19 @@ export class ApiTestUtilService {
* @param headers
*/
addOrReplaceContentType(contentType: ContentType, headers: HeaderParam[] | any = []) {
const result = headers;
const existHeader = headers.find(val => val.name.toLowerCase() === 'content-type');
if (existHeader) {
existHeader['paramAttr.example'] = contentType;
return result;
return headers;
}
headers.unshift({
isRequired: 1,
name: 'content-type',
'paramAttr.example': contentType
});
const result = [
{
isRequired: 1,
name: 'content-type',
'paramAttr.example': contentType
},
...headers
];
return result;
}
private filterCommonHeader(headers = []) {
Expand Down
Loading

0 comments on commit 9c2b059

Please sign in to comment.