mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-19 19:07:47 -05:00
Add tests and expose steps enum so it can be referenced from outside MuteModal
This commit is contained in:
parent
f7bf204924
commit
92667c097d
3 changed files with 44 additions and 3 deletions
|
@ -240,8 +240,8 @@ MuteModal.propTypes = {
|
||||||
}),
|
}),
|
||||||
onRequestClose: PropTypes.func,
|
onRequestClose: PropTypes.func,
|
||||||
showWarning: PropTypes.bool,
|
showWarning: PropTypes.bool,
|
||||||
startStep: PropTypes.number,
|
startStep: PropTypes.oneOf(Object.keys(steps)),
|
||||||
timeMuted: PropTypes.string
|
timeMuted: PropTypes.string
|
||||||
};
|
};
|
||||||
|
MuteModal.steps = steps;
|
||||||
module.exports = injectIntl(MuteModal);
|
module.exports = injectIntl(MuteModal);
|
||||||
|
|
|
@ -344,7 +344,7 @@ class ComposeComment extends React.Component {
|
||||||
muteModalMessages={this.getMuteMessageInfo()}
|
muteModalMessages={this.getMuteMessageInfo()}
|
||||||
shouldCloseOnOverlayClick={false}
|
shouldCloseOnOverlayClick={false}
|
||||||
showWarning={this.state.showWarning}
|
showWarning={this.state.showWarning}
|
||||||
startStep={this.props.isReply ? 1 : 0}
|
startStep={this.props.isReply ? MuteModal.steps.MUTE_INFO : MuteModal.steps.COMMENT_ISSUE}
|
||||||
timeMuted={formatTime.formatRelativeTime(this.state.muteExpiresAtMs, window._locale)}
|
timeMuted={formatTime.formatRelativeTime(this.state.muteExpiresAtMs, window._locale)}
|
||||||
onRequestClose={this.handleMuteClose}
|
onRequestClose={this.handleMuteClose}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -101,6 +101,46 @@ describe('Compose Comment test', () => {
|
||||||
global.Date.now = realDateNow;
|
global.Date.now = realDateNow;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Comment Status and compose box do not show on replies when muted, but mute modal does', () => {
|
||||||
|
const realDateNow = Date.now.bind(global.Date);
|
||||||
|
global.Date.now = () => 0;
|
||||||
|
const store = mockStore({
|
||||||
|
session: {
|
||||||
|
session: {
|
||||||
|
user: {},
|
||||||
|
permissions: {
|
||||||
|
mute_status: {
|
||||||
|
muteExpiresAt: 5,
|
||||||
|
offenses: [],
|
||||||
|
showWarning: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const component = mountWithIntl(
|
||||||
|
<ComposeComment
|
||||||
|
{...defaultProps()}
|
||||||
|
isReply
|
||||||
|
/>
|
||||||
|
, {context: {store}}
|
||||||
|
);
|
||||||
|
expect(component.find('FlexRow.compose-comment').exists()).toEqual(false);
|
||||||
|
expect(component.find('MuteModal').exists()).toBe(true);
|
||||||
|
expect(component.find('MuteModal').props().startStep).toBe(1);
|
||||||
|
expect(component.find('CommentingStatus').exists()).toEqual(false);
|
||||||
|
global.Date.now = realDateNow;
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Comment Status and compose box show on replies when not muted', () => {
|
||||||
|
const realDateNow = Date.now.bind(global.Date);
|
||||||
|
global.Date.now = () => 0;
|
||||||
|
const component = getComposeCommentWrapper({isReply:true});
|
||||||
|
expect(component.find('FlexRow.compose-comment').exists()).toEqual(true);
|
||||||
|
expect(component.find('CommentingStatus').exists()).toEqual(false);
|
||||||
|
global.Date.now = realDateNow;
|
||||||
|
});
|
||||||
|
|
||||||
test('Comment Status initialized properly when muted', () => {
|
test('Comment Status initialized properly when muted', () => {
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
const realDateNow = Date.now.bind(global.Date);
|
const realDateNow = Date.now.bind(global.Date);
|
||||||
|
@ -207,6 +247,7 @@ describe('Compose Comment test', () => {
|
||||||
commentInstance.setState({muteOpen: true});
|
commentInstance.setState({muteOpen: true});
|
||||||
component.update();
|
component.update();
|
||||||
expect(component.find('MuteModal').exists()).toEqual(true);
|
expect(component.find('MuteModal').exists()).toEqual(true);
|
||||||
|
expect(component.find('MuteModal').props().startStep).toEqual(0);
|
||||||
expect(component.find('MuteModal').props().showWarning).toBe(false);
|
expect(component.find('MuteModal').props().showWarning).toBe(false);
|
||||||
global.Date.now = realDateNow;
|
global.Date.now = realDateNow;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue