Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 69 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Wrapper = styled.div`
transition: color 0.15s ease;

&:hover {
color: ${(props) => props.theme.colors.text.link};
color: ${(props) => props.theme.text};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,21 @@ const MultipartFormParams = ({ item, collection }) => {
const currentParams = item.draft
? get(item, 'draft.request.body.multipartForm')
: get(item, 'request.body.multipartForm');
const updatedParams = (currentParams || []).map((p) => {
if (p.uid === row.uid) {
return { ...p, type: 'file', value: processedPaths };
}
return p;
});
const existsInParams = (currentParams || []).some((p) => p.uid === row.uid);
let updatedParams;
if (existsInParams) {
updatedParams = currentParams.map((p) => {
if (p.uid === row.uid) {
return { ...p, type: 'file', value: processedPaths };
}
return p;
});
} else {
updatedParams = [
...(currentParams || []),
{ uid: row.uid, name: row.name || '', enabled: true, type: 'file', value: processedPaths, contentType: '' }
];
}
handleParamsChange(updatedParams);
})
.catch((error) => {
Expand Down Expand Up @@ -139,13 +148,6 @@ const MultipartFormParams = ({ item, collection }) => {
if (fileName) {
return (
<div className="flex items-center file-value-cell">
<button
className="clear-file-btn ml-1"
onClick={() => handleClearFile(row)}
title="Remove file"
>
<IconX size={16} />
</button>
<IconFile size={16} className="text-muted mr-1" />
<div className="file-name flex-1 truncate" title={Array.isArray(value) ? value.join(', ') : value}>
<SingleLineEditor
Expand All @@ -156,6 +158,13 @@ const MultipartFormParams = ({ item, collection }) => {
item={item}
/>
</div>
<button
className="clear-file-btn ml-1"
onClick={() => handleClearFile(row)}
title="Remove file"
>
<IconX size={16} />
</button>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,29 @@ const Wrapper = styled.div`

.upload-btn,
.clear-file-btn {
display: flex;
align-items: center;
justify-content: center;
padding: 4px;
color: ${(props) => props.theme.colors.text.muted};
background: transparent;
border: none;
cursor: pointer;
border-radius: 4px;
transition: color 0.15s ease;
flex-shrink: 0;

&:hover {
color: ${(props) => props.theme.text};
}
}

.clear-file-btn:hover {
color: ${(props) => props.theme.colors.text.danger};
}

.file-value-cell {
width: 100%;
}

.value-cell {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const replacements = {
'pm\\.variables\\.toObject\\(': 'bru.getAllVars(',
'pm\\.request\\.headers\\.remove\\(': 'req.deleteHeader(',
'pm\\.response\\.headers\\.get\\(': 'res.getHeader(',
'pm\\.response\\.to\\.have\\.jsonSchema\\(': 'expect(res.getBody()).to.have.jsonSchema(',
'pm\\.response\\.to\\.not\\.have\\.jsonSchema\\(': 'expect(res.getBody()).to.not.have.jsonSchema(',
'pm\\.response\\.not\\.to\\.have\\.jsonSchema\\(': 'expect(res.getBody()).not.to.have.jsonSchema(',
'pm\\.response\\.to\\.have\\.not\\.jsonSchema\\(': 'expect(res.getBody()).to.have.not.jsonSchema(',
'pm\\.response\\.to\\.have\\.body\\(': 'expect(res.getBody()).to.equal(',
'pm\\.response\\.to\\.have\\.header\\(': 'expect(res.getHeaders()).to.have.property(',
'pm\\.response\\.size\\(\\)': 'res.getSize()',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,74 @@ const complexTransformations = [
}
},

// pm.response.to.have.jsonSchema(schema, options?) -> expect(res.getBody()).to.have.jsonSchema(schema, options?)
{
pattern: 'pm.response.to.have.jsonSchema',
transform: (path, j) => {
const args = path.parent.value.arguments;
return j.callExpression(
j.memberExpression(
j.callExpression(j.identifier('expect'), [
j.callExpression(j.identifier('res.getBody'), [])
]),
j.identifier('to.have.jsonSchema')
),
args
);
}
},

// pm.response.to.not.have.jsonSchema(schema, options?) -> expect(res.getBody()).to.not.have.jsonSchema(schema, options?)
{
pattern: 'pm.response.to.not.have.jsonSchema',
transform: (path, j) => {
const args = path.parent.value.arguments;
return j.callExpression(
j.memberExpression(
j.callExpression(j.identifier('expect'), [
j.callExpression(j.identifier('res.getBody'), [])
]),
j.identifier('to.not.have.jsonSchema')
),
args
);
}
},

// pm.response.not.to.have.jsonSchema(schema, options?) -> expect(res.getBody()).not.to.have.jsonSchema(schema, options?)
{
pattern: 'pm.response.not.to.have.jsonSchema',
transform: (path, j) => {
const args = path.parent.value.arguments;
return j.callExpression(
j.memberExpression(
j.callExpression(j.identifier('expect'), [
j.callExpression(j.identifier('res.getBody'), [])
]),
j.identifier('not.to.have.jsonSchema')
),
args
);
}
},

// pm.response.to.have.not.jsonSchema(schema, options?) -> expect(res.getBody()).to.have.not.jsonSchema(schema, options?)
{
pattern: 'pm.response.to.have.not.jsonSchema',
transform: (path, j) => {
const args = path.parent.value.arguments;
return j.callExpression(
j.memberExpression(
j.callExpression(j.identifier('expect'), [
j.callExpression(j.identifier('res.getBody'), [])
]),
j.identifier('to.have.not.jsonSchema')
),
args
);
}
},

// Legacy postman.getResponseHeader(name) -> res.getHeader(name)
{
pattern: 'pm.getResponseHeader',
Expand Down
Loading
Loading