Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FileUploaderDropContainer): fix NPE selecting file #4936

Merged

Conversation

asudoh
Copy link
Contributor

@asudoh asudoh commented Dec 23, 2019

Fixes #4899.

Changelog

Changed

  • Fix for NPE that happened by selecting a file in <FileUploaderDropContainer>.

Testing / Reviewing

Testing should make sure file uploader is not broken.

@asudoh asudoh requested a review from emyarod December 23, 2019 22:57
@asudoh asudoh requested a review from a team as a code owner December 23, 2019 22:57
@ghost ghost requested a review from dakahn December 23, 2019 22:57
@asudoh asudoh force-pushed the fileuploader-select-file-link branch from 5ead3ae to b66846a Compare December 23, 2019 23:02
@netlify
Copy link

netlify bot commented Dec 23, 2019

Deploy preview for the-carbon-components ready!

Built with commit 89c7a24

https://deploy-preview-4936--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Dec 23, 2019

Deploy preview for carbon-elements ready!

Built with commit 89c7a24

https://deploy-preview-4936--carbon-elements.netlify.com

@netlify
Copy link

netlify bot commented Dec 23, 2019

Deploy preview for carbon-components-react failed.

Built with commit 89c7a24

https://app.netlify.com/sites/carbon-components-react/deploys/5e0146448ea6e30008190368

@netlify
Copy link

netlify bot commented Dec 23, 2019

Deploy preview for the-carbon-components ready!

Built with commit 87c3cf8

https://deploy-preview-4936--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Dec 23, 2019

Deploy preview for carbon-elements failed.

Built with commit 87c3cf8

https://app.netlify.com/sites/carbon-elements/deploys/5e1d03182318c30008b50214

@netlify
Copy link

netlify bot commented Dec 23, 2019

Deploy preview for carbon-components-react failed.

Built with commit 87c3cf8

https://app.netlify.com/sites/carbon-components-react/deploys/5e1d031898d15f00081f45f8

Copy link
Contributor

@joshblack joshblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some style comments, otherwise seems great!

const evt = { target: { files: mockFiles } };
input.simulate('change', evt);
expect(onAddFiles).toHaveBeenCalledTimes(1);
expect(onAddFiles.mock.calls[0][0].target.files).toEqual([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe expect(onAddFiles).toHaveBeenCalledWith might be relevant here? Something like:

expect(onAddFiles).toHaveBeenCalledWith(expect.objectContaining({
  target: {
    files: [fileFoo, fileBar],
  },
}));

@joshblack
Copy link
Contributor

Should we remove the FileUploaderDropContainer story potentially in preference of the container example? Can't seem to get that one to work (and I don't think it has been working??) Just curious 🤔

@asudoh
Copy link
Contributor Author

asudoh commented Jan 7, 2020

The story topic sounds orthogonal to this PR. <FileUploaderDropContainer> itself does not contain the UI of file list. The story for that component demonstrates that it can be integrated with other component, by showing onChange being fired upon adding files. If you go to Actions tab at the bottom or at the right, you'll see onChange when you add files.

@emyarod
Copy link
Member

emyarod commented Jan 9, 2020

just for context, during previous reviews it was decided that the story would be static and the full application example would be available in codesandbox

Copy link
Member

@emyarod emyarod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@asudoh asudoh dismissed joshblack’s stale review January 9, 2020 23:17

Updating the review status as all comments have been addressed.

@@ -255,7 +255,13 @@ describe('FileUploader', () => {
});

describe('FileUploaderDropContainer', () => {
const dropContainer = <FileUploaderDropContainer className="extra-class" />;
const onAddFiles = jest.fn();
const dropContainer = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move blocks where we create components into beforeEach or a similar generator function to prevent test flakiness

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshblack Agreed on beforAll()/beforeEach() making tests more stable, but it's orthogonal to this PR. Do you want to enter an issue for that?

@tw15egan
Copy link
Member

tw15egan commented Jan 13, 2020

@joshblack is the test change request enough to warrant a separate issue? Or do you want it resolved in this PR before merging

@joshblack
Copy link
Contributor

Let's address it before merging while we're in this part of the codebase and the change will be pretty quick 👍

@asudoh
Copy link
Contributor Author

asudoh commented Jan 13, 2020

@joshblack is right that there is a change to test setup code, but the discussion of change in style of test setup code is orthogonal. I want the works not distracted by such kind of change requests.

@joshblack
Copy link
Contributor

joshblack commented Jan 13, 2020

If it helps, was only thinking the change would involve:

describe('FileUploaderDropContainer', () => {
  let onAddFiles;
  let dropContainer;
  let mountWrapper;

  beforeEach(() => {
    onAddFiles = jest.fn();
    dropContainer = (
      <FileUploaderDropContainer
        className="extra-class"
        onAddFiles={onAddFiles}
      />
    );
    mountWrapper = mount(dropContainer);
  });

We should definitely get this update in there while we're working on this part of the codebase given how minimal the change is.

@asudoh
Copy link
Contributor Author

asudoh commented Jan 13, 2020

OK feel free to push a patch like that. Even though the change is minimal, I see it's distracting.

@asudoh asudoh merged commit 5aa4c47 into carbon-design-system:master Jan 14, 2020
@asudoh asudoh deleted the fileuploader-select-file-link branch January 14, 2020 00:08
@MaheshIBM
Copy link

Can anyone help me with which release this might have gone into.

@MaheshIBM
Copy link

@joshblack
Copy link
Contributor

Hi @MaheshIBM! 👋 This was included in our v10.9.0 release, can see the commit over in: https://github.com/carbon-design-system/carbon/releases/tag/v10.9.0

You can see our release schedule over at: https://github.com/carbon-design-system/carbon/wiki/Release-radar

Hope this helps!

@MaheshIBM
Copy link

@joshblack I see the commit was done after the v10.9.0 release which happened on Dec 19

image

The code in the tag does not seem to have the fix.

As per my understanding, I think this fix might go on 27th Jan 2020 as per screen shot below.

image

If I compare the tag with master, I can see the commit showing up in the compare which means its not in the tag.

v10.9.1...master
or
v10.9.2...master

@joshblack
Copy link
Contributor

@MaheshIBM good catch! Sorry about my mistake up above, not sure where I was finding this commit now. But yes, I believe it'll be in our next patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DragAndDropFileUploader]: "click to upload" not working
6 participants