Consolidated Javalab Editor refactors#47486
Conversation
…factor/file-errors-redux Move file error message into redux
…factor/split-dialog-header Move Javalab Editor header and dialogs into their own components
…factor/commitdialog Move compile status state management into CommitDialog
Move dialog state into redux
bencodeorg
left a comment
There was a problem hiding this comment.
Thank you for the PR description, very helpful :)
| .undefined; | ||
| expect(store.getState().javalab.sources[oldFilename]).to.be.undefined; | ||
| expect(javalabEditor.state.openDialog).to.be.null; | ||
| expect(store.getState().javalab.editorOpenDialogName).to.be.null; |
There was a problem hiding this comment.
Opinion I came up with when looking at these tests earlier this week: we should check the prop of the component that references this value (rather than Redux itself). Thoughts?
There was a problem hiding this comment.
Yeah, I definitely agree - I was trying to do that initially but the issue I was running into is that we don't actually read the state value (editorOpenDialogName) in the component. We only call the associated action (openEditorDialog/closeEditorDialog). I was trying to instead just assert that we called those functions, but I couldn't figure out how to do that...passing the functions as custom props didn't seem to work because we use redux inside the test so I think those functions get overwritten. Any ideas?
One option could be to remove redux entirely for this file (or at least for the tests where we're running into this issue) and just assert that it calls the right action handlers. But we use redux for example to check that certain sources were updated so we'd have to change all that too.
Edit: reading a bit more about Redux in tests and I think in the ideal case it might be best to have two separate tests; one that's more a true unit test that only tests the functions of JavalabEditor without using Redux, and an integration test that tests the editor features end to end, and uses Redux. Right now this test is doing a bit of both?
There was a problem hiding this comment.
Gotcha, I see now. Re: Redux in tests, seems like most (all?) tests here require Redux. I feel like for a non-reusable component like this that uses Redux in our actual app, relying on Redux in tests is reasonable since that is how we actually use it? For a more reusable component, isolating tests from Redux would make more sense to me?
There was a problem hiding this comment.
Yeah I think that's fair. I think as pull more stuff out of this component into smaller sub-components, those sub-components can have more isolated unit tests (even if they're technically not reusable) and then this test could serve more as a full integration test?
There was a problem hiding this comment.
That makes sense to me, so for something like JavalabEditorDialogManager (if we were to add tests) we'd try to use no Redux? Do you have any rules of thumb about deciding when you might want to have a component fully isolated from Redux vs not?
There was a problem hiding this comment.
Yeah, I think that sounds right? I don't have a rule of thumb necessarily, but I think it makes sense that we test smaller, functional components without redux because that introduces a lot of overhead and leaks into areas (i.e. the Redux store) that the component doesn't need to be concerned about - as opposed a component like this (JavalabEditor) that's more complicated and needs to ensure that the UI is being updated correctly.
| .undefined; | ||
| expect(store.getState().javalab.sources[oldFilename]).to.be.undefined; | ||
| expect(javalabEditor.state.openDialog).to.be.null; | ||
| expect(store.getState().javalab.editorOpenDialogName).to.be.null; |
There was a problem hiding this comment.
Gotcha, I see now. Re: Redux in tests, seems like most (all?) tests here require Redux. I feel like for a non-reusable component like this that uses Redux in our actual app, relying on Redux in tests is reasonable since that is how we actually use it? For a more reusable component, isolating tests from Redux would make more sense to me?
This PR contains the remaining Javalab editor refactor changes that were originally branched off of Ben's refactors which have now been merged (PR here). The below PRs/changes are included in this PR, and have each been reviewed independently. The only additional changes here are some minor merge conflict fixes and test updates.
Included changes:
There have been a lot of PRs, branching, and merging with these changes, so I'm also including a full work log for clarity and future reference :) hopefully this should make tracking down changes easier in the future.
Full Work Log
Move dialog state into redux #47053
Move compile status state management into CommitDialog #47082
Move Javalab Editor header and dialogs into their own components #47116
Move file error message into redux #47137
Links
Testing story
Tested locally.
Deployment strategy
Follow-up work
Privacy
Security
Caching
PR Checklist: