-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(runner): cleaning up runner-pr1 and resolve conflicts (#7878)
* feat: log request testing results and return them to the main renderer * fix: lint error * fix: install chai with unified version across packages * chore: restore package-lock * chore: restore package-lock * feat(GUI): enable test results pane (#7737) * feat: enable the test result pane * test: bring back tests and cleanups * chore: replace tabitem with tabpanel * chore: useMemo for test result counts * refactor: abstract RequestTestResultRows as a component * chore: cleanup package lock * chore: restore package lock * feat: enable collection runner * fix: cli test failed * fix: lint error * fix: race condition in canceling runner * fix: runner is not canceled when there's an exception * fix: lint error * 1.fix after response iteration and eventname issue * chore: disable the flaky test --------- Co-authored-by: Kent Wang <kent.wang@konghq.com>
- Loading branch information
Showing
54 changed files
with
3,035 additions
and
553 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/insomnia-sdk/src/objects/__tests__/execution.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { Execution } from '../execution'; | ||
|
||
describe('test execution object', () => { | ||
it('test location property', () => { | ||
const location = ['project', 'workspace', 'file', 'requestname']; | ||
const executionInstance = new Execution({ location }); | ||
|
||
expect(executionInstance.location).toStrictEqual(['project', 'workspace', 'file', 'requestname']); | ||
// @ts-expect-error location should have current property by design | ||
expect(executionInstance.location.current).toEqual(location[location.length - 1]); | ||
expect(executionInstance.toObject()).toEqual({ | ||
location: ['project', 'workspace', 'file', 'requestname'], | ||
skipRequest: false, | ||
nextRequestIdOrName: '', | ||
}); | ||
}); | ||
|
||
it('test skipRequest and set nextRequest', () => { | ||
const location = ['project', 'workspace', 'file', 'requestname']; | ||
const executionInstance = new Execution({ location }); | ||
executionInstance.skipRequest(); | ||
executionInstance.setNextRequest('nextRequestNameOrId'); | ||
|
||
expect(executionInstance.toObject()).toEqual({ | ||
location: ['project', 'workspace', 'file', 'requestname'], | ||
skipRequest: true, | ||
nextRequestIdOrName: 'nextRequestNameOrId', | ||
}); | ||
}); | ||
|
||
it('set invalid location', () => { | ||
// @ts-expect-error test invalid input | ||
expect(() => new Execution({ location: 'invalid' })).toThrowError(); | ||
}); | ||
}); |
37 changes: 37 additions & 0 deletions
37
packages/insomnia-sdk/src/objects/__tests__/request-info.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { RequestInfo } from '../request-info'; | ||
|
||
describe('test request info', () => { | ||
it('test normal request info', () => { | ||
const requestInfo = new RequestInfo({ | ||
eventName: 'prerequest', | ||
requestName: 'request_name', | ||
requestId: 'req_bd8b1eb53418482585b70d0a9616a8cc', | ||
}); | ||
expect(requestInfo.toObject()).toEqual({ | ||
eventName: 'prerequest', | ||
requestName: 'request_name', | ||
requestId: 'req_bd8b1eb53418482585b70d0a9616a8cc', | ||
iteration: 1, | ||
iterationCount: 1, | ||
}); | ||
}); | ||
|
||
it('test runner request info', () => { | ||
const runnerRequestInfo = new RequestInfo({ | ||
eventName: 'prerequest', | ||
requestName: 'request_name', | ||
requestId: 'req_bd8b1eb53418482585b70d0a9616a8cc', | ||
iteration: 3, | ||
iterationCount: 5, | ||
}); | ||
expect(runnerRequestInfo.toObject()).toEqual({ | ||
eventName: 'prerequest', | ||
requestName: 'request_name', | ||
requestId: 'req_bd8b1eb53418482585b70d0a9616a8cc', | ||
iteration: 3, | ||
iterationCount: 5, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
export interface ExecutionOption { | ||
location: string[]; | ||
skipRequest?: boolean; | ||
nextRequestIdOrName?: string; | ||
} | ||
|
||
export class Execution { | ||
private _skipRequest: boolean; | ||
private _nextRequestIdOrName: string; | ||
public location: string[]; | ||
|
||
constructor(options: ExecutionOption) { | ||
const { location, skipRequest = false, nextRequestIdOrName = '' } = options; | ||
if (Array.isArray(location)) { | ||
// mapping postman usage of location refer: https://learning.postman.com/docs/tests-and-scripts/write-scripts/postman-sandbox-api-reference/#using-variables-in-scripts | ||
this.location = new Proxy([...location], { | ||
get: (target, prop, receiver) => { | ||
if (prop === 'current') { | ||
return target.length > 0 ? target[target.length - 1] : ''; | ||
}; | ||
return Reflect.get(target, prop, receiver); | ||
}, | ||
}); | ||
this._skipRequest = skipRequest; | ||
this._nextRequestIdOrName = nextRequestIdOrName; | ||
} else { | ||
throw new Error('Location input must be array of string'); | ||
} | ||
}; | ||
|
||
skipRequest = () => { | ||
this._skipRequest = true; | ||
}; | ||
|
||
setNextRequest = (requestIdOrName: string) => { | ||
this._nextRequestIdOrName = requestIdOrName; | ||
}; | ||
|
||
toObject = () => { | ||
return { | ||
location: Array.from(this.location), | ||
skipRequest: this._skipRequest, | ||
nextRequestIdOrName: this._nextRequestIdOrName, | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.