Comments (5)
With the above solution, it will be hard to define many different states for a single url and control them from the UI\API, which is what Leonardo is all about.
I suggest we add a new match
property on the state level - which is a function that gets the request and returns a boolean which determine if Leonardo should use this state or keep looking for other matching states.
It will enable defining many states with the same URL and different macth
function.
example:
Leonardo.addState({
name: 'Get Comments',
verb: 'GET',
url: 'api/comments',
match: (request) => {
// returns true is this request should be processed by the current state,
// otherwise Leonardo will keep looking for matching state
return !!request.body.comments;
},
options: [{
"name": "Success with function",
"status": 200,
"data": {
comments: {}
}
]}
})
@dwido WDYT?
from leonardo.
hey @k3nsei,
Thanks for bringing this up, I am thinking of a few ways to deal with this when data property is a function
- when returning undefined from the function it will pass to the server
- returning a global e.g.
Leonardo.addState({
name: 'Get Comments',
verb: 'GET',
url: 'api/comments',
options: [{
"name": "Success with function",
"status": 200,
"data": (request) => {
// calculate response in real time
return Leonardo.goToServer;
}]
}
@tsachis @MrFrankel any other ideas?
from leonardo.
I think that @tsachis approach is quite good.
from leonardo.
@tsachis seems that this approach is problematic when working with Sinon, the reason is that the decision if to mock a state or let it pass through is done when the xhr.open method is being called when there are no parameters of the request
from leonardo.
@tsachis this can be closed
from leonardo.
Related Issues (20)
- Try to remove synon HOT 1
- Add an "Add State" button to the Scenarios tab HOT 1
- Close editor tab on save
- List Item Selection indicator is buggy HOT 1
- Change images and fix up docs HOT 1
- Add Clear All to the Recorder tab HOT 1
- Leonardo is included in production mode HOT 6
- Add a search filter to the state options dropdown HOT 1
- Add tooltip on Leonardo head HOT 1
- Add the ability to drag and drop Leonardo icon in the screen HOT 1
- Filter relevant requests for a particular feature
- Filter requests by status
- Add option to return specific request or state after delete.
- Clicking on the "edit" icon and clicking on the row, both open the edit request dialog
- Add Record App flow to allow new application to easily add leonardo
- Revive 'Add State' from the recorder tab
- Replace Travis-CI With GitHub Actions
- Sidebar Doesnโt Closes When Clicking On Gray Area
- Cancelling HTTP requests does not work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leonardo.