Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #913 from City-of-Helsinki/hotfix/VAR-34
Browse files Browse the repository at this point in the history
VAR-34 | Staff comment section is not working
  • Loading branch information
Chi Nguyen authored Apr 9, 2019
2 parents ab64fe4 + 8005509 commit 7feb45f
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* 0.1.1
** HOTFIX **

- [#913](https://github.com/City-of-Helsinki/varaamo/pull/913) Fix issue staff comment section is not working. Reason: React-bootstrap ref prop which is deprecated and replace with inputProps
* 0.1.0
** MAJOR CHANGES **

Expand All @@ -21,7 +25,7 @@

- #875: Expand advanced search panel when filters are applied.

- #876: Free-of-charge filter for resources.
- #876: Free-of-charge filter for resources.

- #878: Remove the link for old website from the footer.

Expand Down
5 changes: 3 additions & 2 deletions app/shared/comment-form/CommentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CommentForm extends Component {

handleSave(event) {
event.preventDefault();
const comments = this.commentsInput.current.value;
const comments = this.commentsInput.value;
this.props.onSave(comments);
}

Expand All @@ -33,8 +33,9 @@ class CommentForm extends Component {
<FormControl
componentClass="textarea"
defaultValue={defaultValue}
// eslint-disable-next-line no-return-assign
inputRef={ref => this.commentsInput = ref}
placeholder={t('CommentForm.placeholder')}
ref={this.commentsInput}
rows={5}
/>
</FormGroup>
Expand Down
11 changes: 9 additions & 2 deletions app/shared/comment-form/CommentForm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ describe('shared/comment-form/CommentForm', () => {

describe('comments textarea', () => {
test('renders a FormControl with correct props', () => {
const formControl = getWrapper().find(FormControl);
const wrapper = getWrapper();
const formControl = wrapper.find(FormControl);
const mockRef = { value: 'foo' };

formControl.prop('inputRef')(mockRef);
// change input

expect(formControl.length).toBe(1);
expect(formControl.prop('componentClass')).toBe('textarea');
expect(formControl.prop('defaultValue')).toBe(defaultProps.defaultValue);
expect(typeof formControl.prop('inputRef')).toBe('function');
expect(wrapper.instance().commentsInput).toEqual(mockRef);
});
});

Expand Down Expand Up @@ -75,7 +82,7 @@ describe('shared/comment-form/CommentForm', () => {
beforeAll(() => {
const instance = getWrapper().instance();
// override ref value to mock
instance.commentsInput.current = { value: comments };
instance.commentsInput = { value: comments };

defaultProps.onSave.reset();
instance.handleSave(mockEvent);
Expand Down
5 changes: 3 additions & 2 deletions app/shared/modals/reservation-info/ReservationInfoModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ReservationInfoModal extends Component {
}

handleSaveCommentsClick() {
const comments = this.commentsInput.current.value;
const comments = this.commentsInput.value;
this.props.onSaveCommentsClick(comments);
}

Expand Down Expand Up @@ -98,8 +98,9 @@ class ReservationInfoModal extends Component {
componentClass="textarea"
defaultValue={reservation.comments}
disabled={disabled}
// eslint-disable-next-line no-return-assign
inputRef={ref => this.commentsInput = ref}
placeholder={t('common.commentsPlaceholder')}
ref={this.commentsInput}
rows={5}
/>
</FormGroup>
Expand Down
12 changes: 10 additions & 2 deletions app/shared/modals/reservation-info/ReservationInfoModal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,18 @@ describe('shared/modals/reservation-info/ReservationInfoModal', () => {
});

test('renders textarea FormControl for comments with correct props', () => {
const formControl = getCommentsForm(props).find(FormControl);
const wrapper = getWrapper(props);
const formControl = wrapper.find('.comments-form').find(FormControl);
const mockRef = { value: 'foo' };

formControl.prop('inputRef')(mockRef);
// change input value

expect(formControl).toHaveLength(1);
expect(formControl.prop('componentClass')).toBe('textarea');
expect(formControl.prop('defaultValue')).toBe(reservation.comments);
expect(typeof formControl.prop('inputRef')).toBe('function');
expect(wrapper.instance().commentsInput).toEqual(mockRef);
});

test('renders a save button with correct onClick prop', () => {
Expand Down Expand Up @@ -363,7 +371,7 @@ describe('shared/modals/reservation-info/ReservationInfoModal', () => {
beforeAll(() => {
const instance = getWrapper({ onSaveCommentsClick }).instance();
// override ref value to mock
instance.commentsInput.current = { value: comments };
instance.commentsInput = { value: comments };
instance.handleSaveCommentsClick();
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "varaamo",
"version": "0.1.0",
"version": "0.1.1",
"repository": {
"type": "git",
"url": "https://github.com/City-of-Helsinki/varaamo"
Expand Down

0 comments on commit 7feb45f

Please sign in to comment.