Browse Source

Merge pull request #9915 from nextcloud/dependabot/npm_and_yarn/fast-xml-parser-and-is-svg-and-webdav-4.2.5

chore(deps): Bump fast-xml-parser, is-svg and webdav
pull/9968/head
Maksim Sukharev 3 years ago
committed by GitHub
parent
commit
6a439af176
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 250
      package-lock.json
  2. 2
      package.json
  3. 8
      src/__mocks__/webdav.js
  4. 3
      src/components/MediaSettings/VideoBackgroundEditor.vue
  5. 15
      src/services/DavClient.js
  6. 3
      src/store/fileUploadStore.js
  7. 35
      src/store/fileUploadStore.spec.js
  8. 19
      src/test-setup.js

250
package-lock.json

@ -54,7 +54,7 @@
"vue-shortkey": "^3.1.7",
"vue2-leaflet": "^2.7.1",
"vuex": "^3.6.2",
"webdav": "^4.11.2",
"webdav": "^5.2.2",
"webrtc-adapter": "^8.2.3",
"webrtcsupport": "^2.2.0",
"wildemitter": "^1.2.1",
@ -1847,6 +1847,14 @@
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw=="
},
"node_modules/@buttercup/fetch": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@buttercup/fetch/-/fetch-0.1.1.tgz",
"integrity": "sha512-RwBiPEmPaZv3oLOPY0fcmAGYdd3A4FDoYDc7JN+qxGTXumrYAYEC1RpyCM2pHSr6RYpuaAeg4A1fJy+PiigPIA==",
"optionalDependencies": {
"node-fetch": "^3.3.0"
}
},
"node_modules/@discoveryjs/json-ext": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz",
@ -6850,6 +6858,15 @@
"node": ">=4"
}
},
"node_modules/data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"optional": true,
"engines": {
"node": ">= 12"
}
},
"node_modules/data-urls": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz",
@ -8748,11 +8765,24 @@
"integrity": "sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA=="
},
"node_modules/fast-xml-parser": {
"version": "3.19.0",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.19.0.tgz",
"integrity": "sha512-4pXwmBplsCPv8FOY1WRakF970TjNGnGnfbOnLqjlYvMiF1SR3yOHyxMR/YCXpPTOspNF5gwudqktIP4VsWkvBg==",
"version": "4.2.5",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.2.5.tgz",
"integrity": "sha512-B9/wizE4WngqQftFPmdaMYlXoJlJOYxGQOanC77fq9k8+Z0v5dDSVh+3glErdIROP//s/jgb7ZuxKfB8nVyo0g==",
"funding": [
{
"type": "paypal",
"url": "https://paypal.me/naturalintelligence"
},
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"dependencies": {
"strnum": "^1.0.5"
},
"bin": {
"xml2js": "cli.js"
"fxparser": "src/cli/cli.js"
}
},
"node_modules/fastest-levenshtein": {
@ -8796,6 +8826,29 @@
"bser": "2.1.1"
}
},
"node_modules/fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "paypal",
"url": "https://paypal.me/jimmywarting"
}
],
"optional": true,
"dependencies": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
},
"engines": {
"node": "^12.20 || >= 14.13"
}
},
"node_modules/file-entry-cache": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
@ -9012,6 +9065,18 @@
"node": ">= 6"
}
},
"node_modules/formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"optional": true,
"dependencies": {
"fetch-blob": "^3.1.2"
},
"engines": {
"node": ">=12.20.0"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
@ -9546,9 +9611,9 @@
"peer": true
},
"node_modules/hot-patcher": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/hot-patcher/-/hot-patcher-1.0.0.tgz",
"integrity": "sha512-3H8VH0PreeNsKMZw16nTHbUp4YoHCnPlawpsPXGJUR4qENDynl79b6Xk9CIFvLcH1qungBsCuzKcWyzoPPalTw=="
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/hot-patcher/-/hot-patcher-2.0.0.tgz",
"integrity": "sha512-rwJ0ZqSFgm+5oD0KiGBVinyPWRJESRSsHlEWDzZjyOe/OfhD9tynHqUyUIGX2fWuV+BihW4nXxeoZRJVHid64w=="
},
"node_modules/hpack.js": {
"version": "2.1.6",
@ -10304,11 +10369,11 @@
}
},
"node_modules/is-svg": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/is-svg/-/is-svg-4.3.2.tgz",
"integrity": "sha512-mM90duy00JGMyjqIVHu9gNTjywdZV+8qNasX8cm/EEYZ53PHDgajvbBwNVvty5dwSAxLUD3p3bdo+7sR/UMrpw==",
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/is-svg/-/is-svg-4.4.0.tgz",
"integrity": "sha512-v+AgVwiK5DsGtT9ng+m4mClp6zDAmwrW8nZi6Gg15qzvBnRWWdfWA1TGaXyCDnWq5g5asofIgMVl3PjKxvk1ug==",
"dependencies": {
"fast-xml-parser": "^3.19.0"
"fast-xml-parser": "^4.1.3"
},
"engines": {
"node": ">=6"
@ -13595,6 +13660,43 @@
"vue": "^2.7.14"
}
},
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
],
"optional": true,
"engines": {
"node": ">=10.5.0"
}
},
"node_modules/node-fetch": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz",
"integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==",
"optional": true,
"dependencies": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/node-fetch"
}
},
"node_modules/node-forge": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz",
@ -15984,6 +16086,11 @@
"resolved": "https://registry.npmjs.org/striptags/-/striptags-3.2.0.tgz",
"integrity": "sha512-g45ZOGzHDMe2bdYMdIvdAfCQkCTDMGBazSw1ypMowwGIee7ZQ5dU0rBJ8Jqgl+jAKIv4dbeE1jscZq9wid1Tkw=="
},
"node_modules/strnum": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz",
"integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA=="
},
"node_modules/style-loader": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/style-loader/-/style-loader-3.3.2.tgz",
@ -17885,17 +17992,26 @@
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/web-streams-polyfill": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
"optional": true,
"engines": {
"node": ">= 8"
}
},
"node_modules/webdav": {
"version": "4.11.2",
"resolved": "https://registry.npmjs.org/webdav/-/webdav-4.11.2.tgz",
"integrity": "sha512-Ht9TPD5EB7gYW0YmhRcE5NW0/dn/HQfyLSPQY1Rw1coQ5MQTUooAQ9Bpqt4EU7QLw0b95tX4cU59R+SIojs9KQ==",
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/webdav/-/webdav-5.2.2.tgz",
"integrity": "sha512-CTnhTTKug7pKbMqcvrnGNr4rV9qhWXV1sLk1PpN4BOskqDT+cEfFx4Y4VlcFXUX6lSUFsQBm9Ka8+6dIe0doQQ==",
"dependencies": {
"axios": "^0.27.2",
"@buttercup/fetch": "^0.1.1",
"base-64": "^1.0.0",
"byte-length": "^1.0.2",
"fast-xml-parser": "^3.19.0",
"fast-xml-parser": "^4.2.4",
"he": "^1.2.0",
"hot-patcher": "^1.0.0",
"hot-patcher": "^2.0.0",
"layerr": "^0.1.2",
"md5": "^2.3.0",
"minimatch": "^5.1.0",
@ -17905,7 +18021,7 @@
"url-parse": "^1.5.10"
},
"engines": {
"node": ">=10"
"node": ">=14"
}
},
"node_modules/webdav/node_modules/brace-expansion": {
@ -20045,6 +20161,14 @@
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz",
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw=="
},
"@buttercup/fetch": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@buttercup/fetch/-/fetch-0.1.1.tgz",
"integrity": "sha512-RwBiPEmPaZv3oLOPY0fcmAGYdd3A4FDoYDc7JN+qxGTXumrYAYEC1RpyCM2pHSr6RYpuaAeg4A1fJy+PiigPIA==",
"requires": {
"node-fetch": "^3.3.0"
}
},
"@discoveryjs/json-ext": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz",
@ -23915,6 +24039,12 @@
"resolved": "https://registry.npmjs.org/dashify/-/dashify-2.0.0.tgz",
"integrity": "sha512-hpA5C/YrPjucXypHPPc0oJ1l9Hf6wWbiOL7Ik42cxnsUOhWiCB/fylKbKqqJalW9FgkNQCw16YO8uW9Hs0Iy1A=="
},
"data-uri-to-buffer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
"optional": true
},
"data-urls": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz",
@ -25386,9 +25516,12 @@
}
},
"fast-xml-parser": {
"version": "3.19.0",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.19.0.tgz",
"integrity": "sha512-4pXwmBplsCPv8FOY1WRakF970TjNGnGnfbOnLqjlYvMiF1SR3yOHyxMR/YCXpPTOspNF5gwudqktIP4VsWkvBg=="
"version": "4.2.5",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.2.5.tgz",
"integrity": "sha512-B9/wizE4WngqQftFPmdaMYlXoJlJOYxGQOanC77fq9k8+Z0v5dDSVh+3glErdIROP//s/jgb7ZuxKfB8nVyo0g==",
"requires": {
"strnum": "^1.0.5"
}
},
"fastest-levenshtein": {
"version": "1.0.16",
@ -25425,6 +25558,16 @@
"bser": "2.1.1"
}
},
"fetch-blob": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
"optional": true,
"requires": {
"node-domexception": "^1.0.0",
"web-streams-polyfill": "^3.0.3"
}
},
"file-entry-cache": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
@ -25597,6 +25740,15 @@
"mime-types": "^2.1.12"
}
},
"formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
"optional": true,
"requires": {
"fetch-blob": "^3.1.2"
}
},
"forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
@ -25982,9 +26134,9 @@
"peer": true
},
"hot-patcher": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/hot-patcher/-/hot-patcher-1.0.0.tgz",
"integrity": "sha512-3H8VH0PreeNsKMZw16nTHbUp4YoHCnPlawpsPXGJUR4qENDynl79b6Xk9CIFvLcH1qungBsCuzKcWyzoPPalTw=="
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/hot-patcher/-/hot-patcher-2.0.0.tgz",
"integrity": "sha512-rwJ0ZqSFgm+5oD0KiGBVinyPWRJESRSsHlEWDzZjyOe/OfhD9tynHqUyUIGX2fWuV+BihW4nXxeoZRJVHid64w=="
},
"hpack.js": {
"version": "2.1.6",
@ -26523,11 +26675,11 @@
}
},
"is-svg": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/is-svg/-/is-svg-4.3.2.tgz",
"integrity": "sha512-mM90duy00JGMyjqIVHu9gNTjywdZV+8qNasX8cm/EEYZ53PHDgajvbBwNVvty5dwSAxLUD3p3bdo+7sR/UMrpw==",
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/is-svg/-/is-svg-4.4.0.tgz",
"integrity": "sha512-v+AgVwiK5DsGtT9ng+m4mClp6zDAmwrW8nZi6Gg15qzvBnRWWdfWA1TGaXyCDnWq5g5asofIgMVl3PjKxvk1ug==",
"requires": {
"fast-xml-parser": "^3.19.0"
"fast-xml-parser": "^4.1.3"
}
},
"is-symbol": {
@ -28885,6 +29037,23 @@
"lodash-es": "^4.17.21"
}
},
"node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"optional": true
},
"node-fetch": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz",
"integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==",
"optional": true,
"requires": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
}
},
"node-forge": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz",
@ -30736,6 +30905,11 @@
"resolved": "https://registry.npmjs.org/striptags/-/striptags-3.2.0.tgz",
"integrity": "sha512-g45ZOGzHDMe2bdYMdIvdAfCQkCTDMGBazSw1ypMowwGIee7ZQ5dU0rBJ8Jqgl+jAKIv4dbeE1jscZq9wid1Tkw=="
},
"strnum": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz",
"integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA=="
},
"style-loader": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/style-loader/-/style-loader-3.3.2.tgz",
@ -32132,17 +32306,23 @@
"resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz",
"integrity": "sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ=="
},
"web-streams-polyfill": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
"optional": true
},
"webdav": {
"version": "4.11.2",
"resolved": "https://registry.npmjs.org/webdav/-/webdav-4.11.2.tgz",
"integrity": "sha512-Ht9TPD5EB7gYW0YmhRcE5NW0/dn/HQfyLSPQY1Rw1coQ5MQTUooAQ9Bpqt4EU7QLw0b95tX4cU59R+SIojs9KQ==",
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/webdav/-/webdav-5.2.2.tgz",
"integrity": "sha512-CTnhTTKug7pKbMqcvrnGNr4rV9qhWXV1sLk1PpN4BOskqDT+cEfFx4Y4VlcFXUX6lSUFsQBm9Ka8+6dIe0doQQ==",
"requires": {
"axios": "^0.27.2",
"@buttercup/fetch": "^0.1.1",
"base-64": "^1.0.0",
"byte-length": "^1.0.2",
"fast-xml-parser": "^3.19.0",
"fast-xml-parser": "^4.2.4",
"he": "^1.2.0",
"hot-patcher": "^1.0.0",
"hot-patcher": "^2.0.0",
"layerr": "^0.1.2",
"md5": "^2.3.0",
"minimatch": "^5.1.0",

2
package.json

@ -63,7 +63,7 @@
"vue-shortkey": "^3.1.7",
"vue2-leaflet": "^2.7.1",
"vuex": "^3.6.2",
"webdav": "^4.11.2",
"webdav": "^5.2.2",
"webrtc-adapter": "^8.2.3",
"webrtcsupport": "^2.2.0",
"wildemitter": "^1.2.1",

8
src/__mocks__/webdav.js

@ -0,0 +1,8 @@
// eslint-disable-next-line n/no-unpublished-import
import { createClient } from 'webdav'
jest.mock('webdav', () => ({
createClient: jest.fn(),
}))
export { createClient }

3
src/components/MediaSettings/VideoBackgroundEditor.vue

@ -225,7 +225,8 @@ export default {
try {
// Upload the file
await client.putFileContents(userRoot + uniquePath, file, {
const fileBuffer = await new Blob([file]).arrayBuffer()
await client.putFileContents(userRoot + uniquePath, fileBuffer, {
contentLength: file.size,
})

15
src/services/DavClient.js

@ -20,19 +20,14 @@
*
*/
import parseUrl from 'url-parse'
import { createClient, getPatcher } from 'webdav'
import { createClient } from 'webdav'
import axios from '@nextcloud/axios'
import { getRequestToken } from '@nextcloud/auth'
import { generateRemoteUrl } from '@nextcloud/router'
// force our axios
const patcher = getPatcher()
patcher.patch('request', axios)
// init webdav client on default dav endpoint
const remote = generateRemoteUrl('dav')
const client = createClient(remote)
const client = createClient(generateRemoteUrl('dav'),
{ headers: { requesttoken: getRequestToken() || '' } },
)
export const remotePath = parseUrl(remote).pathname
export default client

3
src/store/fileUploadStore.js

@ -316,7 +316,8 @@ const actions = {
const uniquePath = await findUniquePath(client, userRoot, path)
try {
// Upload the file
await client.putFileContents(userRoot + uniquePath, currentFile, {
const currentFileBuffer = await new Blob([currentFile]).arrayBuffer()
await client.putFileContents(userRoot + uniquePath, currentFileBuffer, {
onUploadProgress: progress => {
const uploadedSize = progress.loaded
commit('setUploadedSize', { state, uploadId, index, uploadedSize })

35
src/store/fileUploadStore.spec.js

@ -11,7 +11,9 @@ import { setAttachmentFolder } from '../services/settingsService.js'
import { findUniquePath, getFileExtension } from '../utils/fileUpload.js'
import fileUploadStore from './fileUploadStore.js'
jest.mock('../services/DavClient')
jest.mock('../services/DavClient', () => ({
putFileContents: jest.fn(),
}))
jest.mock('../utils/fileUpload', () => ({
findUniquePath: jest.fn(),
getFileExtension: jest.fn(),
@ -132,19 +134,22 @@ describe('fileUploadStore', () => {
})
test('performs upload by uploading then sharing', async () => {
const files = [
{
name: 'pngimage.png',
type: 'image/png',
size: 123,
lastModified: Date.UTC(2021, 3, 27, 15, 30, 0),
},
{
name: 'textfile.txt',
type: 'text/plain',
size: 111,
lastModified: Date.UTC(2021, 3, 25, 15, 30, 0),
},
const file1 = {
name: 'pngimage.png',
type: 'image/png',
size: 123,
lastModified: Date.UTC(2021, 3, 27, 15, 30, 0),
}
const file2 = {
name: 'textfile.txt',
type: 'text/plain',
size: 111,
lastModified: Date.UTC(2021, 3, 25, 15, 30, 0),
}
const files = [file1, file2]
const fileBuffers = [
await new Blob([file1]).arrayBuffer(),
await new Blob([file2]).arrayBuffer(),
]
await store.dispatch('initialiseUpload', {
@ -169,7 +174,7 @@ describe('fileUploadStore', () => {
for (let i = 0; i < files.length; i++) {
expect(findUniquePath).toHaveBeenCalledWith(client, '/files/current-user', '/Talk/' + files[i].name)
expect(client.putFileContents.mock.calls[i][0]).toBe('/files/current-user/Talk/' + files[i].name + 'uniq')
expect(client.putFileContents.mock.calls[i][1]).toBe(files[i])
expect(client.putFileContents.mock.calls[i][1]).toStrictEqual(fileBuffers[i])
expect(shareFile.mock.calls[i][0]).toBe('//Talk/' + files[i].name + 'uniq')
expect(shareFile.mock.calls[i][1]).toBe('XXTOKENXX')

19
src/test-setup.js

@ -79,6 +79,25 @@ global.OCP = {
}
global.IS_DESKTOP = false
/**
* Polyfill for Blob.prototype.arrayBuffer
* Required as jsdom breaks Nodejs's native Blob
*
* @see https://github.com/jsdom/jsdom/issues/2555
*/
function myArrayBuffer() {
// this: File or Blob
return new Promise((resolve) => {
const fr = new FileReader()
fr.onload = () => {
resolve(fr.result)
}
fr.readAsArrayBuffer(this)
})
}
global.Blob.prototype.arrayBuffer = Blob.prototype.arrayBuffer || myArrayBuffer
const originalConsoleError = console.error
console.error = function(error) {
if (error?.message?.includes('Could not parse CSS stylesheet')) {

Loading…
Cancel
Save