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

Edit vocabulary lessons in dialog #38839

Merged
merged 7 commits into from Feb 4, 2021

Conversation

bethanyaconnor
Copy link
Contributor

@bethanyaconnor bethanyaconnor commented Feb 1, 2021

Follow up from a comment in #38760 -- this took less than a day :). This PR adds a selector to edit which lessons a vocabulary is in from the All Vocabulary page. It doesn't affect the lesson edit page.

Quick gif -- I'm not sure why the save was slow but I believe that was my computer being sluggish
Screen Recording 2021-02-02 at 9 41 40 AM

Future work

  • Add this to the add vocabulary dialog on the lesson edit page. I didn't do that here but it shouldn't be hard to do in the future
  • Add this same functionality to the add resource dialog

Testing story

Manual testing and a couple unit tests

Reviewer Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@bethanyaconnor bethanyaconnor marked this pull request as ready for review February 2, 2021 18:13
@davidsbailey
Copy link
Member

thanks for the gif! I see what looks like an autocomplete search box, but it only shows you scrolling down without typing. am I correct in understanding that typing into this box allows you to filter what appears in the dropdown? (apologies, I have not pulled this down to try it out yet!)

@bethanyaconnor
Copy link
Contributor Author

@davidsbailey yes you can type -- though the search is a bit different than the one on the lesson edit page. I'm not sure how it works exactly -- it comes for free with the component.

This gif is a lot longer and shows a lesson actually updating, as well as typing into the select box.
Screen Recording 2021-02-01 at 3 16 24 PM

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

Thanks for the updated gif! One initial comment which may spark debate.

Comment on lines 111 to 112
expect(wrapper.contains('Add Vocabulary')).to.be.true;
expect(wrapper.find('input').length).to.equal(2);
Copy link
Member

Choose a reason for hiding this comment

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

I think @Hamms has convinced me that these kinds of "brittle expectations" are not very helpful for the following reasons:

  • they can break when someone adds a new input
  • due to the shallow render, they can break when someone wraps an existing component (button, input, etc) within another subcomponent
  • they do not test business logic
  • they are mostly just testing that the React library is working

Generally, they make tests brittle without adding much value. For now, can I recommend removing lines 111 and 112?

Personally, I think there is some value in still having the "renders default props" test case, because in the event of a later test failure, whether this test case fails can immediately help narrow down the root cause. However, this is only valuable if other test cases go on to test actual business logic (which I am not commenting on one way or another in this comment). So let's leave that in for now, but we may keep it on the table whether to remove "renders default props" test cases entirely in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Add Vocabulary" does actually test business logic because the header is different in different cases. I see the point in removing line 112 so I'll go ahead and do this

Copy link
Member

Choose a reason for hiding this comment

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

Ah, great, thank you for pointing that out! 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

"Add Vocabulary" does actually test business logic because the header is different in different cases

It does! But I'd argue that means it should belong in a test that's specifically testing that the header is different in different cases, not be disguised as a test that claims to just be testing our ability to render

@davidsbailey
Copy link
Member

I'm not sure if this is new, but after pulling down your branch I am running into this issue where the vocab update succeeds, but then the lesson update fails:

edit-vocab.mp4

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

LGTM! The bug in the video seems to also repro in staging, so it seems like it shouldn't block this PR.

@@ -31,6 +31,20 @@ class VocabulariesControllerTest < ActionController::TestCase
assert(@response.body.include?('updated definition'))
end

test "can update lessons from params" do
Copy link
Member

Choose a reason for hiding this comment

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

nit: "can update vocab from params"?

assert_equal 'updated definition', vocabulary.definition
assert(@response.body.include?('updated definition'))
assert_equal [lesson], vocabulary.lessons
end
Copy link
Member

Choose a reason for hiding this comment

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

This test looks good! I think it would be a good idea to add a test for saving the lesson after saving the vocab (issue shown in video in other comment). I'm not sure how easy it would be to add a rails unit or integration test, but it should be possible to cover it with a UI test, based on the UI tests we already have for saving the lesson edit page. Up to you whether that belongs in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to look into that bug separately and add tests there.

Copy link
Contributor

@dmcavoy dmcavoy left a comment

Choose a reason for hiding this comment

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

Oh this is exciting!

@bethanyaconnor bethanyaconnor merged commit 27bdb86 into staging Feb 4, 2021
@bethanyaconnor bethanyaconnor deleted the edit-vocabulary-lessons-in-dialog branch February 4, 2021 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants