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

Refactoring image selector components #149

Merged
merged 18 commits into from
May 18, 2020
Merged

Conversation

evanzhong
Copy link
Member

Profile Picture Selector
image

Edit Sketch Selector
image

Create Sketch Selector
image

Props to be passed into ImageSelector components:
isOpen: boolean for whether the modal is open
closeModal: callback for when the modal is closed
icons: array of elements for icons to display
maxWidth: optional limit on the width of the modal
thumbnailPreview: optional image element to display on the header showing what icon the user has currently selected
error: optional error state
children: optional footer buttons

Copy link
Collaborator

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

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

Hey @evazhog, the PR fails one of our tests (specifically it's one on the profile panel image selector, which makes sense) - do you mind fixing the test to use the new structure of the image selector?

Other than that, this looks generically good; I'll give it a more thorough look over in a moment.

Copy link
Collaborator

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

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

Overall the functionality looks good, but left a bit of review in terms of possible app structure ideas.

src/components/common/ProfilePanel.js Outdated Show resolved Hide resolved
src/components/Sketches/components/ImageSelector.js Outdated Show resolved Hide resolved
src/components/common/ProfilePanel.js Outdated Show resolved Hide resolved
@mattxwang mattxwang added the refactor Refactoring & cleanup label Jan 27, 2020
Copy link
Collaborator

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

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

Hey Evan, thanks for taking the time to sit down with me and work through on this ticket! We figured out (some) of the issues with the broken tests, moved around some code, and added some constants.

Just to recap, a few things that need to be done for the rest of the ticket:

  • write an ImageSelector.scss file that contains all the styling for ImageSelector.js - ideally, we want no leakage from other styles (in case they change in the future)
  • write an ImageSelector.test.js file that tests the component by itself
    • write a smoke test: check that the component renders shallow-ly
    • write some props tests: check that the component handles each of its props properly. edge-cases aren't too important here, but make sure that you cover the generic inputs they'll receive (especially because usually we pass in variables to these components, instead of literals)
    • bonus: write some mouse-event simulator tests: selecting each element and checking the state change, checking if clicking the button triggers the function (you can look into mock jest functions for this), etc. you can look at other test files and see how they do this

Copy link
Collaborator

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

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

Just for sake of clarity: all of the necessary refactoring is done, great job @evazhog! Waiting on possible extra tests for the custom component, but at the current state this LGTM.

@krashanoff
Copy link
Contributor

Just checking in, @evazhog, are you planning on adding any tests to your refactor? If not, I am happy to merge this and write tests after the fact. Just wanted to follow up as this PR has been in limbo for a while now.

@evanzhong
Copy link
Member Author

Plan on taking another pass at it tomorrow, can't get to it tonight unfortunately.

@krashanoff
Copy link
Contributor

No worries Evan! Just wanted to check in. Take it easy!

@krashanoff
Copy link
Contributor

On account of core functionality being OK, I'll be going ahead and merging this. Seeing as this component favors integration tests, we can always add them down the line.

Thanks for all your work Evan!

@krashanoff krashanoff merged commit cf86900 into uclaacm:master May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactoring & cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants