From 222e511a98b1e69a885a8c9bf4bea888f6bb14d7 Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Thu, 2 Mar 2023 21:16:42 +0100 Subject: [PATCH] @uppy/core: fix uppy.resetProgress() (#4337) * Fix uppy.resetProgress() * Update tests --- packages/@uppy/core/src/Uppy.js | 13 ++++++++++--- packages/@uppy/core/src/Uppy.test.js | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/@uppy/core/src/Uppy.js b/packages/@uppy/core/src/Uppy.js index b70d02fc49..d3efed3aa5 100644 --- a/packages/@uppy/core/src/Uppy.js +++ b/packages/@uppy/core/src/Uppy.js @@ -233,15 +233,22 @@ class Uppy { } const files = { ...this.getState().files } const updatedFiles = {} + Object.keys(files).forEach(fileID => { - const updatedFile = { ...files[fileID] } - updatedFile.progress = { ...updatedFile.progress, ...defaultProgress } - updatedFiles[fileID] = updatedFile + updatedFiles[fileID] = { + ...files[fileID], + progress: { + ...files[fileID].progress, ...defaultProgress, + }, + } }) this.setState({ files: updatedFiles, totalProgress: 0, + allowNewUpload: true, + error: null, + recoveredState: null, }) this.emit('reset-progress') diff --git a/packages/@uppy/core/src/Uppy.test.js b/packages/@uppy/core/src/Uppy.test.js index 59de92cf0a..fd8faff2b4 100644 --- a/packages/@uppy/core/src/Uppy.test.js +++ b/packages/@uppy/core/src/Uppy.test.js @@ -1619,6 +1619,10 @@ describe('src/Core', () => { uploadStarted: null, }) expect(core.getState().totalProgress).toEqual(0) + expect(core.getState().allowNewUpload).toEqual(true) + expect(core.getState().error).toEqual(null) + expect(core.getState().recoveredState).toEqual(null) + expect(resetProgressEvent.mock.calls.length).toEqual(1) }) })