Skip to content

Commit

Permalink
Merge branch 'master' into tomas/recover-from-race-condition-when-loa…
Browse files Browse the repository at this point in the history
…ding-legacy-appeal-case-details
  • Loading branch information
va-bot committed Oct 6, 2020
2 parents 6003a6f + e92d572 commit 3e7f7a3
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 8 deletions.
23 changes: 23 additions & 0 deletions app/models/queue_tabs/assign_hearing_tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def columns
{
name: Constants.QUEUE_CONFIG.SUGGESTED_HEARING_LOCATION_COLUMN_NAME,
filter_options: suggested_location_options
},
{
name: Constants.QUEUE_CONFIG.HEARING_REQUEST_TYPE_COLUMN_NAME,
filter_options: hearing_request_type_options
}
]
end
Expand All @@ -85,6 +89,25 @@ def self.serialize_columns
]
end

def hearing_request_type_options
options = tasks.with_cached_appeals.group(:hearing_request_type).count.each_pair.map do |option, count|
label = QueueColumn.format_option_label(option, count)
QueueColumn.filter_option_hash(option, label)
end

former_travel_count = tasks.with_cached_appeals.where("cached_appeal_attributes.formally_travel = ?", true).count

if former_travel_count > 0
label = QueueColumn.format_option_label(
Constants.QUEUE_CONFIG.FILTER_OPTIONS.IS_FORMER_TRAVEL.key,
former_travel_count
)
options.append(QueueColumn.filter_option_hash(Constants.QUEUE_CONFIG.FILTER_OPTIONS.IS_FORMER_TRAVEL.key, label))
end

options
end

def power_of_attorney_name_options
tasks.with_cached_appeals.group(:power_of_attorney_name).count.each_pair.map do |option, count|
label = QueueColumn.format_option_label(option, count)
Expand Down
13 changes: 13 additions & 0 deletions app/models/task_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,27 @@ def where_string_from_filters(filters)
end.compact.join(" AND ")
end

private

def create_where_clause(filter)
clause = "#{table_column_from_name(filter.column)} IN (?)"
filter_selections = filter.values
if filter.column == Constants.QUEUE_CONFIG.HEARING_REQUEST_TYPE_COLUMN_NAME &&
filter_selections.include?(Constants.QUEUE_CONFIG.FILTER_OPTIONS.IS_FORMER_TRAVEL.key)
clause = extract_former_travel_clause(filter, clause)
end
if filter.column == Constants.QUEUE_CONFIG.COLUMNS.APPEAL_TYPE.name &&
filter_selections.include?(Constants.QUEUE_CONFIG.FILTER_OPTIONS.IS_AOD.key)
clause = extract_aod_clause(filter, clause)
end
clause
end

def extract_former_travel_clause(filter, orig_clause)
is_former_travel_clause = "cached_appeal_attributes.formally_travel = true"
(filter.values.size == 1) ? is_former_travel_clause : "(#{orig_clause} OR #{is_former_travel_clause})"
end

def extract_aod_clause(filter, orig_clause)
filter.values.delete(Constants.QUEUE_CONFIG.FILTER_OPTIONS.IS_AOD.key)
is_aod_clause = "cached_appeal_attributes.is_aod = true"
Expand All @@ -50,6 +61,8 @@ def table_column_from_name(column_name)
"cached_appeal_attributes.power_of_attorney_name"
when Constants.QUEUE_CONFIG.SUGGESTED_HEARING_LOCATION_COLUMN_NAME
"cached_appeal_attributes.suggested_hearing_location"
when Constants.QUEUE_CONFIG.HEARING_REQUEST_TYPE_COLUMN_NAME
"cached_appeal_attributes.hearing_request_type"
else
fail(Caseflow::Error::InvalidTaskTableColumnFilter, column: column_name)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ export default class AssignHearingsTable extends React.PureComponent {
return Number(queryParams[QUEUE_CONFIG.PAGE_NUMBER_REQUEST_PARAM]) || 1;
}

/* eslint-disable camelcase */
getFilterOptionsFromApi = (columnName) => {
const { colsFromApi } = this.state;

return colsFromApi?.find((col) => col.name === columnName)?.filter_options ?? [];
}
/* eslint-enable camelcase */

