-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
324 additions
and
16 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
54 changes: 54 additions & 0 deletions
54
app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryEstimate.js
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,54 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
import { isFeature } from '../../../models/beta/story'; | ||
|
||
export class ExpandedStoryEstimate extends React.Component { | ||
editStory(event) { | ||
const newValue = event.target.value; | ||
|
||
this.props.onEdit({ estimate: newValue }); | ||
}; | ||
|
||
render() { | ||
const { project, story } = this.props; | ||
|
||
return ( | ||
<div className="Story__section"> | ||
<div className="Story__section-title"> | ||
{ I18n.translate('activerecord.attributes.story.estimate') } | ||
</div> | ||
|
||
<select | ||
defaultValue={story.estimate} | ||
className="form-control input-sm" | ||
onChange={(event) => this.editStory(event)} | ||
disabled={!isFeature(story)} | ||
> | ||
<option value=''> | ||
{ I18n.translate('story.no_estimate') } | ||
</option> | ||
{ | ||
project.pointValues.map((value) => ( | ||
<option value={value} key={value}> | ||
{ value } | ||
</option> | ||
)) | ||
} | ||
</select> | ||
</div> | ||
); | ||
}; | ||
}; | ||
|
||
ExpandedStoryEstimate.propTypes = { | ||
project: PropTypes.object, | ||
story: PropTypes.object | ||
}; | ||
|
||
const mapStateToProps = ({ project }) => ({ project }); | ||
|
||
export default connect( | ||
mapStateToProps, | ||
null | ||
)(ExpandedStoryEstimate); |
43 changes: 43 additions & 0 deletions
43
app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryType.js
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,43 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { types } from '../../../models/beta/story'; | ||
|
||
export class ExpandedStoryType extends React.Component { | ||
editStory(event) { | ||
const newValue = event.target.value; | ||
|
||
this.props.onEdit({ storyType: newValue }); | ||
}; | ||
|
||
render() { | ||
const { story } = this.props; | ||
|
||
return ( | ||
<div className="Story__section"> | ||
<div className="Story__section-title"> | ||
{ I18n.translate('activerecord.attributes.story.story_type') } | ||
</div> | ||
|
||
<select | ||
defaultValue={story.storyType} | ||
className="form-control input-sm" | ||
onChange={(event) => this.editStory(event)} | ||
> | ||
{ | ||
types.map((value) => ( | ||
<option value={value} key={value}> | ||
{ value } | ||
</option> | ||
)) | ||
} | ||
</select> | ||
</div> | ||
); | ||
}; | ||
}; | ||
|
||
ExpandedStoryType.propTypes = { | ||
story: PropTypes.object | ||
}; | ||
|
||
export default ExpandedStoryType; |
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
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
98 changes: 98 additions & 0 deletions
98
spec/javascripts/components/story/expanded_story/expanded_story_estimate_spec.js
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,98 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { ExpandedStoryEstimate } from 'components/story/ExpandedStory/ExpandedStoryEstimate'; | ||
|
||
describe('<ExpandedStoryEstimate />', () => { | ||
it("renders component with 'Fibonacci' point scale in select", () => { | ||
const project = { pointValues: ['1','2','3','5','8'] }; | ||
const story = { estimate: null }; | ||
|
||
const wrapper = shallow(<ExpandedStoryEstimate project={project} story={story}/>); | ||
const select = wrapper.find('select').text(); | ||
|
||
project.pointValues.forEach((value) => { | ||
expect(select).toContain(value); | ||
}); | ||
}); | ||
|
||
it("renders component with 'Powers of two' point scale in select", () => { | ||
const project = { pointValues: ['1','2','4','8'] }; | ||
const story = { estimate: null }; | ||
|
||
const wrapper = shallow(<ExpandedStoryEstimate project={project} story={story}/>); | ||
const select = wrapper.find('select').text(); | ||
|
||
project.pointValues.forEach((value) => { | ||
expect(select).toContain(value); | ||
}); | ||
}); | ||
|
||
it("renders component with 'Linear' point scale in select", () => { | ||
const project = { pointValues: ['1','2','3','4','5'] }; | ||
const story = { estimate: null }; | ||
|
||
const wrapper = shallow(<ExpandedStoryEstimate project={project} story={story}/>); | ||
const select = wrapper.find('select').text(); | ||
|
||
project.pointValues.forEach((value) => { | ||
expect(select).toContain(value); | ||
}); | ||
}); | ||
|
||
describe("When story.estimate is not null", () => { | ||
it("sets the select defaultValue as story.estimate", () => { | ||
const project = { pointValues: ['1','2','3','5','8'] }; | ||
|
||
project.pointValues.forEach((value) => { | ||
const story = { estimate: value }; | ||
const wrapper = shallow(<ExpandedStoryEstimate project={project} story={story}/>); | ||
const select = wrapper.find('select'); | ||
|
||
expect(select.props().defaultValue).toBe(value); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("When story.estimate is null", () => { | ||
it("sets the select defaultValue as null", () => { | ||
const project = { pointValues: ['1','2','3','4','5'] }; | ||
const story = { estimate: null }; | ||
|
||
const wrapper = shallow(<ExpandedStoryEstimate project={project} story={story}/>); | ||
const select = wrapper.find('select'); | ||
|
||
expect(select.props().defaultValue).toBe(null); | ||
}); | ||
}); | ||
|
||
describe("When change storyType", () => { | ||
describe("to a type that is not a feature", () =>{ | ||
const notFeatureTypes = ['bug', 'release', 'chore']; | ||
|
||
it("disables estimate select", () =>{ | ||
const project = { pointValues: ['1','2','3','4','5'] }; | ||
|
||
notFeatureTypes.forEach((type) => { | ||
const story = { storyType: type }; | ||
const wrapper = shallow(<ExpandedStoryEstimate project={project} story={story}/>); | ||
|
||
const select = wrapper.find('select'); | ||
|
||
expect(select.props().disabled).toBe(true); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("to a feature", () =>{ | ||
it("not disable estimate select", () =>{ | ||
const project = { pointValues: ['1','2','3','4','5'] }; | ||
const story = { storyType: 'bug' }; | ||
|
||
const wrapper = shallow(<ExpandedStoryEstimate project={project} story={story}/>); | ||
const select = wrapper.find('select'); | ||
|
||
expect(select.props().disabled).toBe(true); | ||
}); | ||
}); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
spec/javascripts/components/story/expanded_story/expanded_story_spec.js
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
17 changes: 17 additions & 0 deletions
17
spec/javascripts/components/story/expanded_story/expanded_story_type_spec.js
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,17 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import ExpandedStoryType from 'components/story/ExpandedStory/ExpandedStoryType'; | ||
|
||
describe('<ExpandedStoryEstimate />', () => { | ||
it("sets defaultValue as story.storyType in select", () => { | ||
const storyTypes = ['feature', 'bug', 'release', 'chore']; | ||
|
||
storyTypes.forEach((type) => { | ||
const story = { storyType: type }; | ||
const wrapper = shallow(<ExpandedStoryType story={story} />); | ||
const select = wrapper.find('select'); | ||
|
||
expect(select.props().defaultValue).toBe(type); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,20 +1,23 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { StoryItem } from 'components/story/StoryItem'; | ||
import storyFactory from '../../support/factories/storyFactory' | ||
import storyFactory from '../../support/factories/storyFactory'; | ||
import ExpandedStory from 'components/story/ExpandedStory'; | ||
import CollapsedStory from 'components/story/CollapsedStory'; | ||
|
||
|
||
describe('<StoryItem />', () => { | ||
it('renders the StoryItem component within a Collapsed Story', () => { | ||
const story = storyFactory({ collapsed: true }); | ||
const wrapper = shallow(<StoryItem story={story} />); | ||
|
||
expect(wrapper.find('CollapsedStory')).toExist(); | ||
expect(wrapper.find(CollapsedStory)).toExist(); | ||
}); | ||
|
||
it('renders the StoryItem component within a Expanded Story', () => { | ||
const story = storyFactory({ collapsed: false }); | ||
const wrapper = shallow(<StoryItem story={story} />); | ||
|
||
expect(wrapper.find('ExpandedStory')).toExist(); | ||
expect(wrapper.find(ExpandedStory)).toExist(); | ||
}); | ||
}); |
Oops, something went wrong.