Skip to content

Commit

Permalink
overwriteRequestQueryParams - Enable disabled query params (#528)
Browse files Browse the repository at this point in the history
* overwriteRequestQueryParams - Enable query params
  • Loading branch information
thim81 authored Oct 28, 2023
1 parent 35eb5c5 commit 9b4686b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## [Unreleased]

- overwriteRequestQueryParams - Enable disabled query params (#484)

## v1.23.0 - (2023-10-28)

- orderOfOperations - Adjusted ordering string matching to be exact when wildcard is not present (#490)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ Array [
]
`;

exports[`overwriteRequestQueryParams should enable the request query param 1`] = `
Array [
Object {
"description": Object {
"content": "Include raw response. Mostly used for debugging purposes",
"type": "text/plain",
},
"disabled": false,
"key": "raw",
"value": "true",
},
]
`;

exports[`overwriteRequestQueryParams should insert the query param variable with description, if key not found 1`] = `
Array [
Object {
Expand Down
21 changes: 21 additions & 0 deletions src/application/overwrites/overwriteRequestQueryParams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ describe('overwriteRequestQueryParams', () => {
expect(result.item.request.url.query).toMatchSnapshot()
})

it('should enable the request query param', async () => {
const overwriteValues = [
{
key: 'raw',
disable: false
}
]
const pmOperation = await getPostmanMappedOperation()

const queryParams = pmOperation.item.request.url.query.all()
const firstQueryParamKey = queryParams[0]
firstQueryParamKey.disabled = true

// Set the updated query parameters in the request
pmOperation.item.request.url.query.clear()
pmOperation.item.request.url.query.add(firstQueryParamKey)

const result = overwriteRequestQueryParams(overwriteValues, pmOperation)
expect(result.item.request.url.query).toMatchSnapshot()
})

it('should append the request query param when overwrite is false', async () => {
const overwriteValues = [
{
Expand Down
4 changes: 4 additions & 0 deletions src/application/overwrites/overwriteRequestQueryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export const overwriteRequestQueryParams = (
pmQueryParam.disabled = true
}

if (overwriteItem?.disable === false) {
pmQueryParam.disabled = false
}

// Test suite - Overwrite query param description
if (overwriteItem?.description) {
pmQueryParam.description = overwriteItem.description
Expand Down

0 comments on commit 9b4686b

Please sign in to comment.