/*
* Gets the list of columns to populate the QueueTable with.
*/
Expand Down Expand Up @@ -125,12 +133,17 @@ export default class AssignHearingsTable extends React.PureComponent {
name: 'hearingRequestType',
header: 'Hearing Type',
align: 'left',
columnName: 'Hearing Type',
valueFunction: (row) => (
<HearingRequestType
hearingRequestType={row.hearingRequestType}
isFormerTravel={row.isFormerTravel}
/>
)
),
label: 'Filter by hearing request type',
enableFilter: true,
anyFiltersAreSet: true,
filterOptions: this.getFilterOptionsFromApi(QUEUE_CONFIG.HEARING_REQUEST_TYPE_COLUMN_NAME)
},
{
name: 'docketNum',
Expand All @@ -155,7 +168,7 @@ export default class AssignHearingsTable extends React.PureComponent {
filterValueTransform: this.formatSuggestedHearingLocation,
enableFilter: true,
anyFiltersAreSet: true,
filterOptions: colsFromApi && colsFromApi.find((col) => col.name === 'suggestedLocation').filter_options
filterOptions: this.getFilterOptionsFromApi(QUEUE_CONFIG.SUGGESTED_HEARING_LOCATION_COLUMN_NAME)
},
{
name: 'veteranState',
Expand All @@ -176,7 +189,7 @@ export default class AssignHearingsTable extends React.PureComponent {
label: 'Filter by Power of Attorney',
enableFilter: true,
anyFiltersAreSet: true,
filterOptions: colsFromApi && colsFromApi.find((col) => col.name === 'powerOfAttorneyName').filter_options
filterOptions: this.getFilterOptionsFromApi(QUEUE_CONFIG.POWER_OF_ATTORNEY_COLUMN_NAME)
}
];

Expand Down
3 changes: 3 additions & 0 deletions client/constants/QUEUE_CONFIG.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
"FILTER_OPTIONS": {
"IS_AOD": {
"key": "is_aod"
},
"IS_FORMER_TRAVEL": {
"key": "former Travel"
}
}
}
35 changes: 30 additions & 5 deletions spec/feature/hearings/assign_hearings_table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ def navigate_to_ama_tab

step "check if the filter options are as expected" do
expect(page).to have_content("Suggested Location")
expect(page).to have_selector(".unselected-filter-icon-inner", count: 2)
page.find(".unselected-filter-icon-inner", match: :first).click
expect(page).to have_selector(".unselected-filter-icon-inner", count: 3)
page.find_all(".unselected-filter-icon-inner")[1].click
expect(page).to have_content("#{Appeal.first.suggested_hearing_location.formatted_location} (1)")
expect(page).to have_content("#{Appeal.second.suggested_hearing_location.formatted_location} (1)")
expect(page).to have_content("#{Appeal.third.suggested_hearing_location.formatted_location} (1)")
Expand Down Expand Up @@ -357,8 +357,8 @@ def navigate_to_ama_tab

step "check if the filter options are as expected" do
expect(page).to have_content("Power of Attorney (POA)")
expect(page).to have_selector(".unselected-filter-icon-inner", count: 2)
page.find_all(".unselected-filter-icon-inner")[1].click
expect(page).to have_selector(".unselected-filter-icon-inner", count: 3)
page.find_all(".unselected-filter-icon-inner").last.click
expect(page).to have_content("#{Appeal.first.representative_name} (1)")
expect(page).to have_content("#{Appeal.second.representative_name} (1)")
expect(page).to have_content("#{Appeal.third.representative_name} (1)")
Expand Down Expand Up @@ -429,8 +429,9 @@ def navigate_to_ama_tab
)
end

before { cache_legacy_appeals }

scenario "Verify rows are populated correctly" do
cache_legacy_appeals
visit "hearings/schedule/assign"
expect(page).to have_content("Regional Office")
click_dropdown(text: "St. Petersburg")
Expand All @@ -443,6 +444,30 @@ def navigate_to_ama_tab
table_row = page.find("tr", id: "table-row-2")
expect(table_row).to have_content("former Travel, Virtual")
end

context "Filter by Hearing Type column" do
it "filters are correct, and filter as expected" do
step "navigate to St. Petersburg legacy veterans tab" do
visit "hearings/schedule/assign"
click_dropdown(text: "St. Petersburg")
click_button("Legacy Veterans Waiting", exact: true)
end

step "check if the filter options are as expected" do
expect(page).to have_content("Hearing Type")
expect(page).to have_selector(".unselected-filter-icon-inner", count: 3)
page.find_all(".unselected-filter-icon-inner").first.click
expect(page).to have_content("Virtual (1)")
expect(page).to have_content("Video (1)")
expect(page).to have_content("former Travel (1)")
end

step "clicking on a filter reduces the number of results by the expect amount" do
page.find("label", text: "former Travel (1)", match: :prefer_exact).click
expect(find("tbody").find_all("tr").length).to eq(1)
end
end
end
end

context "AMA Veterans waiting queue" do
Expand Down

0 comments on commit 3e7f7a3

Please sign in to comment.