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

Set up ability to Add Code Documentation Associations to Lessons #39382

Merged
merged 53 commits into from
Mar 26, 2021

Conversation

dmcavoy
Copy link
Contributor

@dmcavoy dmcavoy commented Mar 6, 2021

Hooks up the FindProgrammingExpressionDialog to the ProgrammingExpressionEditor in order to allow editors to add new programming expression associations to a lesson.

Screen.Recording.2021-03-25.at.11.03.09.PM.mov

Links

Testing story

-Manually test (see video)

  • Added some unit tests

PR 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

@dmcavoy dmcavoy changed the title Add expression lesson Add Lesson Edit UI for Code Documentation Associations Mar 12, 2021
@dmcavoy dmcavoy changed the base branch from staging to environment-dynamic March 25, 2021 19:04
@dmcavoy dmcavoy requested a review from a team as a code owner March 25, 2021 21:07
@dmcavoy dmcavoy changed the base branch from environment-dynamic to staging March 25, 2021 21:08
@dmcavoy dmcavoy changed the title Add Lesson Edit UI for Code Documentation Associations Set up ability to Add Code Documentation Associations to Lessons Mar 26, 2021
@dmcavoy dmcavoy requested a review from a team March 26, 2021 16:11
it('renders default props', () => {
const wrapper = mount(<ProgrammingExpressionsEditor {...defaultProps} />);
const wrapper = mount(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need mount here instead of shallow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It couldn't check for parts of the table without mount

Copy link
Contributor

Choose a reason for hiding this comment

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

you shouldn't need to check for parts of the table; that kind of check should be handled by tests on the component that actually renders the table; the most these tests should do is check for that component

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally makes sense. Those tests were existing tests so I'm going to lean in favor of making them work for now and trying to get this in.

Copy link
Contributor

@Hamms Hamms left a comment

Choose a reason for hiding this comment

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

a couple nits, but generally looks good!

@@ -155,6 +162,19 @@ class ProgrammingExpressionsEditor extends Component {
this.handleRemoveProgrammingExpressionDialogClose();
};

handleOpenAddProgrammingExpression = event => {
// Prevents button from trigger save
Copy link
Contributor

Choose a reason for hiding this comment

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

if we specify that the button element is type="button" rather than type="submit", that should prevent this for us; see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/button-has-type.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome! I did not know this and it will be so helpful going forward

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I tested this locally it did not keep the button from triggering the save

Copy link
Contributor

Choose a reason for hiding this comment

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

weird. Fine to leave this for now in the interest of prompt deployment, but we should come back later and figure out what's up here and with some of the other instances of preventDefault I've seen in this space

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it('renders default props', () => {
const wrapper = mount(<ProgrammingExpressionsEditor {...defaultProps} />);
const wrapper = mount(
<Provider store={store}>
Copy link
Contributor

Choose a reason for hiding this comment

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

is this actually necessary, given that ProgrammingExpressionsEditor is actually UnconnectedProgrammingExpressionsEditor, as per line 5?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the FindProgrammingExpressionDialog which is a sub component also needs the store and so it won't work without it

Copy link
Contributor

Choose a reason for hiding this comment

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

is that still relevant if we switch to shallow rendering?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we switch to shallow rendering some of the other checks in the exists tests don't work such as looking for parts of the table

Copy link
Contributor

Choose a reason for hiding this comment

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

right; hence my other comment about that. The point is that shallow rendering makes things simpler in every sense; it keeps tests focused on what they should be testing, which means both that we don't need to look inside other components to see what they're rendering and that we don't need to look inside other components to see what their rendering requirements are

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. Since these were existing tests and this is something we would really like to have for Tuesday I'm going to keep it as is for right now. If you think we should track it to come back to we can do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

onClick={this.handleOpenAddProgrammingExpression}
color={Button.ButtonColor.orange}
/>
<FindProgrammingExpressionDialog
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be something to fix in a future PR but when I try to add multiple programming expressions to a lesson it seems to save some of the state. Trying to get a good screen capture

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the best I can get. The search seems to be saved but the search term is cleared

Screen.Recording.2021-03-26.at.11.28.35.AM.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I don't think I thought about dealing with you clicking multiple. Will look.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is a property of the dialog itself, not of any of the code in this PR; it just requires binding state a bit closer to the value of the input rather than just listening for change events. I figured it wasn't a big enough deal, though, since the actual selection of the blocks still works

Copy link
Contributor

@bethanyaconnor bethanyaconnor left a comment

Choose a reason for hiding this comment

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

Nothing to add beyond what's already been mentioned and I think the search issue I brought up could be fixed in a future PR. So excited to see this near the finish line!

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.

nice work Dani! LGTM after addressing other people's comments.

});

store = getStore();
store.dispatch(init([], {}, []));
Copy link
Member

Choose a reason for hiding this comment

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

this may be moot if we are moving off of mount / redux for this test, this line looks safe to remove. not blocking for this PR due to deadline, but worth considering next time you are in here if you are not ripping out redux entirely.

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 will make a follow up PR to update all the tests.

@dmcavoy dmcavoy merged commit f14fdcb into staging Mar 26, 2021
@dmcavoy dmcavoy deleted the add-expression-lesson branch March 26, 2021 22:11
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