question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: Bruno Workflows

See original GitHub issue

This is a proposal for implementing workflows in Bruno.

Somewhat related to Bruno Test Script RFC #46

Workflows:

  1. A workflow is an ordered sequence of API calls
  2. Data from the previous response can be used in the current request
  3. A developer can easily setup and run a sequence of api calls, as opposed to painfully copy pasting response snippets one by one before executing the next collection method
  4. This could also be used in test scripts to assert the final response.

Examples:

  1. Login and pass the auth token in further API calls
  2. A Shopping flow would search for products, add product(s) to the cart, encrypt payment method then checkout

A workflow would be a first class concept in Bruno similar to collections.

├── collections
│   ├── POST /login
│   └── PUT  /profile
└── workflows
    ├── Update Profile
    │   ├── 1. login
    │   └── 2. update profile
    └── Shop
        ├── 1. search products
        ├── 2. add item
        ├── 3. encrypt card
        └── 4. checkout

Defining a workflow is simple enough, but how do we pass variables over is the interesting part of this proposal.

In Postman after an API call we can run a “post request script” to set collection variables, which are then reused in rest of API calls. But usually it is difficult to understand what the script does, what variables are set, since these are well… scripts 😃

Workflow implementation

  1. Every workflow runs in a new session
  2. A session holds a set of variables that can be embedded in request body or headers
  3. Each step in the workflow can declare a post request json config
  4. This config updates the session variables (using say json query) which are further used down the chain

The idea is… look ma, no scripts!

Update profile workflow steps

  1. login post script config
    {
       "token": "$res.data.token"
    }
    
  2. update profile schema
    {
      "method": "PUT",
      "url": "/profile",
      "headers": {
        "Authorization": "Bearer $token"
      },
      "body": {
      }
    }
    

Tests:

  • Rather than complex asserts in scripts, the workflow could define the expected json at the end of the workflow
  • Bruno would compare the final response to the expected json
  • The workflow runner could capture and show intermediate step failures.
    • Step gave a non 2xx response
    • Step succeeded but did not contain a value that was supposed to populate a variable

Everything being simple json provides a lot of benefits and opportunities.

@helloanoop I can do a PR if this is something you’d be interested in.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ajaishankarcommented, Dec 4, 2022

Sorry for late response… on question 2 on how we know if a var is a response var?

Postman has a list of dynamic vars, and for us similarly $res is a special var checked here.

Any expression that refers to $res should be evaluated after a response, others before request…

1reaction
helloanoopcommented, Nov 13, 2022

Would it make sense to have the Assert configuration only in the right hand pane? The right hand pane (response pane) only becomes visible after the response arrives

image

Also we can show the actual values side by side in that Assert tab itself… Not able to visualize the side by side in Assert tab given that right hand pane becomes active after response arrives

@ajaishankar it’d be great if you want to take a stab at implementing this, I feel we are both aligned here on the assertions part. I was thinking we will use the request tab to code the assertions, and the response tab to show the assertion results (kind of like of how postman allows to write scripts in request pane, and displays test results in response pane).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · usebruno/bruno · GitHub
Issues list ; Proposal: Bruno Workflows. #71 opened Nov 11, 2022 ; Graphql Support. #65 opened Nov 6, 2022 ; Collections icons partially...
Read more >
Solved: Add tasks to standard change proposal? - ServiceNow
Solved: Is it possible when proposing a new standard change to add tasks to the proposal instead of using the default workflow tasks...
Read more >
(PDF) A Proposal for the Inclusion of Accessibility Criteria in ...
A proposal for the inclusion of accessibility criteria in the. publishing workflow of images in biomedical academic articles. Bruno ...
Read more >
“Marry You” Bruno Mars Marriage Proposal
Featuring the Bruno Mars' song “Marry You,” the proposal shows every reaction from the bride who was recorded as almost 60 friends and...
Read more >
How to Write a Proposal and Get What You Want (Free ...
Bonus material: Simple Proposal Format Template + Checklist to help you get started ASAP! A proposal has a lot of different purposes, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found