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

Add activeTool validation on frame change to MultiFrameViewerContainer #2930

Merged
merged 4 commits into from
Mar 9, 2022

Conversation

mcbouslog
Copy link
Contributor

@mcbouslog mcbouslog commented Mar 7, 2022

Package:

  • lib-classifier

Closes #2810.

Describe your changes:

  • adds active tool validation on frame change to MultiFrameViewerContainer

Helpful explanations that will make your reviewer happy:

Review Checklist

General

  • Are the tests passing locally and on Travis?
  • Is the documentation up to date?

Components

Apps

  • Does it work in all major browsers: Firefox, Chrome, Edge, Safari?
  • Does it work on mobile?
  • Can you yarn panic && yarn bootstrap or docker-compose up --build and app works as expected?

Publishing

  • Is the changelog updated?
  • Are the dependencies updated for apps and libraries that are using the newly published library?

Post-merging

@mcbouslog mcbouslog added bug Something isn't working degraded-ux UX is degraded labels Mar 7, 2022
@mcbouslog mcbouslog requested a review from ErikOstlund March 7, 2022 22:05
Copy link
Contributor

@eatyourgreens eatyourgreens left a 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.

Comment on lines 161 to 165
it('should validate active tool marks on frame change', function () {
wrapper.setProps({ activeTool })
wrapper.instance().onFrameChange(2)
expect(validateSpy).to.have.been.calledOnce()
})
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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])

Copy link
Contributor

Choose a reason for hiding this comment

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

New test looks good. 👍🏻

@github-actions github-actions bot added the approved This PR is approved for merging label Mar 8, 2022
@mcbouslog mcbouslog merged commit 617045a into master Mar 9, 2022
@mcbouslog mcbouslog deleted the fix-2810 branch March 9, 2022 14:30
@eatyourgreens eatyourgreens mentioned this pull request Mar 9, 2022
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved This PR is approved for merging bug Something isn't working degraded-ux UX is degraded
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Corresponding with Quakers: Can't move on to next task
2 participants