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

Move students: success and error notifications #22190

Merged
merged 29 commits into from
May 4, 2018
Merged

Conversation

maddiedierker
Copy link
Contributor

@maddiedierker maddiedierker commented May 4, 2018

This is PR no. 4 for rewriting the 'move students' functionality in React. For context, check out my previous PR or the spec.

This implements success and error notification functionality. Because success notifications live in the parent component (ManageStudentsTable), the code to render those notifications will be in the next (and final!) PR that hooks up the new 'move students' dialog to the 'manage students' tab.

Errors, on the other hand, are rendered in the 'move students' dialog itself using error text returned from the server.

Examples

screen shot 2018-05-03 at 5 04 24 pm

screen shot 2018-05-03 at 5 03 34 pm

Copy link
Contributor

@caleybrock caleybrock left a comment

Choose a reason for hiding this comment

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

Looks good to me!

/>
)
},
{
name: 'Move students dialog',
description: 'Ability to move students in a certain section to a different section or teacher',
description: 'Dialog when an error has occurred',
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 nice addition

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

excited_totally_wicked

sections={sections}
updateStudentTransfer={() => console.log('updating...')}
transferStudents={() => console.log('transferring...')}
cancelStudentTransfer={() => console.log('cancelling...')}
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a storybook "actions" addon designed for stubbing callbacks like this, that logs to the onscreen console (not the developer console) and reports any arguments passed to the callback as well. Example:

import {action} from '@storybook/addon-actions';
export default storybook => {
return storybook
.storiesOf('MakerToolkit/ConfirmEnableMakerDialog', module)
.add('overview', () => {
return (
<ConfirmEnableMakerDialog
isOpen
handleConfirm={action('Confirm')}
handleCancel={action('Cancel')}
/>
);
});
};

@@ -51,6 +59,7 @@ describe('MoveStudents', () => {
{...DEFAULT_PROPS}
updateStudentTransfer={updateStudentTransfer}
transferStudents={transferStudents}
cancelStudentTransfer={cancelStudentTransfer}
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to compose DEFAULT_PROPS and the spy callbacks in your beforeEach function, since you pass them in every single test.

);

wrapper.find('Button').simulate('click');
expect(cancelStudentTransfer.callCount).to.equal(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip: We've already got the sinon-chai assertions enabled so you can make assertions about spies and stubs like this:

expect(cancelStudentTransfer).not.to.have.been.called;
expect(cancelStudentTransfer).to.have.been.calledOnce;

@caleybrock
Copy link
Contributor

A little suggestion you can feel free to do later or not take if it's already discussed in the spec. For these cases it feels like the error message would make more sense to have right under where you entered the section.

@maddiedierker maddiedierker requested a review from nkiruka May 4, 2018 16:30
@maddiedierker
Copy link
Contributor Author

@caleybrock re: error message placement, i think you have a good point. poorva and i discussed the other day and decided to put the error at the top of the modal since the error won't always have to do with the section input--it could be a more general failure (although it'll usually be the former, so it might make sense to move it at some point...)

@maddiedierker maddiedierker merged commit f534170 into staging May 4, 2018
@maddiedierker maddiedierker deleted the move-students-pt4 branch May 4, 2018 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants