-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23625 from code-dot-org/remove-student-warning-types
Minimal warning if student has never signed in
- Loading branch information
Showing
10 changed files
with
227 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
apps/src/templates/manageStudents/ConfirmRemoveStudentDialog.story.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import ConfirmRemoveStudentDialog, {MINIMUM_TEST_PROPS} from './ConfirmRemoveStudentDialog'; | ||
|
||
const STORY_PROPS = { | ||
...MINIMUM_TEST_PROPS, | ||
hideBackdrop: true, | ||
}; | ||
|
||
export default storybook => storybook | ||
.storiesOf('ConfirmRemoveStudentDialog', module) | ||
.addStoryTable([ | ||
{ | ||
name:'For a student who has never signed in', | ||
description: ` | ||
Removing a student who has never signed in incurs no risk | ||
of losing access to data for the student or the school, so the | ||
warning dialog can be minimal. | ||
`, | ||
story: () => ( | ||
<ConfirmRemoveStudentDialog | ||
{...STORY_PROPS} | ||
hasEverSignedIn={false} | ||
/> | ||
) | ||
}, { | ||
name:'For a student who has signed in', | ||
description: ` | ||
Removing a student who has signed in may give the student the ability | ||
to delete their account, which would result in destruction of school | ||
records. Therefore, we show a scary warning. | ||
`, | ||
story: () => ( | ||
<ConfirmRemoveStudentDialog | ||
{...STORY_PROPS} | ||
hasEverSignedIn={true} | ||
/> | ||
) | ||
} | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
apps/test/unit/templates/manageStudents/ConfirmRemoveStudentDialogTest.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React from 'react'; | ||
import {mount} from 'enzyme'; | ||
import i18n from '@cdo/locale'; | ||
import {expect} from '../../../util/configuredChai'; | ||
import ConfirmRemoveStudentDialog, {MINIMUM_TEST_PROPS} from '@cdo/apps/templates/manageStudents/ConfirmRemoveStudentDialog'; | ||
import Button from '@cdo/apps/templates/Button'; | ||
import {Header, ConfirmCancelFooter} from '@cdo/apps/lib/ui/SystemDialog/SystemDialog'; | ||
import {ADD_A_PERSONAL_LOGIN_HELP_URL} from '@cdo/apps/lib/util/urlHelpers'; | ||
|
||
describe('ConfirmRemoveStudentDialog', () => { | ||
it('renders nothing if not open', () => { | ||
const wrapper = mount( | ||
<ConfirmRemoveStudentDialog | ||
{...MINIMUM_TEST_PROPS} | ||
isOpen={false} | ||
/> | ||
); | ||
expect(wrapper).to.be.empty; | ||
}); | ||
|
||
it('renders minimal content if student has never signed in', () => { | ||
const wrapper = mount( | ||
<ConfirmRemoveStudentDialog | ||
{...MINIMUM_TEST_PROPS} | ||
hasEverSignedIn={false} | ||
/> | ||
); | ||
expect(wrapper).to.containMatchingElement( | ||
<div> | ||
<Header text={i18n.removeStudentHeader()}/> | ||
<ConfirmCancelFooter | ||
confirmText={i18n.removeStudent()} | ||
confirmColor={Button.ButtonColor.red} | ||
onConfirm={MINIMUM_TEST_PROPS.onConfirm} | ||
onCancel={MINIMUM_TEST_PROPS.onCancel} | ||
disableConfirm={false} | ||
disableCancel={false} | ||
tabIndex="1" | ||
/> | ||
</div> | ||
); | ||
}); | ||
|
||
it('renders full text if student has ever signed in', () => { | ||
const wrapper = mount( | ||
<ConfirmRemoveStudentDialog | ||
{...MINIMUM_TEST_PROPS} | ||
hasEverSignedIn={true} | ||
/> | ||
); | ||
expect(wrapper).to.containMatchingElement( | ||
<div> | ||
<Header text={i18n.removeStudentHeaderNew()}/> | ||
<div> | ||
<p> | ||
<strong>{i18n.removeStudentBody1()}</strong> | ||
{' '} | ||
{i18n.removeStudentBody2()} | ||
</p> | ||
<p> | ||
{i18n.removeStudentBody3()} | ||
</p> | ||
<Button | ||
text={i18n.removeStudentSendHomeInstructions()} | ||
target="_blank" | ||
href={ADD_A_PERSONAL_LOGIN_HELP_URL} | ||
color={Button.ButtonColor.blue} | ||
size={Button.ButtonSize.large} | ||
tabIndex="1" | ||
/> | ||
<p> | ||
{i18n.removeStudentBody4()} | ||
</p> | ||
</div> | ||
<ConfirmCancelFooter | ||
confirmText={i18n.removeStudent()} | ||
confirmColor={Button.ButtonColor.red} | ||
onConfirm={MINIMUM_TEST_PROPS.onConfirm} | ||
onCancel={MINIMUM_TEST_PROPS.onCancel} | ||
disableConfirm={false} | ||
disableCancel={false} | ||
tabIndex="1" | ||
/> | ||
</div> | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.