-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add activeTool validation on frame change to MultiFrameViewerContainer #2930
Conversation
...Classifier/components/SubjectViewer/components/MultiFrameViewer/MultiFrameViewerContainer.js
Show resolved
Hide resolved
...Classifier/components/SubjectViewer/components/MultiFrameViewer/MultiFrameViewerContainer.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug fix looks good. I'm seeing stray marks deleted when I change frame on this branch. If it's quick, and easy, to test that invalid marks are deleted, then I'd ask for a test that checks that behavior, in order to avoid regressions. If not, then lets get this deployed ASAP but do take a look at #2808, which refactors this viewer as a functional component with hooks for subject data fetching.
it('should validate active tool marks on frame change', function () { | ||
wrapper.setProps({ activeTool }) | ||
wrapper.instance().onFrameChange(2) | ||
expect(validateSpy).to.have.been.calledOnce() | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocking comment, but wrapper.instance()
should be avoided in tests, since it's null for functional components.
This test doesn't tell us what validation does. If the expectation is that incomplete marks are deleted, then a better test would set up an incomplete translation line and expect it to be deleted on frame change. That would be a behaviour-driven test, whereas this tests how the code is implemented. Implementation can change, in refactors, without changing behaviour, which makes tests like this one brittle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree, I'll refactor this test better asap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No hurry to do this right now, by the way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eatyourgreens I think this test is better now, not ideal (still using wrapper.instance()
), but since #2808 refactors to functional component and relatedly refactors tests with mount then we can include removing wrapper.instance()
in that PR? Sorry that #2808 will need to be refactored because of this PR, but I can help or will prioritize review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I wouldn’t worry about breaking #2808.
I think the equivalent fix, using hooks, would be something like
useEffect(() => {
activeTool?.validate()
}, [frame])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New test looks good. 👍🏻
Package:
Closes #2810.
Describe your changes:
Helpful explanations that will make your reviewer happy:
Review Checklist
General
Components
Apps
yarn panic && yarn bootstrap
ordocker-compose up --build
and app works as expected?Publishing
Post-merging