Merge branch 'master' into next
This commit is contained in:
993
package-lock.json
generated
993
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@@ -102,19 +102,19 @@
|
||||
"devDependencies": {
|
||||
"@babel/cli": "=7.21.0",
|
||||
"@babel/core": "=7.21.0",
|
||||
"@babel/eslint-parser": "=7.19.1",
|
||||
"@babel/eslint-parser": "=7.21.3",
|
||||
"@babel/plugin-proposal-class-properties": "=7.16.7",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "=7.18.6",
|
||||
"@babel/plugin-proposal-object-rest-spread": "=7.19.4",
|
||||
"@babel/plugin-proposal-optional-chaining": "=7.21.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "=7.16.8",
|
||||
"@babel/plugin-transform-modules-commonjs": "=7.21.2",
|
||||
"@babel/plugin-transform-runtime": "=7.21.0",
|
||||
"@babel/preset-env": "=7.21.4",
|
||||
"@babel/preset-react": "=7.14.5",
|
||||
"@babel/register": "=7.21.0",
|
||||
"@commitlint/cli": "^17.5.0",
|
||||
"@commitlint/cli": "^17.6.1",
|
||||
"@commitlint/config-conventional": "^17.4.4",
|
||||
"@jest/globals": "=29.4.3",
|
||||
"@jest/globals": "=29.5.0",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
|
||||
"@release-it/conventional-changelog": "=5.1.0",
|
||||
"@wojtekmaj/enzyme-adapter-react-17": "=0.6.6",
|
||||
@@ -127,7 +127,7 @@
|
||||
"buffer": "^6.0.3",
|
||||
"cors": "^2.8.5",
|
||||
"cross-env": "=7.0.3",
|
||||
"css-loader": "=6.7.1",
|
||||
"css-loader": "=6.7.3",
|
||||
"cssnano": "=6.0.0",
|
||||
"cypress": "=9.5.1",
|
||||
"dedent": "^0.7.0",
|
||||
@@ -136,7 +136,7 @@
|
||||
"eslint": "^8.37.0",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-jest": "^26.1.1",
|
||||
"eslint-plugin-mocha": "^9.0.0",
|
||||
"eslint-plugin-mocha": "^10.1.0",
|
||||
"eslint-plugin-react": "^7.27.1",
|
||||
"esm": "=3.2.25",
|
||||
"expect": "=29.5.0",
|
||||
@@ -154,7 +154,7 @@
|
||||
"json-server": "=0.17.3",
|
||||
"less": "^4.1.2",
|
||||
"license-checker": "^25.0.0",
|
||||
"lint-staged": "^13.2.0",
|
||||
"lint-staged": "^13.2.1",
|
||||
"local-web-server": "^5.3.0",
|
||||
"mini-css-extract-plugin": "^2.6.1",
|
||||
"mocha": "=8.4.0",
|
||||
@@ -163,8 +163,8 @@
|
||||
"oauth2-server": "^2.4.1",
|
||||
"open": "^9.1.0",
|
||||
"postcss": "^8.4.14",
|
||||
"postcss-loader": "^7.1.0",
|
||||
"postcss-preset-env": "^8.1.0",
|
||||
"postcss-loader": "^7.2.4",
|
||||
"postcss-preset-env": "^8.3.0",
|
||||
"prettier": "^2.8.7",
|
||||
"process": "^0.11.10",
|
||||
"react-refresh": "^0.14.0",
|
||||
@@ -179,7 +179,7 @@
|
||||
"stream-browserify": "^3.0.0",
|
||||
"tachyons-sass": "^4.9.5",
|
||||
"terser-webpack-plugin": "^5.3.7",
|
||||
"webpack": "^5.76.3",
|
||||
"webpack": "^5.80.0",
|
||||
"webpack-bundle-size-analyzer": "^3.1.0",
|
||||
"webpack-cli": "^4.10.0",
|
||||
"webpack-dev-server": "^4.7.4",
|
||||
|
||||
@@ -59,11 +59,13 @@ export default class ResponseBody extends React.PureComponent {
|
||||
url = url || ""
|
||||
|
||||
if (
|
||||
/^application\/octet-stream/i.test(contentType) ||
|
||||
(headers["Content-Disposition"] && (/attachment/i).test(headers["Content-Disposition"])) ||
|
||||
(headers["content-disposition"] && (/attachment/i).test(headers["content-disposition"])) ||
|
||||
(headers["Content-Description"] && (/File Transfer/i).test(headers["Content-Description"])) ||
|
||||
(headers["content-description"] && (/File Transfer/i).test(headers["content-description"]))) {
|
||||
(/^application\/octet-stream/i.test(contentType) ||
|
||||
(headers["Content-Disposition"] && /attachment/i.test(headers["Content-Disposition"])) ||
|
||||
(headers["content-disposition"] && /attachment/i.test(headers["content-disposition"])) ||
|
||||
(headers["Content-Description"] && /File Transfer/i.test(headers["Content-Description"])) ||
|
||||
(headers["content-description"] && /File Transfer/i.test(headers["content-description"]))) &&
|
||||
content.size > 0
|
||||
) {
|
||||
// Download
|
||||
|
||||
if ("Blob" in window) {
|
||||
|
||||
@@ -39,4 +39,18 @@ describe("<ResponseBody />", function () {
|
||||
console.warn(wrapper.debug())
|
||||
expect(wrapper.find("highlightCodeComponent[canCopy]").length).toEqual(1)
|
||||
})
|
||||
|
||||
it("should render Download file link for non-empty response", function () {
|
||||
props.contentType = "application/octet-stream"
|
||||
props.content = new Blob(["\"test\""], { type: props.contentType })
|
||||
const wrapper = shallow(<ResponseBody {...props} />)
|
||||
expect(wrapper.text()).toMatch(/Download file/)
|
||||
})
|
||||
|
||||
it("should not render Download file link for empty response", function () {
|
||||
props.contentType = "application/octet-stream"
|
||||
props.content = new Blob()
|
||||
const wrapper = shallow(<ResponseBody {...props} />)
|
||||
expect(wrapper.text()).not.toMatch(/Download file/)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -29,6 +29,11 @@ function setUpDomEnvironment() {
|
||||
}
|
||||
copyProps(win, window) // use UI's built-in window wrapper
|
||||
copyProps(window, global)
|
||||
|
||||
// https://github.com/jsdom/jsdom/issues/1721
|
||||
if (typeof global.window.URL.createObjectURL === "undefined") {
|
||||
Object.defineProperty(global.window.URL, "createObjectURL", { value: () => "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==" })
|
||||
}
|
||||
}
|
||||
|
||||
setUpDomEnvironment()
|
||||
|
||||
Reference in New Issue
Block a user