Skip to content

Commit

Permalink
Validate special issues dispatch page (#14047)
Browse files Browse the repository at this point in the history
Resolves #14018

### Description
Adds validation to the special issues page for dispatching legacy appeals

### Acceptance Criteria
- [ ] Code compiles correctly

### Testing Plan
#### FeatureToggle On
1. Feature toggle!
```ruby
> FeatureToggle.enable!(:special_issues_revamp)
```
2. Log in as BVAGWHITE
3. Go to `/dispatch` and hit `Establish New Claim`
4. Hit "Route Claim" while no special issues are selected
5. Confirm error
6. Select a special issue and hit "Route Claim"
7. confirm success!

### User Facing Changes
![Screen Shot 2020-04-20 at 5 10 34 PM](https://user-images.githubusercontent.com/45575454/79889333-de560300-83cb-11ea-96df-c1bba7edb26f.png)
  • Loading branch information
hschallhorn authored Apr 21, 2020
1 parent a474793 commit 83cdb76
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 11 deletions.
50 changes: 40 additions & 10 deletions client/app/containers/EstablishClaimPage/EstablishClaimDecision.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { connect } from 'react-redux';
import * as Constants from '../../establishClaim/constants';
import moment from 'moment';
import { LOGO_COLORS } from '../../constants/AppConstants';
import COPY from '../../../COPY';

export class EstablishClaimDecision extends React.Component {
constructor(props) {
Expand All @@ -40,17 +41,34 @@ export class EstablishClaimDecision extends React.Component {
return this.props.task.appeal.decisions.length > 1;
}

validate = () => {
const {
specialIssuesRevamp,
specialIssues,
handleSubmit,
showSpecialIssueError
} = this.props;

if (specialIssuesRevamp && Object.values(specialIssues).every((isChecked) => !isChecked)) {
showSpecialIssueError();

return;
}

return handleSubmit();
}

render() {
let {
loading,
decisionType,
handleSubmit,
handleToggleCancelTaskModal,
handleSpecialIssueFieldChange,
pdfLink,
pdfjsLink,
specialIssues,
task
task,
specialIssuesError
} = this.props;

let issueColumns = [
Expand Down Expand Up @@ -204,6 +222,13 @@ export class EstablishClaimDecision extends React.Component {
<b>Select Special Issues</b>
</label>
</legend>
{specialIssuesError &&
<Alert
title={COPY.SPECIAL_ISSUES_NONE_CHOSEN_TITLE}
message={COPY.SPECIAL_ISSUES_NONE_CHOSEN_DETAIL}
type="error"
/>
}
<div className="cf-multiple-columns">
{enabledSpecialIssues(this.props.specialIssuesRevamp).map((issue, index) => {
return (
Expand All @@ -230,7 +255,7 @@ export class EstablishClaimDecision extends React.Component {
<Button
app="dispatch"
name={this.state.endProductButtonText}
onClick={handleSubmit}
onClick={this.validate}
loading={loading}
/>
</div>
Expand All @@ -242,34 +267,39 @@ export class EstablishClaimDecision extends React.Component {

EstablishClaimDecision.propTypes = {
decisionType: PropTypes.string.isRequired,
handleToggleCancelTaskModal: PropTypes.func.isRequired,
handleSubmit: PropTypes.func.isRequired,
handleSpecialIssueFieldChange: PropTypes.func,
handleSubmit: PropTypes.func.isRequired,
handleToggleCancelTaskModal: PropTypes.func.isRequired,
loading: PropTypes.bool,
pdfLink: PropTypes.string.isRequired,
pdfjsLink: PropTypes.string.isRequired,
showSpecialIssueError: PropTypes.func,
specialIssues: PropTypes.object.isRequired,
task: PropTypes.object.isRequired,
loading: PropTypes.bool,
specialIssuesRevamp: PropTypes.bool
specialIssuesError: PropTypes.bool,
specialIssuesRevamp: PropTypes.bool,
task: PropTypes.object.isRequired
};

const mapStateToProps = (state) => ({
specialIssues: state.specialIssues
specialIssues: state.specialIssues,
specialIssuesError: state.establishClaim.error
});

const mapDispatchToProps = (dispatch) => ({
handleToggleCancelTaskModal: () => {
dispatch({ type: Constants.TOGGLE_CANCEL_TASK_MODAL });
},
handleSpecialIssueFieldChange: (specialIssue) => (value) => {
dispatch({ type: Constants.CLEAR_SPECIAL_ISSUE_ERROR });
dispatch({
type: Constants.CHANGE_SPECIAL_ISSUE,
payload: {
specialIssue,
value
}
});
}
},
showSpecialIssueError: () => dispatch({ type: Constants.SHOW_SPECIAL_ISSUE_ERROR })
});

const ConnectedEstablishClaimDecision = connect(
Expand Down
2 changes: 2 additions & 0 deletions client/app/establishClaim/constants/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// actions
export const CHANGE_SPECIAL_ISSUE = 'CHANGE_SPECIAL_ISSUE';
export const SHOW_SPECIAL_ISSUE_ERROR = 'SHOW_SPECIAL_ISSUE_ERROR';
export const CLEAR_SPECIAL_ISSUE_ERROR = 'CLEAR_SPECIAL_ISSUE_ERROR';
export const CHANGE_ESTABLISH_CLAIM_FIELD = 'CHANGE_ESTABLISH_CLAIM_FIELD';
export const TOGGLE_CANCEL_TASK_MODAL = 'TOGGLE_CANCEL_TASK_MODAL';
export const TRIGGER_LOADING = 'TRIGGER_LOADING';
Expand Down
15 changes: 14 additions & 1 deletion client/app/establishClaim/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const getEstablishClaimInitialState = function() {
isSubmittingCancelFeedback: false,
isShowingCancelModal: false,
isValidating: false,
loading: false
loading: false,
error: false
};
};

Expand Down Expand Up @@ -48,6 +49,18 @@ export const establishClaim = function(state = getEstablishClaimInitialState(),
isValidating: false,
cancelFeedback: action.payload.value
};
case Constants.SHOW_SPECIAL_ISSUE_ERROR: {
return {
...state,
error: true
};
}
case Constants.CLEAR_SPECIAL_ISSUE_ERROR: {
return {
...state,
error: false
};
}
default:
return state;
}
Expand Down
37 changes: 37 additions & 0 deletions spec/feature/dispatch/establish_claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,43 @@
expect(page).to have_content("System Error")
end

context "Special issue validation" do
before { FeatureToggle.enable!(:special_issues_revamp) }
after { FeatureToggle.disable!(:special_issues_revamp) }

let!(:task) do
create(:establish_claim,
created_at: 3.days.ago,
prepared_at: Date.yesterday,
appeal: appeal_full_grant,
aasm_state: "unassigned")
end

scenario "Establish a new claim with special issue routed to national office" do
task.assign!(:assigned, current_user)
visit "/dispatch/establish-claim/#{task.id}"

# Try to move forward without selecting a special issue
click_on "Route claim"

# Error!
expect(page).to have_content(COPY::SPECIAL_ISSUES_NONE_CHOSEN_TITLE)
expect(page).to have_content(COPY::SPECIAL_ISSUES_NONE_CHOSEN_DETAIL)

# Select no special issues and move forward
click_label("noSpecialIssues")
expect(page).to have_no_content(COPY::SPECIAL_ISSUES_NONE_CHOSEN_TITLE)
click_on "Route claim"

# Success!
expect(page).to have_content("Create End Product")

# Ensure we really cleared the error
click_on "< Back to Review Decision"
expect(page).to have_no_content(COPY::SPECIAL_ISSUES_NONE_CHOSEN_TITLE)
end
end

context "For an appeal with multiple possible decision documents in VBMS" do
let(:documents) do
[
Expand Down

0 comments on commit 83cdb76

Please sign in to comment.