@axinom/mosaic-ui 0.34.0-rc.8 → 0.34.0-rc.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-ui",
3
- "version": "0.34.0-rc.8",
3
+ "version": "0.34.0-rc.9",
4
4
  "description": "UI components for building Axinom Mosaic applications",
5
5
  "author": "Axinom",
6
6
  "license": "PROPRIETARY",
@@ -32,7 +32,7 @@
32
32
  "build-storybook": "storybook build"
33
33
  },
34
34
  "dependencies": {
35
- "@axinom/mosaic-core": "^0.4.7-rc.8",
35
+ "@axinom/mosaic-core": "^0.4.7-rc.9",
36
36
  "@faker-js/faker": "^7.4.0",
37
37
  "@popperjs/core": "^2.9.2",
38
38
  "clsx": "^1.1.0",
@@ -102,5 +102,5 @@
102
102
  "publishConfig": {
103
103
  "access": "public"
104
104
  },
105
- "gitHead": "5edc02cc390133cd76b231e57bde5394db8a5aa0"
105
+ "gitHead": "94ff309a76a395dfa2c13eed746c6603c15df0bd"
106
106
  }
@@ -203,6 +203,41 @@ describe('FileUploadControl', () => {
203
203
  );
204
204
  });
205
205
 
206
+ it('allows files with the same name to be uploaded multiple times', () => {
207
+ const spy = jest.fn();
208
+
209
+ const wrapper = mount(
210
+ <FileUploadControl name={'test-name'} onFileSelected={spy} />,
211
+ );
212
+
213
+ const fileInput = wrapper.find('input[type="file"]');
214
+
215
+ // Simulate first file upload
216
+ fileInput.simulate('change', { target: { files: mockFileList } });
217
+
218
+ expect(spy).toHaveBeenCalledTimes(1);
219
+ expect(spy).toHaveBeenCalledWith({
220
+ file: mockFile,
221
+ uploadCompleted: expect.any(Function),
222
+ uploadProgress: expect.any(Function),
223
+ uploadStarted: expect.any(Function),
224
+ });
225
+
226
+ // Reset spy
227
+ spy.mockReset();
228
+
229
+ // Simulate second file upload with the same file
230
+ fileInput.simulate('change', { target: { files: mockFileList } });
231
+
232
+ expect(spy).toHaveBeenCalledTimes(1);
233
+ expect(spy).toHaveBeenCalledWith({
234
+ file: mockFile,
235
+ uploadCompleted: expect.any(Function),
236
+ uploadProgress: expect.any(Function),
237
+ uploadStarted: expect.any(Function),
238
+ });
239
+ });
240
+
206
241
  describe('MIME Types', () => {
207
242
  const mockTypes = 'image/jpeg,image/png';
208
243
  const mockFile = new File([new ArrayBuffer(1)], 'image.png', {
@@ -169,6 +169,8 @@ export const FileUploadControl: React.FC<FileUploadProps> = ({
169
169
  onChange={(event) => {
170
170
  const file = event.target.files?.item(0);
171
171
  file && fileSelected(file);
172
+ // Reset the value of the input field to ensure onChange fires even with same file
173
+ event.target.value = '';
172
174
  }}
173
175
  />
174
176
  </>