Skip to content

Commit

Permalink
Fix AvaTax Bruno collection issue with variables (#1578)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofzuraw authored Sep 19, 2024
1 parent dff6d8d commit ca5b6fd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/avatax/bruno/checkout/01-create-storefront-user.bru
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ body:graphql:vars {
"channelSlug": "{{channelSlug}}",
"email": "{{storefrontUserEmail}}",
"password": "{{storefrontUserPassword}}",
"firstName": "{{storefrontUserFirstName}}"
"firstName": "{{storefrontUserName}}"
}
}
4 changes: 2 additions & 2 deletions apps/avatax/bruno/checkout/02-create-storefront-token.bru
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ body:graphql {

body:graphql:vars {
{
"email": "{{storefrontUserEmail}}",
"password": "{{storefrontUserPassword}}"
"email": "{{storefrontUserEmail}}",
"password": "{{storefrontUserPassword}}"
}
}

Expand Down
19 changes: 19 additions & 0 deletions apps/avatax/bruno/collection.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
script:pre-request {
// Remove after https://github.com/usebruno/bruno/issues/2960 in done
function resolveTemplateVariables(string) {
const VARIABLE_NAME_REGEX = /{{([A-Za-z_]\w+)}}/g;

return string.replace(
VARIABLE_NAME_REGEX,
(_, key) => bru.getVar(key) || bru.getEnvVar(key)
);
}

const body = req.getBody();

if (!body.variables) {
return;
}

body.variables = resolveTemplateVariables(body.variables);
}

0 comments on commit ca5b6fd

Please sign in to comment.