diff --git a/client/test/app/caseDistribution/pages/CaseDistributionApp.test.js b/client/test/app/caseDistribution/pages/CaseDistributionApp.test.js index 50ace1ab67c..f28255d91c5 100644 --- a/client/test/app/caseDistribution/pages/CaseDistributionApp.test.js +++ b/client/test/app/caseDistribution/pages/CaseDistributionApp.test.js @@ -1,5 +1,13 @@ import React from 'react'; import CaseDistributionApp from 'app/caseDistribution/pages/CaseDistributionApp'; +import { + history as leverHistory, + mockAffinityDaysLevers, + mockBatchLevers, + mockDocketDistributionPriorLevers, + mockDocketTimeGoalsLevers, + mockStaticLevers +} from '../../../data/adminCaseDistributionLevers'; import { Provider } from 'react-redux'; import { createStore, applyMiddleware } from 'redux'; import rootReducer from 'app/caseDistribution/reducers/root'; @@ -14,11 +22,11 @@ describe('render Case Distribution Application', () => { applyMiddleware(thunk)); let testLevers = { - static: [], - batch: [], - affinity: [], - docket_distribution_prior: [], - docket_time_goal: [] + static: mockStaticLevers, + batch: mockBatchLevers, + affinity: mockAffinityDaysLevers, + docket_distribution_prior: mockDocketDistributionPriorLevers, + docket_time_goal: mockDocketTimeGoalsLevers }; afterEach(() => { @@ -33,7 +41,7 @@ describe('render Case Distribution Application', () => { diff --git a/spec/controllers/appeals_controller_spec.rb b/spec/controllers/appeals_controller_spec.rb index 83e6de31ff1..ee93885402c 100644 --- a/spec/controllers/appeals_controller_spec.rb +++ b/spec/controllers/appeals_controller_spec.rb @@ -1001,7 +1001,7 @@ def allow_vbms_to_return_empty_array end describe "POST update" do - context "AMA Appeal" do + context "AMA Appeal updates for MST/PACT issues" do before do User.authenticate!(roles: ["System Admin"]) Fakes::Initializer.load! @@ -1059,5 +1059,160 @@ def allow_vbms_to_return_empty_array expect(response).to be_successful end end + + context "Adding a contested claim issue" do + let!(:current_user) { User.authenticate!(roles: ["Mail Intake"]) } + let!(:appeal) do + create(:appeal, :with_post_intake_tasks, docket_type: docket) + end + let(:docket) { nil } + + before do + User.authenticate!(user: current_user) + end + + subject do + post :update, params: { + request_issues: [ + { + benefit_type: "compensation", + nonrating_issue_category: "Contested Claims - Attorney Fees", + decision_text: "Test Issue", + decision_date: 1.week.ago.to_date, + ineligible_due_to_id: nil, + ineligible_reason: nil, + withdrawal_date: nil, + is_predocket_needed: nil, + mst_status: false, + pact_status: false + } + ], + controller: "appeals", + action: "update", + appeal_id: appeal.uuid + } + end + + context "with the feature toggle off" do + let(:docket) { Constants.AMA_DOCKETS.direct_review } + + it "does not create a SendInitialNotificationLetterTask" do + expect_any_instance_of(AppealsController).to_not receive(:send_initial_notification_letter) + + subject + task = Task.find_by(type: SendInitialNotificationLetterTask.name, appeal: appeal) + + expect(task).to be nil + end + end + + context "with the feature toggle on" do + before do + FeatureToggle.enable!(:cc_appeal_workflow) + FeatureToggle.enable!(:indicator_for_contested_claims) + ClerkOfTheBoard.singleton + end + + after do + FeatureToggle.disable!(:cc_appeal_workflow) + FeatureToggle.disable!(:indicator_for_contested_claims) + end + + context "to a direct review docket appeal" do + let(:docket) { Constants.AMA_DOCKETS.direct_review } + + it "creates SendInitialNotificationLetterTask as child of DistributionTask" do + subject + task = Task.find_by(type: SendInitialNotificationLetterTask.name, appeal: appeal) + + expect(response).to be_successful + expect(task.present?).to be true + expect(task.parent.type).to eq DistributionTask.name + expect(task.assigned_to).to eq ClerkOfTheBoard.singleton + expect(task.assigned_by).to eq current_user + end + end + + context "to an evidence submission docket appeal" do + let(:docket) { Constants.AMA_DOCKETS.evidence_submission } + + it "creates SendInitialNotificationLetterTask as child of EvidenceSubmissionWindowTask" do + subject + task = Task.find_by(type: SendInitialNotificationLetterTask.name, appeal: appeal) + + expect(response).to be_successful + expect(task.present?).to be true + expect(task.parent.type).to eq EvidenceSubmissionWindowTask.name + expect(task.assigned_to).to eq ClerkOfTheBoard.singleton + expect(task.assigned_by).to eq current_user + end + end + + context "to a hearing docket appeal" do + let(:docket) { Constants.AMA_DOCKETS.hearing } + + it "creates SendInitialNotificationLetterTask as child of ScheduleHearingTask" do + subject + task = Task.find_by(type: SendInitialNotificationLetterTask.name, appeal: appeal) + + expect(response).to be_successful + expect(task.present?).to be true + expect(task.parent.type).to eq ScheduleHearingTask.name + expect(task.assigned_to).to eq ClerkOfTheBoard.singleton + expect(task.assigned_by).to eq current_user + end + end + + context "when an appeal already has a SendInitialNotificationLetterTask" do + let(:docket) { Constants.AMA_DOCKETS.direct_review } + let!(:inital_letter_task) do + build(:task, + type: SendInitialNotificationLetterTask.name, + assigned_to: ClerkOfTheBoard.singleton, + assigned_by: current_user, + assigned_at: Time.zone.now, + appeal: appeal, + parent: appeal.tasks.where(type: DistributionTask.name).first, + status: task_status, + updated_at: Time.zone.now).tap { |t| t.save(validate: false) } + end + + context "which is active" do + let(:task_status) { Constants.TASK_STATUSES.assigned } + + it "does not create a new SendInitialNotificationLetterTask" do + subject + + expect(response).to be_successful + expect(Task.where(appeal: appeal, type: SendInitialNotificationLetterTask.name).count).to eq 1 + end + end + + context "which is completed" do + let(:task_status) { Constants.TASK_STATUSES.completed } + + it "creates a new SendInitialNotificationLetterTask" do + subject + + expect(response).to be_successful + expect(Task.where(appeal: appeal, type: SendInitialNotificationLetterTask.name).count).to eq 2 + expect(Task.active.where(appeal: appeal, type: SendInitialNotificationLetterTask.name).count).to eq 1 + end + end + + context "which is cancelled" do + let(:task_status) { Constants.TASK_STATUSES.cancelled } + + it "creates a new SendInitialNotificationLetterTask" do + subject + + expect(response).to be_successful + expect(Task.where(appeal: appeal, type: SendInitialNotificationLetterTask.name).count).to eq 2 + expect(Task.active.where(appeal: appeal, type: SendInitialNotificationLetterTask.name).count).to eq 1 + end + end + end + end + end end end diff --git a/spec/feature/automatic_case_distribution/acd_audit_history/audit_lever_history_table_spec.rb b/spec/feature/automatic_case_distribution/acd_audit_history/audit_lever_history_table_spec.rb deleted file mode 100644 index c1662fc1a04..00000000000 --- a/spec/feature/automatic_case_distribution/acd_audit_history/audit_lever_history_table_spec.rb +++ /dev/null @@ -1,130 +0,0 @@ -# frozen_string_literal: true - -RSpec.feature "Audit Lever History Table" do - let!(:current_user) do - user = create(:user, css_id: "BVATTWAYNE") - CDAControlGroup.singleton.add_user(user) - User.authenticate!(user: user) - end - before { Seeds::CaseDistributionLevers.new.seed! } - - let(:ama_direct_reviews) { Constants.DISTRIBUTION.ama_direct_review_start_distribution_prior_to_goals } - let(:alternate_batch_size) { Constants.DISTRIBUTION.alternative_batch_size } - - let(:ama_direct_reviews_lever) { CaseDistributionLever.find_by_item(ama_direct_reviews) } - let(:alternate_batch_size_lever) { CaseDistributionLever.find_by_item(alternate_batch_size) } - - context "user is in Case Distro Algorithm Control organization but not an admin" do - scenario "visits the lever control page", type: :feature do - visit "case-distribution-controls" - confirm_page_and_section_loaded - end - - scenario "visits the lever control page with an audit lever history entry " do - create(:case_distribution_audit_lever_entry, - case_distribution_lever: ama_direct_reviews_lever, - previous_value: 10, - update_value: 15) - - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(find("#lever-history-table")).to have_content(current_user.css_id) - expect(find("#lever-history-table")).to have_content(ama_direct_reviews_lever.title) - expect(find("#lever-history-table")).to have_content("10 #{ama_direct_reviews_lever.unit}") - expect(find("#lever-history-table")).to have_content("15 #{ama_direct_reviews_lever.unit}") - end - - scenario "visits the lever control page with an audit two lever history entries " do - create(:case_distribution_audit_lever_entry, - case_distribution_lever: ama_direct_reviews_lever, - previous_value: 15, - update_value: 5) - - create(:case_distribution_audit_lever_entry, - case_distribution_lever: alternate_batch_size_lever, - previous_value: 7, - update_value: 6, - created_at: Time.zone.now - 1.minute) - - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(find("#lever-history-table-row-0")).to have_content(current_user.css_id) - expect(find("#lever-history-table-row-0")).to have_content(alternate_batch_size_lever.title) - expect(find("#lever-history-table-row-0")).to have_content("7 #{alternate_batch_size_lever.unit}") - expect(find("#lever-history-table-row-0")).to have_content("6 #{alternate_batch_size_lever.unit}") - - expect(find("#lever-history-table-row-1")).to have_content(current_user.css_id) - expect(find("#lever-history-table-row-1")).to have_content(ama_direct_reviews_lever.title) - expect(find("#lever-history-table-row-1")).to have_content("15 #{ama_direct_reviews_lever.unit}") - expect(find("#lever-history-table-row-1")).to have_content("5 #{ama_direct_reviews_lever.unit}") - end - - scenario "visits the lever control page with one audit lever history entry with two levers changed" do - create(:case_distribution_audit_lever_entry, - case_distribution_lever: ama_direct_reviews_lever, - previous_value: 9, - update_value: 13) - create(:case_distribution_audit_lever_entry, - case_distribution_lever: alternate_batch_size_lever, - previous_value: 2, - update_value: 4) - - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(find("#lever-history-table-row-0")).to have_content(current_user.css_id) - expect(find("#lever-history-table-row-0")).to have_content(alternate_batch_size_lever.title) - expect(find("#lever-history-table-row-0")).to have_content("2 #{alternate_batch_size_lever.unit}") - expect(find("#lever-history-table-row-0")).to have_content("4 #{alternate_batch_size_lever.unit}") - - expect(find("#lever-history-table-row-0")).to have_content(ama_direct_reviews_lever.title) - expect(find("#lever-history-table-row-0")).to have_content("9 #{ama_direct_reviews_lever.unit}") - expect(find("#lever-history-table-row-0")).to have_content("13 #{ama_direct_reviews_lever.unit}") - end - end - - context "user is a Case Distro Algorithm Control admin" do - let(:ama_direct_reviews_field) { Constants.DISTRIBUTION.ama_direct_review_docket_time_goals } - - before do - OrganizationsUser.make_user_admin(current_user, CDAControlGroup.singleton) - end - - scenario "lever history displays on page", type: :feature do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(find("#lever-history-table").has_no_content?("123 days")).to eq(true) - expect(find("#lever-history-table").has_no_content?("300 days")).to eq(true) - - fill_in ama_direct_reviews_field, with: "123" - click_save_button - click_modal_confirm_button - - expect(find("#lever-history-table").has_content?("123 days")).to eq(true) - expect(find("#lever-history-table").has_no_content?("300 days")).to eq(true) - - fill_in ama_direct_reviews_field, with: "300" - click_save_button - click_modal_confirm_button - - expect(find("#lever-history-table").has_content?("123 days")).to eq(true) - expect(find("#lever-history-table").has_content?("300 days")).to eq(true) - end - end -end - -def confirm_page_and_section_loaded - expect(page).to have_content(COPY::CASE_DISTRIBUTION_HISTORY_TITLE) - expect(page).to have_content(COPY::CASE_DISTRIBUTION_HISTORY_DESCRIPTION) -end - -def click_save_button - find("#LeversSaveButton").click -end - -def click_modal_confirm_button - find("#save-modal-confirm").click -end diff --git a/spec/feature/automatic_case_distribution/acd_levers/affinity_days_levers_spec.rb b/spec/feature/automatic_case_distribution/acd_levers/affinity_days_levers_spec.rb deleted file mode 100644 index cb215a42751..00000000000 --- a/spec/feature/automatic_case_distribution/acd_levers/affinity_days_levers_spec.rb +++ /dev/null @@ -1,83 +0,0 @@ -# frozen_string_literal: true - -RSpec.feature "Affinity Days Levers" do - before { Seeds::CaseDistributionLevers.new.seed! } - - let!(:current_user) do - user = create(:user, css_id: "BVATTWAYNE") - CDAControlGroup.singleton.add_user(user) - User.authenticate!(user: user) - end - - let(:disabled_lever_list) do - [ - Constants.DISTRIBUTION.cavc_aod_affinity_days, - Constants.DISTRIBUTION.cavc_affinity_days, - Constants.DISTRIBUTION.aoj_affinity_days, - Constants.DISTRIBUTION.aoj_aod_affinity_days, - Constants.DISTRIBUTION.aoj_cavc_affinity_days - ] - end - - let(:enabled_lever_list) do - [ - Constants.DISTRIBUTION.ama_hearing_case_affinity_days, - Constants.DISTRIBUTION.ama_hearing_case_aod_affinity_days - ] - end - - context "user is in Case Distro Algorithm Control organization but not an admin" do - scenario "visits the lever control page", type: :feature do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - disabled_lever_list.each do |item| - expect(find("#lever-wrapper-#{item}")).to match_css(".lever-disabled") - expect(find("#affinity-day-label-for-#{item}")).to match_css(".lever-disabled") - end - - enabled_lever_list.each do |item| - expect(find("#lever-wrapper-#{item}")).not_to match_css(".lever-disabled") - expect(find("#affinity-day-label-for-#{item}")).not_to match_css(".lever-disabled") - end - end - end - - context "user is a Case Distro Algorithm Control admin" do - before do - OrganizationsUser.make_user_admin(current_user, CDAControlGroup.singleton) - end - - scenario "visits the lever control page" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - option_list = [Constants.ACD_LEVERS.omit, Constants.ACD_LEVERS.infinite, Constants.ACD_LEVERS.value] - - disabled_lever_list.each do |disabled_lever| - option_list.each do |option| - expect(find("##{disabled_lever}-#{option}", visible: false)).to be_disabled - end - end - - enabled_lever_list.each do |enabled_lever| - option_list.each do |option| - expect(find("##{enabled_lever}-#{option}", visible: false)).not_to be_disabled - end - end - end - end -end - -# rubocop:disable Metrics/AbcSize -def confirm_page_and_section_loaded - expect(page).to have_content(COPY::CASE_DISTRIBUTION_AFFINITY_DAYS_H2_TITLE) - expect(page).to have_content(Constants.DISTRIBUTION.ama_hearing_case_affinity_days_title) - expect(page).to have_content(Constants.DISTRIBUTION.ama_hearing_case_aod_affinity_days_title) - expect(page).to have_content(Constants.DISTRIBUTION.cavc_affinity_days_title) - expect(page).to have_content(Constants.DISTRIBUTION.cavc_aod_affinity_days_title) - expect(page).to have_content(Constants.DISTRIBUTION.aoj_affinity_days_title) - expect(page).to have_content(Constants.DISTRIBUTION.aoj_aod_affinity_days_title) - expect(page).to have_content(Constants.DISTRIBUTION.aoj_cavc_affinity_days_title) -end -# rubocop:enable Metrics/AbcSize diff --git a/spec/feature/automatic_case_distribution/acd_levers/ama_np_dist_goals_by_docket_lever_spec.rb b/spec/feature/automatic_case_distribution/acd_levers/ama_np_dist_goals_by_docket_lever_spec.rb deleted file mode 100644 index 952483fc2ed..00000000000 --- a/spec/feature/automatic_case_distribution/acd_levers/ama_np_dist_goals_by_docket_lever_spec.rb +++ /dev/null @@ -1,82 +0,0 @@ -# frozen_string_literal: true - -RSpec.feature "AMA Non-priority Distribution Goals by Docket Levers" do - before { Seeds::CaseDistributionLevers.new.seed! } - - let!(:current_user) do - user = create(:user, css_id: "BVATTWAYNE") - CDAControlGroup.singleton.add_user(user) - User.authenticate!(user: user) - end - - let(:ama_hearings) { Constants.DISTRIBUTION.ama_hearing_start_distribution_prior_to_goals } - let(:ama_direct_reviews) { Constants.DISTRIBUTION.ama_direct_review_start_distribution_prior_to_goals } - let(:ama_evidence_submissions) { Constants.DISTRIBUTION.ama_evidence_submission_start_distribution_prior_to_goals } - - let(:ama_hearings_field) { Constants.DISTRIBUTION.ama_hearing_docket_time_goals } - let(:ama_direct_reviews_field) { Constants.DISTRIBUTION.ama_direct_review_docket_time_goals } - let(:ama_evidence_submissions_field) { Constants.DISTRIBUTION.ama_evidence_submission_docket_time_goals } - - context "user is in Case Distro Algorithm Control organization but not an admin" do - scenario "visits the lever control page", type: :feature do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(find("##{ama_hearings}-lever-value > span")["data-disabled-in-ui"]).to eq("false") - expect(find("##{ama_direct_reviews}-lever-value > span")["data-disabled-in-ui"]).to eq("false") - expect(find("##{ama_evidence_submissions}-lever-value > span")["data-disabled-in-ui"]).to eq("false") - - expect(find("##{ama_hearings}-lever-toggle > div > span")["data-disabled-in-ui"]).to eq("false") - expect(find("##{ama_direct_reviews}-lever-toggle > div > span")["data-disabled-in-ui"]).to eq("false") - expect(find("##{ama_evidence_submissions}-lever-toggle > div > span")["data-disabled-in-ui"]).to eq("false") - end - end - - context "user is a Case Distro Algorithm Control admin" do - before do - OrganizationsUser.make_user_admin(current_user, CDAControlGroup.singleton) - end - - scenario "visits the lever control page" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(page).to have_field(ama_hearings_field.to_s, disabled: false) - expect(page).to have_field(ama_direct_reviews_field.to_s) - expect(page).to have_field(ama_evidence_submissions_field.to_s, disabled: false) - - expect(page).to have_button("toggle-switch-#{ama_hearings}", disabled: false) - expect(page).to have_button("toggle-switch-#{ama_direct_reviews}", disabled: false) - expect(page).to have_button("toggle-switch-#{ama_evidence_submissions}", disabled: false) - end - - scenario "changes the AMA Direct Review lever value to an invalid input" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - empty_error_message = "Please enter a value greater than or equal to 0" - - fill_in ama_direct_reviews_field, with: "ABC" - expect(page).to have_field(ama_direct_reviews_field, with: "") - expect(find("##{ama_direct_reviews_field}-lever")).to have_content(empty_error_message) - - fill_in ama_direct_reviews_field, with: "-1" - expect(page).to have_field(ama_direct_reviews_field, with: "1") - expect(find("##{ama_direct_reviews_field}-lever").has_no_content?(empty_error_message)).to eq(true) - end - - scenario "changes the AMA Direct Review lever value to a valid input" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(page).to have_field(ama_direct_reviews_field, with: "365") - end - end -end - -def confirm_page_and_section_loaded - expect(page).to have_content(COPY::CASE_DISTRIBUTION_DOCKET_TIME_GOALS_SECTION_TITLE) - expect(page).to have_content(Constants.DISTRIBUTION.ama_hearings_section_title) - expect(page).to have_content(Constants.DISTRIBUTION.ama_direct_review_section_title) - expect(page).to have_content(Constants.DISTRIBUTION.ama_evidence_submission_section_title) -end diff --git a/spec/feature/automatic_case_distribution/acd_levers/batch_size_levers_spec.rb b/spec/feature/automatic_case_distribution/acd_levers/batch_size_levers_spec.rb deleted file mode 100644 index 31a3e5f82d5..00000000000 --- a/spec/feature/automatic_case_distribution/acd_levers/batch_size_levers_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -# frozen_string_literal: true - -RSpec.feature "Batch Size Levers" do - before { Seeds::CaseDistributionLevers.new.seed! } - let!(:current_user) do - user = create(:user, css_id: "BVATTWAYNE") - CDAControlGroup.singleton.add_user(user) - User.authenticate!(user: user) - end - - let(:alternate_batch_size) { Constants.DISTRIBUTION.alternative_batch_size } - let(:batch_size_per_attorney) { Constants.DISTRIBUTION.batch_size_per_attorney } - let(:request_more_cases_minimum) { Constants.DISTRIBUTION.request_more_cases_minimum } - - context "user is in Case Distro Algorithm Control organization but not an admin" do - scenario "visits the lever control page", type: :feature do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(find("##{alternate_batch_size} > label")).to match_css(".lever-active") - expect(find("##{batch_size_per_attorney} > label")).to match_css(".lever-active") - expect(find("##{request_more_cases_minimum} > label")).to match_css(".lever-active") - end - end - - context "user is a Case Distro Algorithm Control admin" do - before do - OrganizationsUser.make_user_admin(current_user, CDAControlGroup.singleton) - end - - scenario "visits the lever control page" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(page).to have_field("#{alternate_batch_size}-field", readonly: false) - expect(page).to have_field("#{batch_size_per_attorney}-field", readonly: false) - expect(page).to have_field("#{request_more_cases_minimum}-field", readonly: false) - end - - scenario "changes the Batch Size levers values to an valid input" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(page).not_to have_field("#{alternate_batch_size}-field", with: "42") - expect(page).not_to have_field("#{batch_size_per_attorney}-field", with: "32") - expect(page).not_to have_field("#{request_more_cases_minimum}-field", with: "25") - - fill_in "#{alternate_batch_size}-field", with: "42" - fill_in "#{batch_size_per_attorney}-field", with: "32" - fill_in "#{request_more_cases_minimum}-field", with: "25" - - expect(page).to have_field("#{alternate_batch_size}-field", with: "42") - expect(page).to have_field("#{batch_size_per_attorney}-field", with: "32") - expect(page).to have_field("#{request_more_cases_minimum}-field", with: "25") - end - - scenario "changes the Batch Size levers values to a invalid inputs" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - empty_error_message = "Please enter a value greater than or equal to 0" - - CaseDistributionLever.find_by_item(alternate_batch_size) - CaseDistributionLever.find_by_item(batch_size_per_attorney) - CaseDistributionLever.find_by_item(request_more_cases_minimum) - - fill_in "#{alternate_batch_size}-field", with: "ABC" - fill_in "#{batch_size_per_attorney}-field", with: "-1" - fill_in "#{request_more_cases_minimum}-field", with: "(*&)" - - expect(page).to have_field("#{alternate_batch_size}-field", with: "") - expect(page).to have_field("#{batch_size_per_attorney}-field", with: "1") - expect(page).to have_field("#{request_more_cases_minimum}-field", with: "") - - expect(find("##{alternate_batch_size} > div > div > span")).to have_content(empty_error_message) - expect(find("##{request_more_cases_minimum} > div > div > span")).to have_content(empty_error_message) - end - end -end - -def confirm_page_and_section_loaded - expect(page).to have_content(COPY::CASE_DISTRIBUTION_BATCH_SIZE_H2_TITLE) - expect(page).to have_content(Constants.DISTRIBUTION.alternative_batch_size_title) - expect(page).to have_content(Constants.DISTRIBUTION.batch_size_per_attorney_title) - expect(page).to have_content(Constants.DISTRIBUTION.request_more_cases_minimum_title) -end diff --git a/spec/feature/automatic_case_distribution/acd_levers/inactive_data_elements_levers_spec.rb b/spec/feature/automatic_case_distribution/acd_levers/inactive_data_elements_levers_spec.rb deleted file mode 100644 index 661f144c83b..00000000000 --- a/spec/feature/automatic_case_distribution/acd_levers/inactive_data_elements_levers_spec.rb +++ /dev/null @@ -1,88 +0,0 @@ -# frozen_string_literal: true - -RSpec.feature "Excluding Appeals by Docket Type and Priority from Automatic Case Distribution Levers" do - before { Seeds::CaseDistributionLevers.new.seed! } - let!(:current_user) do - user = create(:user, css_id: "BVATTWAYNE") - CDAControlGroup.singleton.add_user(user) - User.authenticate!(user: user) - end - - let(:maximum_direct_review_proportion) { Constants.DISTRIBUTION.maximum_direct_review_proportion } - let(:minimum_legacy_proportion) { Constants.DISTRIBUTION.minimum_legacy_proportion } - let(:nod_adjustment) { Constants.DISTRIBUTION.nod_adjustment } - let(:bust_backlog) { Constants.DISTRIBUTION.bust_backlog } - - context "user is in Case Distro Algorithm Control organization but not an admin" do - scenario "visits the lever control page", type: :feature do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - description_product_match - end - end - - context "user is a Case Distro Algorithm Control admin" do - before do - OrganizationsUser.make_user_admin(current_user, CDAControlGroup.singleton) - end - - scenario "visits the lever control page" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - description_product_match - end - - scenario "confirms the displayed values of the levers" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - maximum_direct_review_proportion_lever = CaseDistributionLever.find_by_item(maximum_direct_review_proportion) - minimum_legacy_proportion_lever = CaseDistributionLever.find_by_item(minimum_legacy_proportion) - nod_adjustment_lever = CaseDistributionLever.find_by_item(nod_adjustment) - bust_backlog_lever = CaseDistributionLever.find_by_item(bust_backlog) - - converted_maximum_direct_review_proportion_value = - (maximum_direct_review_proportion_lever.value.to_f * 100).to_i.to_s - converted_minimum_legacy_proportion_value = (minimum_legacy_proportion_lever.value.to_f * 100).to_i.to_s - converted_nod_adjustment_value = (nod_adjustment_lever.value.to_f * 100).to_i.to_s - bust_backlog_value = bust_backlog_lever.value.humanize - - expect(find("##{maximum_direct_review_proportion}-value")).to have_content( - converted_maximum_direct_review_proportion_value + maximum_direct_review_proportion_lever.unit - ) - expect(find("##{minimum_legacy_proportion}-value")).to have_content( - converted_minimum_legacy_proportion_value + minimum_legacy_proportion_lever.unit - ) - expect(find("##{nod_adjustment}-value")).to have_content( - converted_nod_adjustment_value + nod_adjustment_lever.unit - ) - expect(find("##{bust_backlog}-value")).to have_content(bust_backlog_value + bust_backlog_lever.unit) - end - end -end - -# rubocop:disable Metrics/AbcSize -def description_product_match - expect(find("##{maximum_direct_review_proportion}-description")).to match_css(".description-styling") - expect(find("##{maximum_direct_review_proportion}-product")).to match_css(".value-styling") - - expect(find("##{minimum_legacy_proportion}-description")).to match_css(".description-styling") - expect(find("##{minimum_legacy_proportion}-product")).to match_css(".value-styling") - - expect(find("##{nod_adjustment}-description")).to match_css(".description-styling") - expect(find("##{nod_adjustment}-product")).to match_css(".value-styling") - - expect(find("##{bust_backlog}-description")).to match_css(".description-styling") - expect(find("##{bust_backlog}-product")).to match_css(".value-styling") -end - -def confirm_page_and_section_loaded - expect(page).to have_content(COPY::CASE_DISTRIBUTION_STATIC_LEVERS_TITLE) - expect(page).to have_content(Constants.DISTRIBUTION.maximum_direct_review_proportion_title) - expect(page).to have_content(Constants.DISTRIBUTION.minimum_legacy_proportion_title) - expect(page).to have_content(Constants.DISTRIBUTION.nod_adjustment_title) - expect(page).to have_content(Constants.DISTRIBUTION.bust_backlog_title) -end -# rubocop:enable Metrics/AbcSize diff --git a/spec/feature/automatic_case_distribution/acd_levers/lever_buttons_spec.rb b/spec/feature/automatic_case_distribution/acd_levers/lever_buttons_spec.rb deleted file mode 100644 index bbdb850961a..00000000000 --- a/spec/feature/automatic_case_distribution/acd_levers/lever_buttons_spec.rb +++ /dev/null @@ -1,168 +0,0 @@ -# frozen_string_literal: true - -RSpec.feature "Case Distribution Controls Page Buttons" do - before { Seeds::CaseDistributionLevers.new.seed! } - - let!(:current_user) do - user = create(:user, css_id: "BVATTWAYNE") - CDAControlGroup.singleton.add_user(user) - User.authenticate!(user: user) - end - - let(:ama_direct_reviews) { Constants.DISTRIBUTION.ama_direct_review_docket_time_goals } - let(:alternate_batch_size) { Constants.DISTRIBUTION.alternative_batch_size } - - let(:ama_direct_reviews_lever) { CaseDistributionLever.find_by_item(ama_direct_reviews) } - let(:alternate_batch_size_lever) { CaseDistributionLever.find_by_item(alternate_batch_size) } - - context "user is in Case Distro Algorithm Control organization but not an admin" do - scenario "visits the lever control page", type: :feature do - visit "case-distribution-controls" - confirm_page_and_section_loaded - expect(page).not_to have_button("Cancel") - expect(page).not_to have_button("Save") - end - end - - context "user is a Case Distro Algorithm Control admin" do - let(:ama_direct_reviews_field) { Constants.DISTRIBUTION.ama_direct_review_docket_time_goals } - let(:alternative_batch_size_field) { "#{Constants.DISTRIBUTION.alternative_batch_size}-field" } - - before do - OrganizationsUser.make_user_admin(current_user, CDAControlGroup.singleton) - ama_direct_reviews_lever.value = 100 - alternate_batch_size_lever.value = 10 - ama_direct_reviews_lever.save - alternate_batch_size_lever.save - end - - scenario "visits the lever control page", type: :feature do - visit "case-distribution-controls" - confirm_page_and_section_loaded - expect(page).to have_button("Cancel") - expect(page).to have_button("Save", disabled: true) - end - - scenario "changes a lever and then cancels the change" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(page).to have_field(ama_direct_reviews_field, with: "100") - - fill_in ama_direct_reviews_field, with: "123" - expect(page).to have_field(ama_direct_reviews_field, with: "123") - - click_cancel_button - expect(page).to have_field(ama_direct_reviews_field, with: "100") - end - - scenario "changes two levers and then cancels the change" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(page).to have_field(ama_direct_reviews_field, with: "100") - expect(page).to have_field(alternative_batch_size_field, with: "10") - - fill_in ama_direct_reviews_field, with: "123" - fill_in alternative_batch_size_field, with: "12" - expect(page).to have_field(ama_direct_reviews_field, with: "123") - expect(page).to have_field(alternative_batch_size_field, with: "12") - - click_cancel_button - expect(page).to have_field(ama_direct_reviews_field, with: "100") - expect(page).to have_field(alternative_batch_size_field, with: "10") - end - - scenario "changes a lever and then hits save" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(page).to have_field(ama_direct_reviews_field, with: "100") - - fill_in ama_direct_reviews_field, with: "123" - expect(page).to have_field(ama_direct_reviews_field, with: "123") - - click_save_button - expect(find("#case-distribution-control-modal-table-0")).to have_content("123") - end - - scenario "changes two levers and then hits save" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(page).to have_field(ama_direct_reviews_field, with: "100") - expect(page).to have_field(alternative_batch_size_field, with: "10") - - fill_in ama_direct_reviews_field, with: "123" - fill_in alternative_batch_size_field, with: "13" - expect(page).to have_field(ama_direct_reviews_field, with: "123") - expect(page).to have_field(alternative_batch_size_field, with: "13") - - click_save_button - expect(find("#case-distribution-control-modal-table-0")).to have_content("13") - expect(find("#case-distribution-control-modal-table-1")).to have_content("123") - end - - scenario "changes two levers and cancels on the modal screen" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(page).to have_field(ama_direct_reviews_field, with: "100") - expect(page).to have_field(alternative_batch_size_field, with: "10") - - fill_in ama_direct_reviews_field, with: "123" - fill_in alternative_batch_size_field, with: "13" - expect(page).to have_field(ama_direct_reviews_field, with: "123") - expect(page).to have_field(alternative_batch_size_field, with: "13") - - click_save_button - expect(find("#case-distribution-control-modal-table-0")).to have_content("13") - expect(find("#case-distribution-control-modal-table-1")).to have_content("123") - - click_modal_cancel_button - expect(page).to have_field(ama_direct_reviews_field, with: "123") - expect(page).to have_field(alternative_batch_size_field, with: "13") - end - - scenario "changes two levers and confirms on the modal screen" do - visit "case-distribution-controls" - confirm_page_and_section_loaded - - expect(page).to have_field(ama_direct_reviews_field, with: "100") - expect(page).to have_field(alternative_batch_size_field, with: "10") - - fill_in ama_direct_reviews_field, with: "123" - fill_in alternative_batch_size_field, with: "13" - expect(page).to have_field(ama_direct_reviews_field, with: "123") - expect(page).to have_field(alternative_batch_size_field, with: "13") - - click_save_button - expect(find("#case-distribution-control-modal-table-0")).to have_content("13") - expect(find("#case-distribution-control-modal-table-1")).to have_content("123") - - click_modal_confirm_button - expect(page).to have_field(ama_direct_reviews_field, with: "123") - expect(page).to have_field(alternative_batch_size_field, with: "13") - end - end -end - -def confirm_page_and_section_loaded - expect(page).to have_content(COPY::CASE_DISTRIBUTION_TITLE) -end - -def click_cancel_button - find("#CancelLeversButton").click -end - -def click_save_button - find("#LeversSaveButton").click -end - -def click_modal_cancel_button - find("#save-modal-cancel").click -end - -def click_modal_confirm_button - find("#save-modal-confirm").click -end diff --git a/spec/feature/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb new file mode 100644 index 00000000000..a52390941d7 --- /dev/null +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -0,0 +1,205 @@ +# frozen_string_literal: true + +RSpec.feature "Admin UI" do + before { Seeds::CaseDistributionLevers.new.seed! } + + let!(:current_user) do + user = create(:user, css_id: "BVATTWAYNE") + CDAControlGroup.singleton.add_user(user) + User.authenticate!(user: user) + end + + let(:disabled_lever_list) do + [ + Constants.DISTRIBUTION.cavc_aod_affinity_days, + Constants.DISTRIBUTION.cavc_affinity_days, + Constants.DISTRIBUTION.aoj_affinity_days, + Constants.DISTRIBUTION.aoj_aod_affinity_days, + Constants.DISTRIBUTION.aoj_cavc_affinity_days + ] + end + + let(:enabled_lever_list) do + [ + Constants.DISTRIBUTION.ama_hearing_case_affinity_days, + Constants.DISTRIBUTION.ama_hearing_case_aod_affinity_days + ] + end + + let(:ama_hearings) { Constants.DISTRIBUTION.ama_hearing_start_distribution_prior_to_goals } + let(:ama_direct_reviews) { Constants.DISTRIBUTION.ama_direct_review_start_distribution_prior_to_goals } + let(:ama_evidence_submissions) { Constants.DISTRIBUTION.ama_evidence_submission_start_distribution_prior_to_goals } + + let(:ama_hearings_field) { Constants.DISTRIBUTION.ama_hearing_docket_time_goals } + let(:ama_direct_reviews_field) { Constants.DISTRIBUTION.ama_direct_review_docket_time_goals } + let(:ama_evidence_submissions_field) { Constants.DISTRIBUTION.ama_evidence_submission_docket_time_goals } + + let(:alternate_batch_size) { Constants.DISTRIBUTION.alternative_batch_size } + let(:batch_size_per_attorney) { Constants.DISTRIBUTION.batch_size_per_attorney } + let(:request_more_cases_minimum) { Constants.DISTRIBUTION.request_more_cases_minimum } + + let(:ama_direct_reviews_lever) { CaseDistributionLever.find_by_item(ama_direct_reviews) } + let(:alternate_batch_size_lever) { CaseDistributionLever.find_by_item(alternate_batch_size) } + + let(:maximum_direct_review_proportion) { Constants.DISTRIBUTION.maximum_direct_review_proportion } + let(:minimum_legacy_proportion) { Constants.DISTRIBUTION.minimum_legacy_proportion } + let(:nod_adjustment) { Constants.DISTRIBUTION.nod_adjustment } + let(:bust_backlog) { Constants.DISTRIBUTION.bust_backlog } + + let(:alternative_batch_size_field) { "#{Constants.DISTRIBUTION.alternative_batch_size}-field" } + + context "user is a Case Distro Algorithm Control admin" do + before do + OrganizationsUser.make_user_admin(current_user, CDAControlGroup.singleton) + end + + it "the lever control page operates correctly" do + visit "case-distribution-controls" + expect(page).to have_content("Case Distribution Algorithm Values") + + EMPTY_ERROR_MESSAGE = "Please enter a value greater than or equal to 0" + + step "enabled and disabled levers display correctly" do + # From affinity_days_levers_spec.rb + option_list = [Constants.ACD_LEVERS.omit, Constants.ACD_LEVERS.infinite, Constants.ACD_LEVERS.value] + + disabled_lever_list.each do |disabled_lever| + option_list.each do |option| + expect(find("##{disabled_lever}-#{option}", visible: false)).to be_disabled + end + end + + enabled_lever_list.each do |enabled_lever| + option_list.each do |option| + expect(find("##{enabled_lever}-#{option}", visible: false)).not_to be_disabled + end + end + end + + step "levers initally are enabled and display correctly" do + expect(page).to have_field(ama_hearings_field.to_s, disabled: false) + expect(page).to have_field(ama_direct_reviews_field.to_s) + expect(page).to have_field(ama_evidence_submissions_field.to_s, disabled: false) + + expect(page).to have_button("toggle-switch-#{ama_hearings}", disabled: false) + expect(page).to have_button("toggle-switch-#{ama_direct_reviews}", disabled: false) + expect(page).to have_button("toggle-switch-#{ama_evidence_submissions}", disabled: false) + end + + step "inactive levers are displayed with values" do + expect(find("##{maximum_direct_review_proportion}-value")).to have_content("7%") + expect(find("##{minimum_legacy_proportion}-value")).to have_content("90%") + expect(find("##{nod_adjustment}-value")).to have_content("40%") + expect(find("##{bust_backlog}-value")).to have_content("True") + end + + step "cancelling lever changes resets values" do + # Capybara locally is not setting clearing the field prior to entering the new value so fill with "" + fill_in ama_direct_reviews_field, with: "" + + fill_in ama_direct_reviews_field, with: "123" + expect(page).to have_field(ama_direct_reviews_field, with: "123") + click_cancel_button + expect(page).to have_field(ama_direct_reviews_field, with: "365") + + fill_in ama_direct_reviews_field, with: "123" + fill_in alternative_batch_size_field, with: "" + fill_in alternative_batch_size_field, with: "12" + expect(page).to have_field(ama_direct_reviews_field, with: "123") + expect(page).to have_field(alternative_batch_size_field, with: "12") + + click_cancel_button + expect(page).to have_field(ama_direct_reviews_field, with: "365") + expect(page).to have_field(alternative_batch_size_field, with: "15") + end + + step "cancelling changes on confirm modal returns user to page without resetting the values in the fields" do + fill_in ama_direct_reviews_field, with: "123" + fill_in alternative_batch_size_field, with: "13" + expect(page).to have_field(ama_direct_reviews_field, with: "123") + expect(page).to have_field(alternative_batch_size_field, with: "13") + + click_save_button + expect(find("#case-distribution-control-modal-table-0")).to have_content("13") + expect(find("#case-distribution-control-modal-table-1")).to have_content("123") + + click_modal_cancel_button + expect(page).to have_field(ama_direct_reviews_field, with: "123") + expect(page).to have_field(alternative_batch_size_field, with: "13") + end + + step "error displays for invalid input on time goals section" do + fill_in ama_direct_reviews_field, with: "ABC" + expect(page).to have_field(ama_direct_reviews_field, with: "") + expect(find("##{ama_direct_reviews_field}-lever")).to have_content(EMPTY_ERROR_MESSAGE) + + fill_in ama_direct_reviews_field, with: "-1" + expect(page).to have_field(ama_direct_reviews_field, with: "1") + expect(find("##{ama_direct_reviews_field}-lever").has_no_content?(EMPTY_ERROR_MESSAGE)).to eq(true) + end + + step "time goals section error clears with valid input" do + expect(find("#lever-history-table").has_no_content?("123 days")).to eq(true) + expect(find("#lever-history-table").has_no_content?("300 days")).to eq(true) + + # Change two levers at once to satisfy a previously separate test + fill_in ama_direct_reviews_field, with: "" + fill_in ama_direct_reviews_field, with: "123" + fill_in ama_evidence_submissions_field, with: "456" + click_save_button + click_modal_confirm_button + expect(page).to have_content(COPY::CASE_DISTRIBUTION_SUCCESS_BANNER_TITLE) + end + + step "lever history displays on page" do + expect(page.find("#lever-history-table").has_content?("15 cases")).to be true + expect(page.find("#lever-history-table").has_content?("365 days")).to be true + expect(page.find("#lever-history-table").has_content?("550 days")).to be true + expect(page.find("#lever-history-table").has_content?("13 cases")).to be true + expect(page.find("#lever-history-table").has_content?("123 days")).to be true + expect(page.find("#lever-history-table").has_content?("456 days")).to be true + end + + step "batch size lever section errors display with invalid inputs" do + expect(page).to have_field("#{alternate_batch_size}-field", readonly: false) + expect(page).to have_field("#{batch_size_per_attorney}-field", readonly: false) + expect(page).to have_field("#{request_more_cases_minimum}-field", readonly: false) + + fill_in "#{alternate_batch_size}-field", with: "ABC" + fill_in "#{batch_size_per_attorney}-field", with: "-1" + fill_in "#{request_more_cases_minimum}-field", with: "(*&)" + + expect(page).to have_field("#{alternate_batch_size}-field", with: "") + expect(page).to have_field("#{batch_size_per_attorney}-field", with: "1") + expect(page).to have_field("#{request_more_cases_minimum}-field", with: "") + + expect(find("##{alternate_batch_size} > div > div > span")).to have_content(EMPTY_ERROR_MESSAGE) + expect(find("##{request_more_cases_minimum} > div > div > span")).to have_content(EMPTY_ERROR_MESSAGE) + end + + step "batch size lever section errors clear with valid inputs" do + fill_in "#{alternate_batch_size}-field", with: "42" + fill_in "#{batch_size_per_attorney}-field", with: "32" + fill_in "#{request_more_cases_minimum}-field", with: "25" + + expect(page).not_to have_content(EMPTY_ERROR_MESSAGE) + end + end + end + + def click_save_button + find("#LeversSaveButton").click + end + + def click_modal_confirm_button + find("#save-modal-confirm").click + end + + def click_cancel_button + find("#CancelLeversButton").click + end + + def click_modal_cancel_button + find("#save-modal-cancel").click + end +end diff --git a/spec/feature/intake/appeal/edit_spec.rb b/spec/feature/intake/appeal/edit_spec.rb index 0977e38aaba..e8fa74a765c 100644 --- a/spec/feature/intake/appeal/edit_spec.rb +++ b/spec/feature/intake/appeal/edit_spec.rb @@ -18,9 +18,7 @@ last_name: "Merica") end - let!(:current_user) do - User.authenticate!(roles: ["Mail Intake"]) - end + let!(:current_user) { User.authenticate!(roles: ["Mail Intake"]) } let!(:non_comp_org) { create(:business_line, name: "Non-Comp Org", url: "nco") } let(:last_week) { Time.zone.now - 7.days } @@ -83,106 +81,152 @@ let!(:rating_request_issue) { create(:request_issue, rating_request_issue_attributes) } - scenario "allows adding/removing issues" do - visit "appeals/#{appeal.uuid}/edit/" + # This veteran and appeal are a "blank canvas" with no request issues or pre-existing ratings/issues + let(:vet_no_history) { create(:veteran) } + let(:appeal3) do + create(:appeal, + veteran_file_number: vet_no_history.file_number, + receipt_date: receipt_date, + docket_type: Constants.AMA_DOCKETS.evidence_submission, + veteran_is_not_claimant: false, + legacy_opt_in_approved: legacy_opt_in_approved).tap(&:create_tasks_on_intake_success!) + end - expect(page).to have_content(nonrating_request_issue.description) + scenario "Add, edit, and remove request issues" do + step "allows adding/removing issues" do + visit "appeals/#{appeal.uuid}/edit/" - # remove an issue - click_remove_intake_issue_dropdown(nonrating_request_issue.description) - expect(page.has_no_content?(nonrating_request_issue.description)).to eq(true) - expect(page).to have_content("When you finish making changes, click \"Save\" to continue") + expect(page).to have_content(nonrating_request_issue.description) - # add a different issue - click_intake_add_issue - add_intake_rating_issue("Left knee granted") - # save flash should still occur because issues are different - expect(page).to have_content("When you finish making changes, click \"Save\" to continue") + # remove an issue + click_remove_intake_issue_dropdown(nonrating_request_issue.description) + expect(page.has_no_content?(nonrating_request_issue.description)).to eq(true) + expect(page).to have_content("When you finish making changes, click \"Save\" to continue") - # save - expect(page).to have_content("Left knee granted") - safe_click("#button-submit-update") + # add a different issue + click_intake_add_issue + add_intake_rating_issue("Left knee granted") + # save flash should still occur because issues are different + expect(page).to have_content("When you finish making changes, click \"Save\" to continue") - # should redirect to queue - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") + # save + expect(page).to have_content("Left knee granted") + safe_click("#button-submit-update") - # going back to edit page should show those issues - visit "appeals/#{appeal.uuid}/edit/" - expect(page).to have_content("Left knee granted") - expect(page.has_no_content?("nonrating description")).to eq(true) + # should redirect to queue + expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") + expect(page).to have_content("added 1 issue") + expect(page).to have_content("removed 1 issue") - # canceling should redirect to queue - click_on "Cancel" - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") - end + # going back to edit page should show those issues + visit "appeals/#{appeal.uuid}/edit/" + expect(page).to have_content("Left knee granted") + expect(page.has_no_content?("nonrating description")).to eq(true) - scenario "allows removing and re-adding same issue" do - issue_description = rating_request_issue.description - - visit "appeals/#{appeal.uuid}/edit/" - - expect(page).to have_content(issue_description) - expect(page).to have_button("Save", disabled: true) - # remove - click_remove_intake_issue_dropdown(issue_description) - expect(page.has_no_content?(issue_description)).to eq(true) - expect(page).to have_content("When you finish making changes, click \"Save\" to continue") - - # re-add - click_intake_add_issue - add_intake_rating_issue(issue_description, "a new comment") - expect(page).to have_content(issue_description) - expect(page).to_not have_content( - Constants.INELIGIBLE_REQUEST_ISSUES.duplicate_of_rating_issue_in_active_review.gsub("{review_title}", "Appeal") - ) - expect(page).to have_content("When you finish making changes, click \"Save\" to continue") - - # issue note was added - expect(page).to have_button("Save", disabled: false) - end + # canceling should redirect to queue + click_on "Cancel" + expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") + end + + step "allows removing and re-adding same issue" do + issue_description = rating_request_issue.description - scenario "when selecting a new benefit type the issue category dropdown should return to a default state" do - new_vet = create(:veteran, first_name: "Ed", last_name: "Merica") - new_appeal = create(:appeal, - veteran_file_number: new_vet.file_number, - receipt_date: receipt_date, - docket_type: Constants.AMA_DOCKETS.evidence_submission, - veteran_is_not_claimant: false, - legacy_opt_in_approved: legacy_opt_in_approved).tap(&:create_tasks_on_intake_success!) + visit "appeals/#{appeal.uuid}/edit/" - visit "appeals/#{new_appeal.uuid}/edit/" + expect(page).to have_content(issue_description) + expect(page).to have_button("Save", disabled: true) + # remove + click_remove_intake_issue_dropdown(issue_description) + expect(page.has_no_content?(issue_description)).to eq(true) + expect(page).to have_content("When you finish making changes, click \"Save\" to continue") - click_intake_add_issue + # re-add + click_intake_add_issue + add_intake_rating_issue(issue_description, "a new comment") + expect(page).to have_content(issue_description) + expect(page).to_not have_content( + Constants.INELIGIBLE_REQUEST_ISSUES.duplicate_of_rating_issue_in_active_review.gsub("{review_title}", "Appeal") + ) + expect(page).to have_content("When you finish making changes, click \"Save\" to continue") - dropdown_select_string = "Select or enter..." - benefit_text = "Compensation" + # issue note was added + expect(page).to have_button("Save", disabled: false) + end - # Select the first benefit type - all(".cf-select__control", text: dropdown_select_string).first.click - find("div", class: "cf-select__option", text: benefit_text).click + step "when selecting a new benefit type the issue category dropdown should return to a default state" do + visit "appeals/#{appeal3.uuid}/edit/" - # Select the first issue category - find(".cf-select__control", text: dropdown_select_string).click - find("div", class: "cf-select__option", text: "Unknown Issue Category").click + click_intake_add_issue - # Verify that the default dropdown text is missing from the page - expect(page).to_not have_content(dropdown_select_string) + dropdown_select_string = "Select or enter..." + benefit_text = "Compensation" - # Select a different benefit type - find(".cf-select__control", text: benefit_text).click - find("div", class: "cf-select__option", text: "Education").click + # Select the first benefit type + all(".cf-select__control", text: dropdown_select_string).first.click + find("div", class: "cf-select__option", text: benefit_text).click - # Verify that the default dropdown text once again present on the page - expect(page).to have_content(dropdown_select_string) - end + # Select the first issue category + find(".cf-select__control", text: dropdown_select_string).click + find("div", class: "cf-select__option", text: "Unknown Issue Category").click - context "with remove decision review enabled" do - scenario "allows all request issues to be removed and saved" do + # Verify that the default dropdown text is missing from the page + expect(page).to_not have_content(dropdown_select_string) + + # Select a different benefit type + find(".cf-select__control", text: benefit_text).click + find("div", class: "cf-select__option", text: "Education").click + + # Verify that the default dropdown text once again present on the page + expect(page).to have_content(dropdown_select_string) + end + + # this validates a bug fix from https://github.com/department-of-veterans-affairs/caseflow/pull/10197 + step "adding an issue with a non-comp benefit type returns to case details page" do + visit "appeals/#{appeal.uuid}/edit/" + + # Add issue that is not a VBMS issue + click_intake_add_issue + click_intake_no_matching_issues + add_intake_nonrating_issue( + benefit_type: "Education", + category: "Accrued", + description: "Description for Accrued", + date: 1.day.ago.to_date.mdY + ) + + expect(page).to_not have_content("Check the Veteran's profile for invalid information") + expect(page).to have_button("Save", disabled: false) + + click_edit_submit_and_confirm + expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") + page.find("a", text: "refresh the page").click if page.has_text?("Unable to load this case") + expect(page).not_to have_content("Loading this case") + expect(page).to have_content(veteran.name) + expect(RequestIssue.find_by( + benefit_type: "education", + decision_review: appeal + )).to_not be_nil + end + + # originally added in https://github.com/department-of-veterans-affairs/caseflow/pull/10241 + step "allows all request issues to be removed and saved and cancels all active tasks" do visit "appeals/#{appeal.uuid}/edit/" + + # A VeteranRecordRequest task is added when the non-comp request issue is added. Complete it + # to ensure that cancelling the appeal does not update its status to 'cancelled' later on + appeal.tasks.where(type: VeteranRecordRequest.name).first.completed! + # remove all issues click_remove_intake_issue_dropdown("PTSD denied") - click_remove_intake_issue_dropdown("Military Retired Pay") + click_remove_intake_issue_dropdown("Left knee granted") + click_remove_intake_issue_dropdown("Accrued") expect(page).to have_button("Save", disabled: false) + click_edit_submit_and_confirm + + expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") + expect(appeal.tasks.filter(&:open?).any?).to eq false + expect(appeal.tasks.where(type: VeteranRecordRequest.name).first.status).to eq(Constants.TASK_STATUSES.completed) + expect(appeal.tasks.map(&:closed_at)).to match_array([Time.zone.now, Time.zone.now, Time.zone.now, Time.zone.now]) end end @@ -347,501 +391,284 @@ end end - def add_contested_claim_issue - click_intake_add_issue - click_intake_no_matching_issues - - # add the cc issue - dropdown_select_string = "Select or enter..." - benefit_text = "Insurance" - - # Select the benefit type - all(".cf-select__control", text: dropdown_select_string).first.click - find("div", class: "cf-select__option", text: benefit_text).click - - # Select the issue category - find(".cf-select__control", text: dropdown_select_string).click - find("div", class: "cf-select__option", text: "Contested Death Claim | Intent of Insured").click - - # fill in date and issue description - fill_in "Decision date", with: 1.day.ago.to_date.mdY.to_s - fill_in "Issue description", with: "CC Instructions" - - # click buttons - click_on "Add this issue" - click_on "Save" - click_on "Confirm" - end - - context "A contested claim is added to an evidence submission appeal" do - let!(:cc_appeal) do - create(:appeal, - veteran_file_number: veteran.file_number, - receipt_date: receipt_date, - docket_type: Constants.AMA_DOCKETS.evidence_submission, - veteran_is_not_claimant: false, - legacy_opt_in_approved: legacy_opt_in_approved).tap(&:create_tasks_on_intake_success!) - end - - before do - User.authenticate!(user: current_user) - FeatureToggle.enable!(:cc_appeal_workflow) - FeatureToggle.enable!(:indicator_for_contested_claims) - FeatureToggle.enable!(:indicator_for_contested_claims) - ClerkOfTheBoard.singleton - end - - scenario "the cc_appeal_workflow feature toggle is not enabled" do - FeatureToggle.disable!(:cc_appeal_workflow) - visit("/appeals/#{cc_appeal.uuid}/edit") - add_contested_claim_issue - - assert page.has_content?("You have successfully added 1 issue") - expect(cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").nil?).to be true - end - - scenario "a cc issue is assigned to an evidence submission appeal" do - visit("/appeals/#{cc_appeal.uuid}/edit") - add_contested_claim_issue - - assert page.has_content?("You have successfully added 1 issue") - expect(cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").nil?).to be false - expect( - cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").parent - ).to eql(cc_appeal.tasks.find_by(type: "EvidenceSubmissionWindowTask")) - expect( - cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").assigned_to - ).to eql(ClerkOfTheBoard.singleton) - expect( - cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").assigned_by - ).to eql(current_user) - end - end - - context "A contested claim is added to an hearing appeal" do - let!(:cc_appeal) do - create(:appeal, - veteran_file_number: veteran.file_number, - receipt_date: receipt_date, - docket_type: Constants.AMA_DOCKETS.hearing, - veteran_is_not_claimant: false, - legacy_opt_in_approved: legacy_opt_in_approved).tap(&:create_tasks_on_intake_success!) - end - - before do - User.authenticate!(user: current_user) - FeatureToggle.enable!(:cc_appeal_workflow) - FeatureToggle.enable!(:indicator_for_contested_claims) - FeatureToggle.enable!(:indicator_for_contested_claims) - ClerkOfTheBoard.singleton - end - - scenario "a cc issue is assigned to a hearing appeal" do - visit("/appeals/#{cc_appeal.uuid}/edit") - add_contested_claim_issue - - assert page.has_content?("You have successfully added 1 issue") - expect(cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").nil?).to be false - expect( - cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").parent - ).to eql(cc_appeal.tasks.find_by(type: "ScheduleHearingTask")) - expect( - cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").assigned_to - ).to eql(ClerkOfTheBoard.singleton) - expect( - cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").assigned_by - ).to eql(current_user) - end - end - - context "A contested claim is added to a direct review appeal" do - let!(:cc_appeal) do - create(:appeal, - veteran_file_number: veteran.file_number, - receipt_date: receipt_date, - docket_type: Constants.AMA_DOCKETS.direct_review, - veteran_is_not_claimant: false, - legacy_opt_in_approved: legacy_opt_in_approved).tap(&:create_tasks_on_intake_success!) - end - + context "User is a member of the Supervisory Senior Council" do before do User.authenticate!(user: current_user) - FeatureToggle.enable!(:cc_appeal_workflow) - FeatureToggle.enable!(:indicator_for_contested_claims) - FeatureToggle.enable!(:indicator_for_contested_claims) - ClerkOfTheBoard.singleton - end - - scenario "a cc issue is assigned to a direct review appeal" do - visit("/appeals/#{cc_appeal.uuid}/edit") - add_contested_claim_issue - - assert page.has_content?("You have successfully added 1 issue") - expect(cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").nil?).to be false - expect( - cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").parent - ).to eql(cc_appeal.tasks.find_by(type: "DistributionTask")) - expect( - cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").assigned_to - ).to eql(ClerkOfTheBoard.singleton) - expect( - cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask").assigned_by - ).to eql(current_user) - end - end - - context "A cc issue is added to a cc appeal with the initial letter task" do - let!(:cc_appeal) do - create(:appeal, - veteran_file_number: veteran.file_number, - receipt_date: receipt_date, - docket_type: Constants.AMA_DOCKETS.direct_review, - veteran_is_not_claimant: false, - legacy_opt_in_approved: legacy_opt_in_approved).tap(&:create_tasks_on_intake_success!) + FeatureToggle.enable!(:split_appeal_workflow) + OrganizationsUser.make_user_admin(current_user, SupervisorySeniorCouncil.singleton) end - let(:initial_letter_task) do - SendInitialNotificationLetterTask.create!( - appeal: cc_appeal, - parent: appeal.tasks.find_by(type: "DistributionTask"), - assigned_to: ClerkOfTheBoard.singleton, - assigned_by: current_user - ) - end + after { FeatureToggle.disable!(:split_appeal_workflow) } - before do - User.authenticate!(user: current_user) - FeatureToggle.enable!(:cc_appeal_workflow) - FeatureToggle.enable!(:indicator_for_contested_claims) - FeatureToggle.enable!(:indicator_for_contested_claims) - ClerkOfTheBoard.singleton + scenario "less than 2 request issues on the appeal, the split appeal button doesn't show" do + visit "appeals/#{appeal2.uuid}/edit/" + expect(appeal2.decision_issues.length + appeal2.request_issues.length).to be < 2 + expect(page).to_not have_button("Split appeal") end - scenario "if the first task is open, a 2nd SendInitialNotificationLetterTask is not created" do - visit("/appeals/#{cc_appeal.uuid}/edit") - add_contested_claim_issue + context "and the appeal has 2 or more tasks" do + let!(:request_issue_1) do + create(:request_issue, + id: 22, + decision_review: appeal2, + decision_date: profile_date, + contested_rating_issue_reference_id: "def456", + contested_rating_issue_profile_date: profile_date, + contested_issue_description: "PTSD denied", + contention_reference_id: "3897", + benefit_type: "Education") + end - assert page.has_content?("You have successfully added 1 issue") - expect(cc_appeal.reload.tasks.where(type: "SendInitialNotificationLetterTask").count).to eq 1 - # expect(cc_appeal.reload.tasks.find_by(type: "SendInitialNotificationLetterTask")).to be initial_letter_task - end + let!(:request_issue_2) do + create(:request_issue, + id: 25, + decision_review: appeal2, + decision_date: profile_date, + contested_rating_issue_reference_id: "blah1234", + contested_rating_issue_profile_date: profile_date, + contested_issue_description: "Other Issue Description", + contention_reference_id: "78910", + benefit_type: "Education") + end - scenario "if the first task is completed, a new SendInitialNotificationLetterTask is created" do - initial_letter_task.completed! + scenario "Split appeal page behavior" do + step "SSC user navigates to the split appeal page" do + visit "appeals/#{appeal2.uuid}/edit/" - visit("/appeals/#{cc_appeal.uuid}/edit") - add_contested_claim_issue + expect(page).to have_button("Split appeal") + # clicking the button takes the user to the next page + click_button("Split appeal") - assert page.has_content?("You have successfully added 1 issue") - expect(cc_appeal.reload.tasks.where(type: "SendInitialNotificationLetterTask").count).to eq 2 - expect(cc_appeal.reload.tasks.where( - type: "SendInitialNotificationLetterTask" - ).where(status: "assigned").count).to eq 1 - end + expect(page).to have_current_path("/appeals/#{appeal2.uuid}/edit/create_split") + end - scenario "if the first task is cancelled, a new SendInitialNotificationLetterTask is created" do - initial_letter_task.cancelled! + step "The split appeal page contains the appropriate information" do + expect(page).to have_content("PTSD denied") + expect(page).to have_content("Other Issue Description") - visit("/appeals/#{cc_appeal.uuid}/edit") - add_contested_claim_issue + # expect the select bar, cancel button, and continue button to show + expect(page).to have_content("Select...") + expect(page).to have_content("Cancel") - assert page.has_content?("You have successfully added 1 issue") - expect(cc_appeal.reload.tasks.where(type: "SendInitialNotificationLetterTask").count).to eq 2 - expect(cc_appeal.reload.tasks.where( - type: "SendInitialNotificationLetterTask" - ).where(status: "assigned").count).to eq 1 - end - end + # expect the continue button to be disabled + expect(page).to have_button("Continue", disabled: true) - context "User is a member of the Supervisory Senior Council" do - let!(:organization) { SupervisorySeniorCouncil.singleton } - let!(:current_user) { create(:user, roles: ["Mail Intake"]) } - let!(:organization_user) { OrganizationsUser.make_user_admin(current_user, organization) } - scenario "less than 2 request issues on the appeal, the split appeal button doesn't show" do - User.authenticate!(user: current_user) - visit "appeals/#{appeal2.uuid}/edit/" - expect(appeal2.decision_issues.length + appeal2.request_issues.length).to be < 2 - expect(page).to_not have_button("Split appeal") - end - end + # The cancel button goes back to the edit page + click_button("Cancel") + expect(page).to have_current_path("/queue/appeals/#{appeal2.uuid}") + end - context "The user is a member of Supervisory Senior Council and the appeal has 2 or more tasks" do - let!(:organization) { SupervisorySeniorCouncil.singleton } - let!(:current_user) { create(:user, roles: ["Mail Intake"]) } - let!(:organization_user) { OrganizationsUser.make_user_admin(current_user, organization) } - let!(:request_issue_1) do - create(:request_issue, - id: 22, - decision_review: appeal2, - decision_date: profile_date, - contested_rating_issue_reference_id: "def456", - contested_rating_issue_profile_date: profile_date, - contested_issue_description: "PTSD denied", - contention_reference_id: "3897", - benefit_type: "Education") - end + step "If no issues and no reason are selected on the split appeal page, the Continue button is disabled" do + visit("/appeals/#{appeal2.uuid}/edit/create_split") - let!(:request_issue_2) do - create(:request_issue, - id: 25, - decision_review: appeal2, - decision_date: profile_date, - contested_rating_issue_reference_id: "blah1234", - contested_rating_issue_profile_date: profile_date, - contested_issue_description: "Other Issue Description", - contention_reference_id: "78910", - benefit_type: "Education") - end + # expect issue descriptions to display + expect(page).to have_content("PTSD denied") + expect(page).to have_content("Other Issue Description") + expect(page).to have_content("Select...") + expect(page).to have_button("Continue", disabled: true) + end - before do - # Login with the user - User.authenticate!(user: current_user) - FeatureToggle.enable!(:split_appeal_workflow) - end + step "If a reason is selected the button remains disabled" do + find(:css, ".cf-select").select_option + find(:css, ".cf-select__menu").click + expect(page).to have_button("Continue", disabled: true) + end - after do - FeatureToggle.disable!(:split_appeal_workflow) - end + step "If an issue is selected and then de-selected the Continue button behaves correctly" do + find("label", text: "PTSD denied").click + expect(page).to have_button("Continue", disabled: false) + find("label", text: "PTSD denied").click + expect(page).to have_button("Continue", disabled: true) + end - scenario "Split appeal page behavior" do - step "SSC user navigates to the split appeal page" do - visit "appeals/#{appeal2.uuid}/edit/" + step "If all issues are selected on the split appeal page, the Continue button is disabled" do + find("label", text: "PTSD denied").click + find("label", text: "Other Issue Description").click - expect(page).to have_button("Split appeal") - # clicking the button takes the user to the next page - click_button("Split appeal") + expect(page).to have_button("Continue", disabled: true) + end - expect(page).to have_current_path("/appeals/#{appeal2.uuid}/edit/create_split") + step "The SSC user navigates to the split appeal page to review page" do + find("label", text: "PTSD denied").click + click_button("Continue") + expect(page).to have_content("Reason for new appeal stream:") + expect(page).to have_current_path("/appeals/#{appeal2.uuid}/edit/review_split") + end end - step "The split appeal page contains the appropriate information" do + def skill_form(appeal) + visit("/appeals/#{appeal.uuid}/edit/create_split") + + # expect issue descritions to display expect(page).to have_content("PTSD denied") expect(page).to have_content("Other Issue Description") - - # expect the select bar, cancel button, and continue button to show + find("label", text: "PTSD denied").click expect(page).to have_content("Select...") - expect(page).to have_content("Cancel") - # expect the continue button to be disabled - expect(page).to have_button("Continue", disabled: true) + find(:css, ".cf-select").select_option + find(:css, ".cf-select__menu").click - # The cancel button goes back to the edit page - click_button("Cancel") - expect(page).to have_current_path("/queue/appeals/#{appeal2.uuid}") + click_button("Continue") + expect(page).to have_current_path("/appeals/#{appeal.uuid}/edit/review_split") end - step "If no issues and no reason are selected on the split appeal page, the Continue button is disabled" do - visit("/appeals/#{appeal2.uuid}/edit/create_split") + def specialty_case_team_split_form(appeal) + visit("/appeals/#{appeal.uuid}/edit/create_split") - # expect issue descriptions to display + # expect issue descritions to display expect(page).to have_content("PTSD denied") expect(page).to have_content("Other Issue Description") + expect(page).to have_content("CHAMPVA Split Issue") + find("label", text: "CHAMPVA Split Issue").click expect(page).to have_content("Select...") - expect(page).to have_button("Continue", disabled: true) - end - step "If a reason is selected the button remains disabled" do find(:css, ".cf-select").select_option find(:css, ".cf-select__menu").click - expect(page).to have_button("Continue", disabled: true) - end - - step "If an issue is selected and then de-selected the Continue button behaves correctly" do - find("label", text: "PTSD denied").click - expect(page).to have_button("Continue", disabled: false) - find("label", text: "PTSD denied").click - expect(page).to have_button("Continue", disabled: true) - end - - step "If all issues are selected on the split appeal page, the Continue button is disabled" do - find("label", text: "PTSD denied").click - find("label", text: "Other Issue Description").click - expect(page).to have_button("Continue", disabled: true) - end - - step "The SSC user navigates to the split appeal page to review page" do - find("label", text: "PTSD denied").click click_button("Continue") - expect(page).to have_content("Reason for new appeal stream:") - expect(page).to have_current_path("/appeals/#{appeal2.uuid}/edit/review_split") + expect(page).to have_current_path("/appeals/#{appeal.uuid}/edit/review_split") end - end - - def skill_form(appeal) - visit("/appeals/#{appeal.uuid}/edit/create_split") - - # expect issue descritions to display - expect(page).to have_content("PTSD denied") - expect(page).to have_content("Other Issue Description") - find("label", text: "PTSD denied").click - expect(page).to have_content("Select...") - - find(:css, ".cf-select").select_option - find(:css, ".cf-select__menu").click - - click_button("Continue") - expect(page).to have_current_path("/appeals/#{appeal.uuid}/edit/review_split") - end - - def specialty_case_team_split_form(appeal) - visit("/appeals/#{appeal.uuid}/edit/create_split") - # expect issue descritions to display - expect(page).to have_content("PTSD denied") - expect(page).to have_content("Other Issue Description") - expect(page).to have_content("CHAMPVA Split Issue") - find("label", text: "CHAMPVA Split Issue").click - expect(page).to have_content("Select...") - - find(:css, ".cf-select").select_option - find(:css, ".cf-select__menu").click - - click_button("Continue") - expect(page).to have_current_path("/appeals/#{appeal.uuid}/edit/review_split") - end - - # scenario "When the user accesses the review_split page, the page renders as expected" do - scenario "Review split page behavior" do - step "When the user accesses the review_split page, the page renders as expected" do - skill_form(appeal2) - - expect(page).to have_table("review_table") - expect(page).to have_content("Cancel") - expect(page).to have_button("Back") - expect(page).to have_button("Split appeal") - expect(page).to have_content("Reason for new appeal stream:") - expect(appeal2.docket_type).not_to have_content("hearing") - - # Verify table information - row2_1 = page.find(:xpath, ".//table/tr[2]/td[1]/em").text - row3_1 = page.find(:xpath, ".//table/tr[3]/td[1]/em").text - expect(row2_1).to eq("Veteran") - if expect(appeal2.veteran_is_not_claimant).to be(false) - expect(row3_1).to eq("Docket Number") - else - expect(row3_1).to eq("Appellant") + # scenario "When the user accesses the review_split page, the page renders as expected" do + scenario "Review split page behavior" do + step "When the user accesses the review_split page, the page renders as expected" do + skill_form(appeal2) + + expect(page).to have_table("review_table") + expect(page).to have_content("Cancel") + expect(page).to have_button("Back") + expect(page).to have_button("Split appeal") + expect(page).to have_content("Reason for new appeal stream:") + expect(appeal2.docket_type).not_to have_content("hearing") + + # Verify table information + row2_1 = page.find(:xpath, ".//table/tr[2]/td[1]/em").text + row3_1 = page.find(:xpath, ".//table/tr[3]/td[1]/em").text + expect(row2_1).to eq("Veteran") + if expect(appeal2.veteran_is_not_claimant).to be(false) + expect(row3_1).to eq("Docket Number") + else + expect(row3_1).to eq("Appellant") + end end - end - - step "the back button takes the user back" do - click_button("Back") - expect(page).to have_content("Create new appeal stream") - expect(page).to have_current_path("/appeals/#{appeal2.uuid}/edit/create_split") - end - step "the cancel button takes the user back to the appeal case details page" do - skill_form(appeal2) - expect(page).to have_button("Split appeal") - click_button("Cancel") - expect(page).to have_current_path("/queue/appeals/#{appeal2.uuid}") - end + step "the back button takes the user back" do + click_button("Back") + expect(page).to have_content("Create new appeal stream") + expect(page).to have_current_path("/appeals/#{appeal2.uuid}/edit/create_split") + end - step "the Split appeal button splits appeal and takes the user back to the original appeal case details page" do - skill_form(appeal2) + step "the cancel button takes the user back to the appeal case details page" do + skill_form(appeal2) + expect(page).to have_button("Split appeal") + click_button("Cancel") + expect(page).to have_current_path("/queue/appeals/#{appeal2.uuid}") + end - click_button("Split appeal") - expect(page).to have_current_path("/queue/appeals/#{appeal2.uuid}", ignore_query: true) + step "the Split appeal button splits appeal and takes the user back to the original appeal case details page" do + skill_form(appeal2) - # Verify the success banner - expect(page).to have_content("You have successfully split #{appeal2.claimant.name}'s appeal") - expect(page).to have_content(COPY::SPLIT_APPEAL_BANNER_SUCCESS_MESSAGE) + click_button("Split appeal") + expect(page).to have_current_path("/queue/appeals/#{appeal2.uuid}", ignore_query: true) - # Verify the spit appeal information - appeal2.reload - split_record = SplitCorrelationTable.last - new_appeal = Appeal.find(split_record.appeal_id) - expect(split_record.original_appeal_id).to eq(appeal2.id) - expect(new_appeal.request_issues.first.contested_issue_description).to eq("PTSD denied") - expect(appeal2.request_issues.active.count).to eq(1) - expect(new_appeal.docket_number).to eq(appeal2.docket_number) - end - end + # Verify the success banner + expect(page).to have_content("You have successfully split #{appeal2.claimant.name}'s appeal") + expect(page).to have_content(COPY::SPLIT_APPEAL_BANNER_SUCCESS_MESSAGE) - context "When splitting appeals with Specialty Case Team issues" do - let!(:request_issue_3) do - create(:request_issue, - id: 28, - decision_review: appeal2, - decision_date: profile_date, - benefit_type: "vha", - nonrating_issue_category: "CHAMPVA", - nonrating_issue_description: "CHAMPVA Split Issue") + # Verify the spit appeal information + appeal2.reload + split_record = SplitCorrelationTable.last + new_appeal = Appeal.find(split_record.appeal_id) + expect(split_record.original_appeal_id).to eq(appeal2.id) + expect(new_appeal.request_issues.first.contested_issue_description).to eq("PTSD denied") + expect(appeal2.request_issues.active.count).to eq(1) + expect(new_appeal.docket_number).to eq(appeal2.docket_number) + end end - context "With feature toggle enabled" do - before do - FeatureToggle.enable!(:specialty_case_team_distribution) - end - after do - FeatureToggle.disable!(:specialty_case_team_distribution) + context "When splitting appeals with Specialty Case Team issues" do + let!(:request_issue_3) do + create(:request_issue, + id: 28, + decision_review: appeal2, + decision_date: profile_date, + benefit_type: "vha", + nonrating_issue_category: "CHAMPVA", + nonrating_issue_description: "CHAMPVA Split Issue") end - scenario "Split appeal with Vha issue" do - step "The split appeal should progress through to the review split page" do - specialty_case_team_split_form(appeal2) - end - - step "the banner should be on the page indicating that it is a specialty case team issue" do - expect(page).to have_content(COPY::SPLIT_APPEAL_SPECIALTY_CASE_TEAM_ISSUE_MESSAGE) - end - - step "The appeal should be split succesfully and user should be redirected back to the case details page" do - click_button("Split appeal") - expect(page).to have_current_path("/queue/appeals/#{appeal2.uuid}", ignore_query: true) - - # Verify the success banner - expect(page).to have_content("You have successfully split #{appeal2.claimant.name}'s appeal") - expect(page).to have_content(COPY::SPLIT_APPEAL_BANNER_SUCCESS_MESSAGE) - - # Verify the spit appeal information - appeal2.reload - split_record = SplitCorrelationTable.last - new_appeal = Appeal.find(split_record.appeal_id) - expect(split_record.original_appeal_id).to eq(appeal2.id) - expect(new_appeal.request_issues.first.nonrating_issue_category).to eq("CHAMPVA") - expect(appeal2.request_issues.active.count).to eq(2) - expect(new_appeal.request_issues.active.count).to eq(1) - expect(new_appeal.docket_number).to eq(appeal2.docket_number) - - # The new appeal should have an assigned SCT task - sct_task = new_appeal.tasks.find { |task| task.type == SpecialtyCaseTeamAssignTask.name } - expect(sct_task.status).to eq(Constants.TASK_STATUSES.assigned) + context "With feature toggle enabled" do + before { FeatureToggle.enable!(:specialty_case_team_distribution) } + after { FeatureToggle.disable!(:specialty_case_team_distribution) } + + scenario "Split appeal with Vha issue" do + step "The split appeal should progress through to the review split page" do + specialty_case_team_split_form(appeal2) + end + + step "the banner should be on the page indicating that it is a specialty case team issue" do + expect(page).to have_content(COPY::SPLIT_APPEAL_SPECIALTY_CASE_TEAM_ISSUE_MESSAGE) + end + + step "The appeal should be split succesfully and user should be redirected back to the case details page" do + click_button("Split appeal") + expect(page).to have_current_path("/queue/appeals/#{appeal2.uuid}", ignore_query: true) + + # Verify the success banner + expect(page).to have_content("You have successfully split #{appeal2.claimant.name}'s appeal") + expect(page).to have_content(COPY::SPLIT_APPEAL_BANNER_SUCCESS_MESSAGE) + + # Verify the spit appeal information + appeal2.reload + split_record = SplitCorrelationTable.last + new_appeal = Appeal.find(split_record.appeal_id) + expect(split_record.original_appeal_id).to eq(appeal2.id) + expect(new_appeal.request_issues.first.nonrating_issue_category).to eq("CHAMPVA") + expect(appeal2.request_issues.active.count).to eq(2) + expect(new_appeal.request_issues.active.count).to eq(1) + expect(new_appeal.docket_number).to eq(appeal2.docket_number) + + # The new appeal should have an assigned SCT task + sct_task = new_appeal.tasks.find { |task| task.type == SpecialtyCaseTeamAssignTask.name } + expect(sct_task.status).to eq(Constants.TASK_STATUSES.assigned) + end end end - end - - context "With sct feature toggle disabled" do - scenario "Split appeal with Vha issue" do - step "The split appeal should progress through to the review split page" do - specialty_case_team_split_form(appeal2) - end - step "the sct banner should not be on the page indicating that it is a specialty case team issue" do - expect(page).to_not have_content(COPY::SPLIT_APPEAL_SPECIALTY_CASE_TEAM_ISSUE_MESSAGE) - end - - step "The appeal should be split succesfully and user should be redirected back to the case details page" do - click_button("Split appeal") - expect(page).to have_current_path("/queue/appeals/#{appeal2.uuid}", ignore_query: true) - - # Verify the success banner - expect(page).to have_content("You have successfully split #{appeal2.claimant.name}'s appeal") - expect(page).to have_content(COPY::SPLIT_APPEAL_BANNER_SUCCESS_MESSAGE) - - # Verify the spit appeal information - appeal2.reload - split_record = SplitCorrelationTable.last - new_appeal = Appeal.find(split_record.appeal_id) - expect(split_record.original_appeal_id).to eq(appeal2.id) - expect(new_appeal.request_issues.first.nonrating_issue_category).to eq("CHAMPVA") - expect(appeal2.request_issues.active.count).to eq(2) - expect(new_appeal.request_issues.active.count).to eq(1) - expect(new_appeal.docket_number).to eq(appeal2.docket_number) - - # The new appeal should not have an assigned SCT task - sct_task = new_appeal.tasks.find { |task| task.type == SpecialtyCaseTeamAssignTask.name } - expect(sct_task).to eq(nil) + context "With sct feature toggle disabled" do + scenario "Split appeal with Vha issue" do + step "The split appeal should progress through to the review split page" do + specialty_case_team_split_form(appeal2) + end + + step "the sct banner should not be on the page indicating that it is a specialty case team issue" do + expect(page).to_not have_content(COPY::SPLIT_APPEAL_SPECIALTY_CASE_TEAM_ISSUE_MESSAGE) + end + + step "The appeal should be split succesfully and user should be redirected back to the case details page" do + click_button("Split appeal") + expect(page).to have_current_path("/queue/appeals/#{appeal2.uuid}", ignore_query: true) + + page.find("a", text: "refresh the page").click if page.has_text?("Unable to load this case") + + # Verify the success banner + expect(page).to have_content("You have successfully split #{appeal2.claimant.name}'s appeal") + expect(page).to have_content(COPY::SPLIT_APPEAL_BANNER_SUCCESS_MESSAGE) + + # Verify the spit appeal information + appeal2.reload + split_record = SplitCorrelationTable.last + new_appeal = Appeal.find(split_record.appeal_id) + expect(split_record.original_appeal_id).to eq(appeal2.id) + expect(new_appeal.request_issues.first.nonrating_issue_category).to eq("CHAMPVA") + expect(appeal2.request_issues.active.count).to eq(2) + expect(new_appeal.request_issues.active.count).to eq(1) + expect(new_appeal.docket_number).to eq(appeal2.docket_number) + + # The new appeal should not have an assigned SCT task + sct_task = new_appeal.tasks.find { |task| task.type == SpecialtyCaseTeamAssignTask.name } + expect(sct_task).to eq(nil) + end end end end @@ -908,8 +735,8 @@ def specialty_case_team_split_form(appeal) end end - context "when appeal Type is Veterans Health Administration By default (Predocket option)" do - scenario "appeal with benefit type VHA" do + context "when appeal Type is Veterans Health Administration" do + scenario "appeal with benefit type VHA (predocket)" do visit "appeals/#{appeal.uuid}/edit/" click_intake_add_issue click_intake_no_matching_issues @@ -926,9 +753,7 @@ def specialty_case_team_split_form(appeal) expect(find("#is-predocket-needed_false", visible: false).checked?).to eq(false) expect(page).to have_content(COPY::VHA_PRE_DOCKET_ISSUE_BANNER) end - end - context "when appeal Type is Veterans Health Administration NO Predocket" do scenario "appeal with benefit type VHA no - predocket" do visit "appeals/#{appeal.uuid}/edit/" click_intake_add_issue @@ -950,35 +775,6 @@ def specialty_case_team_split_form(appeal) end end - context "appeal is non-comp benefit type" do - let!(:request_issue) { create(:request_issue, benefit_type: "education") } - - scenario "adding an issue with a non-comp benefit type" do - visit "appeals/#{appeal.uuid}/edit/" - - # Add issue that is not a VBMS issue - click_intake_add_issue - click_intake_no_matching_issues - add_intake_nonrating_issue( - benefit_type: "Education", - category: "Accrued", - description: "Description for Accrued", - date: 1.day.ago.to_date.mdY - ) - - expect(page).to_not have_content("Check the Veteran's profile for invalid information") - expect(page).to have_button("Save", disabled: false) - - click_edit_submit_and_confirm - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") - expect(page).to_not have_content("Unable to load this case") - expect(RequestIssue.find_by( - benefit_type: "education", - veteran_participant_id: nil - )).to_not be_nil - end - end - context "appeal is outcoded" do let(:appeal) { create(:appeal, :outcoded, veteran: veteran) } @@ -992,20 +788,6 @@ def specialty_case_team_split_form(appeal) end context "when withdraw decision reviews is enabled" do - scenario "remove an issue with dropdown and show alert message" do - visit "appeals/#{appeal.uuid}/edit/" - expect(page).to have_content("PTSD denied") - click_remove_intake_issue_dropdown("PTSD denied") - - expect(page).to_not have_content("PTSD denied") - - click_edit_submit_and_confirm - - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") - - expect(page).to have_content("You have successfully removed 1 issue.") - end - let(:withdraw_date) { 1.day.ago.to_date.mdY } let!(:in_progress_task) do @@ -1016,99 +798,81 @@ def specialty_case_team_split_form(appeal) assigned_at: last_week) end - scenario "withdraw entire review and show alert" do - visit "appeals/#{appeal.uuid}/edit/" - - click_withdraw_intake_issue_dropdown("PTSD denied") - fill_in "withdraw-date", with: withdraw_date - - expect(page).to_not have_content("This review will be withdrawn.") - expect(page).to have_button("Save", disabled: false) + scenario "user can withdraw single issue and edit page shows previously withdrawn issues" do + step "withdraw an issue" do + visit "appeals/#{appeal.uuid}/edit/" - click_withdraw_intake_issue_dropdown("Military Retired Pay - nonrating description") + expect(page).to_not have_content("Withdrawn issues") + expect(page).to_not have_content("Please include the date the withdrawal was requested") - expect(page).to have_content("This review will be withdrawn.") - expect(page).to have_button("Withdraw", disabled: false) - - click_edit_submit + click_withdraw_intake_issue_dropdown("PTSD denied") - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") + expect(page).to have_content( + /Withdrawn issues\n[1-2]..PTSD denied\nDecision date: #{request_issue_decision_mdY}\nWithdrawal pending/i + ) + expect(page).to have_content("Please include the date the withdrawal was requested") - expect(page).to have_content("You have successfully withdrawn a review.") + expect(page).to have_button("Save", disabled: true) - expect(in_progress_task.reload.status).to eq(Constants.TASK_STATUSES.cancelled) - end + fill_in "withdraw-date", with: withdraw_date - scenario "withdraw an issue" do - visit "appeals/#{appeal.uuid}/edit/" + safe_click("#button-submit-update") + expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") - expect(page).to_not have_content("Withdrawn issues") - expect(page).to_not have_content("Please include the date the withdrawal was requested") + withdrawn_issue = RequestIssue.where(closed_status: "withdrawn").first - click_withdraw_intake_issue_dropdown("PTSD denied") + expect(withdrawn_issue).to_not be_nil + expect(withdrawn_issue.closed_at).to eq(1.day.ago.to_date.to_datetime) + expect(page).to have_content("You have successfully withdrawn 1 issue.") + end - expect(page).to have_content( - /Withdrawn issues\n[1-2]..PTSD denied\nDecision date: #{request_issue_decision_mdY}\nWithdrawal pending/i - ) - expect(page).to have_content("Please include the date the withdrawal was requested") + step "show withdrawn issue when appeal edit page is reloaded" do + # reload to verify that the new issues populate the form + visit "appeals/#{appeal.uuid}/edit/" - expect(page).to have_button("Save", disabled: true) + expect(page).to have_content( + /Withdrawn issues\s*[0-9]+\. PTSD denied\s*Decision date: #{request_issue_decision_mdY}\s*Withdrawn on/i + ) + end - fill_in "withdraw-date", with: withdraw_date + step "show alert when withdrawal date is not valid" do + click_withdraw_intake_issue_dropdown("Military Retired Pay - nonrating description") + fill_in "withdraw-date", with: 50.days.ago.to_date.mdY - safe_click("#button-submit-update") - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") + expect(page).to have_content( + "We cannot process your request. Please select a date after the Appeal's receipt date." + ) + expect(page).to have_button("Withdraw", disabled: true) - withdrawn_issue = RequestIssue.where(closed_status: "withdrawn").first + fill_in "withdraw-date", with: 2.years.from_now.to_date.mdY - expect(withdrawn_issue).to_not be_nil - expect(withdrawn_issue.closed_at).to eq(1.day.ago.to_date.to_datetime) - expect(page).to have_content("You have successfully withdrawn 1 issue.") + expect(page).to have_content("We cannot process your request. Please select a date prior to today's date.") + expect(page).to have_button("Withdraw", disabled: true) + end end - scenario "show withdrawn issue when appeal edit page is reloaded" do + scenario "withdraw entire review and show alert" do visit "appeals/#{appeal.uuid}/edit/" - click_intake_add_issue - add_intake_rating_issue("Left knee granted") + click_withdraw_intake_issue_dropdown("PTSD denied") + fill_in "withdraw-date", with: withdraw_date + expect(page).to_not have_content("This review will be withdrawn.") expect(page).to have_button("Save", disabled: false) - safe_click("#button-submit-update") - expect(page).to have_content("Number of issues has changed") - - safe_click ".confirm" - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") - - # reload to verify that the new issues populate the form - visit "appeals/#{appeal.uuid}/edit/" - expect(page).to have_content("Left knee granted") - - click_withdraw_intake_issue_dropdown("PTSD denied") + click_withdraw_intake_issue_dropdown("Military Retired Pay - nonrating description") + fill_in "withdraw-date", with: 2.days.ago.to_date.mdY - expect(page).to_not have_content(/Requested issues\s*[0-9]+\. PTSD denied/i) - expect(page).to have_content( - /Withdrawn issues\n[1-2]..PTSD denied\nDecision date: #{request_issue_decision_mdY}\nWithdrawal pending/i - ) - expect(page).to have_content("Please include the date the withdrawal was requested") + expect(page).to have_content("This review will be withdrawn.") + expect(page).to have_button("Withdraw", disabled: false) - fill_in "withdraw-date", with: withdraw_date + click_edit_submit - safe_click("#button-submit-update") expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") - withdrawn_issue = RequestIssue.where(closed_status: "withdrawn").first - expect(withdrawn_issue).to_not be_nil - expect(withdrawn_issue.closed_at).to eq(1.day.ago.to_date.to_datetime) - - sleep 1 - - # reload to verify that the new issues populate the form - visit "appeals/#{appeal.uuid}/edit/" + expect(page).to have_content("You have successfully withdrawn a review.") - expect(page).to have_content( - /Withdrawn issues\s*[0-9]+\. PTSD denied\s*Decision date: #{request_issue_decision_mdY}\s*Withdrawn on/i - ) + expect(in_progress_task.reload.status).to eq(Constants.TASK_STATUSES.cancelled) end scenario "show alert when issue is added, removed and withdrawn" do @@ -1146,135 +910,6 @@ def specialty_case_team_split_form(appeal) expect(page).to have_content("You have successfully added 1 issue, removed 1 issue, and withdrawn 1 issue.") end - - scenario "show alert when withdrawal date is not valid" do - visit "appeals/#{appeal.uuid}/edit/" - click_withdraw_intake_issue_dropdown("PTSD denied") - fill_in "withdraw-date", with: 50.days.ago.to_date.mdY - - expect(page).to have_content( - "We cannot process your request. Please select a date after the Appeal's receipt date." - ) - expect(page).to have_button("Save", disabled: true) - - fill_in "withdraw-date", with: 2.years.from_now.to_date.mdY - - expect(page).to have_content("We cannot process your request. Please select a date prior to today's date.") - expect(page).to have_button("Save", disabled: true) - end - end - - context "when remove decision reviews is enabled" do - let(:today) { Time.zone.now } - let(:appeal) do - # reload to get uuid - create(:appeal, veteran_file_number: veteran.file_number).reload - end - let!(:existing_request_issues) do - [create(:request_issue, :nonrating, decision_review: appeal), - create(:request_issue, :nonrating, decision_review: appeal)] - end - - let!(:completed_task) do - create(:appeal_task, - :completed, - appeal: appeal, - assigned_to: non_comp_org, - closed_at: last_week) - end - - let!(:cancelled_task) do - create(:appeal_task, - :cancelled, - appeal: appeal, - assigned_to: non_comp_org, - closed_at: Time.zone.now) - end - - context "when review has multiple active tasks" do - let!(:in_progress_task) do - create(:appeal_task, - :in_progress, - appeal: appeal, - assigned_to: non_comp_org, - assigned_at: last_week) - end - - scenario "cancel all active tasks when all request issues are removed" do - visit "appeals/#{appeal.uuid}/edit" - # remove all request issues - click_remove_intake_issue_dropdown("Apportionment") - click_remove_intake_issue_dropdown("Apportionment") - click_remove_intake_issue_dropdown("PTSD denied") - click_remove_intake_issue_dropdown("Military Retired Pay") - - click_edit_submit_and_confirm - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") - - expect(RequestIssue.find_by( - benefit_type: "compensation", - veteran_participant_id: nil - )).to_not be_nil - - visit "appeals/#{appeal.uuid}/edit" - expect(page.has_no_content?(existing_request_issues.first.description)).to eq(true) - expect(page.has_no_content?(existing_request_issues.second.description)).to eq(true) - expect(completed_task.reload.status).to eq(Constants.TASK_STATUSES.completed) - expect(in_progress_task.reload.status).to eq(Constants.TASK_STATUSES.cancelled) - end - - context "when appeal is non-comp benefit type" do - let!(:request_issue) { create(:request_issue, benefit_type: "education") } - - scenario "remove all non-comp decision reviews" do - visit "appeals/#{appeal.uuid}/edit" - - # remove all request issues - click_remove_intake_issue_dropdown("Apportionment") - click_remove_intake_issue_dropdown("Apportionment") - click_remove_intake_issue_dropdown("PTSD denied") - click_remove_intake_issue_dropdown("Military Retired Pay") - click_edit_submit_and_confirm - - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") - expect(page).to have_content("Edit Completed") - end - end - - context "when review has no active tasks" do - scenario "no tasks are cancelled when all request issues are removed" do - visit "appeals/#{appeal.uuid}/edit" - - click_remove_intake_issue_dropdown("Apportionment") - click_remove_intake_issue_dropdown("Apportionment") - click_remove_intake_issue_dropdown("PTSD denied") - click_remove_intake_issue_dropdown("Military Retired Pay") - click_edit_submit_and_confirm - expect(completed_task.reload.status).to eq(Constants.TASK_STATUSES.completed) - end - end - - context "when appeal task is cancelled" do - scenario "show timestamp when all request issues are cancelled" do - visit "appeals/#{appeal.uuid}/edit" - # remove all request issues - - click_remove_intake_issue_dropdown("Apportionment") - click_remove_intake_issue_dropdown("Apportionment") - click_remove_intake_issue_dropdown("PTSD denied") - click_remove_intake_issue_dropdown("Military Retired Pay") - - click_edit_submit_and_confirm - expect(page).to have_current_path("/queue/appeals/#{appeal.uuid}") - - visit "appeals/#{appeal.uuid}/edit" - expect(page.has_no_content?(existing_request_issues.first.description)).to eq(true) - expect(page.has_no_content?(existing_request_issues.second.description)).to eq(true) - expect(cancelled_task.status).to eq(Constants.TASK_STATUSES.cancelled) - expect(cancelled_task.closed_at).to eq(Time.zone.now) - end - end - end end context "with BVA Intake Admin user" do @@ -1296,19 +931,6 @@ def specialty_case_team_split_form(appeal) ) end - let(:legacy_appeal_mst_pact_checked) do - create( - :legacy_appeal, - :with_veteran, - vacols_case: create( - :case, - case_issues: [ - create(:case_issue, issmst: "Y", isspact: "Y") - ] - ) - ) - end - before do # joins the user with the organization to grant access to role and org permissions OrganizationsUser.make_user_admin(bva_intake_admin_user, bva_intake) @@ -1338,64 +960,66 @@ def go_to_queue_edit_issues_page_with_legacy_appeal(legacy_appeal) FeatureToggle.disable!(:legacy_mst_pact_identification) end - scenario "can add MST/PACT to issues" do - go_to_queue_edit_issues_page_with_legacy_appeal(legacy_appeal_mst_pact_unchecked) - click_edit_intake_issue_dropdown_by_number(1) - check("Military Sexual Trauma (MST)", allow_label_click: true, visible: false) - find(:xpath, "//label[@for='PACT Act']").click(allow_label_click: true, visible: false) - click_on "Save" + it "issues can be modified" do + step "can add MST/PACT to issues" do + go_to_queue_edit_issues_page_with_legacy_appeal(legacy_appeal_mst_pact_unchecked) + click_edit_intake_issue_dropdown_by_number(1) + check("Military Sexual Trauma (MST)", allow_label_click: true, visible: false) + find(:xpath, "//label[@for='PACT Act']").click(allow_label_click: true, visible: false) + click_on "Save" - click_on "Save" + click_on "Save" - expect(page).to have_content("MST and PACT") - end + expect(page).to have_content("MST and PACT") + end - scenario "can remove MST/PACT issues" do - go_to_queue_edit_issues_page_with_legacy_appeal(legacy_appeal_mst_pact_checked) - click_edit_intake_issue_dropdown_by_number(1) - uncheck("Military Sexual Trauma (MST)", allow_label_click: true, visible: false) - find(:xpath, "//label[@for='PACT Act']").click(allow_label_click: true, visible: false) - click_on "Save" + step "can remove MST/PACT issues" do + click_on "Correct issues" + click_edit_intake_issue_dropdown_by_number(1) + uncheck("Military Sexual Trauma (MST)", allow_label_click: true, visible: false) + find(:xpath, "//label[@for='PACT Act']").click(allow_label_click: true, visible: false) + click_on "Save" - click_on "Save" + click_on "Save" - expect(page).to have_no_content("MST and PACT") - end + expect(page).to have_no_content("MST and PACT") + end - scenario "can add and remove only PACT to an issue" do - go_to_queue_edit_issues_page_with_legacy_appeal(legacy_appeal_mst_pact_unchecked) - click_edit_intake_issue_dropdown_by_number(1) - find(:xpath, "//label[@for='PACT Act']").click(allow_label_click: true, visible: false) - click_on "Save" + step "can add and remove only PACT to an issue" do + click_on "Correct issues" + click_edit_intake_issue_dropdown_by_number(1) + find(:xpath, "//label[@for='PACT Act']").click(allow_label_click: true, visible: false) + click_on "Save" - click_on "Save" - expect(page).to have_content("SPECIAL ISSUES\nPACT") + click_on "Save" + expect(page).to have_content("SPECIAL ISSUES\nPACT") - click_on "Correct issues" - click_edit_intake_issue_dropdown_by_number(1) - find(:xpath, "//label[@for='PACT Act']").click(allow_label_click: true, visible: false) - click_on "Save" + click_on "Correct issues" + click_edit_intake_issue_dropdown_by_number(1) + find(:xpath, "//label[@for='PACT Act']").click(allow_label_click: true, visible: false) + click_on "Save" - click_on "Save" - expect(page).to have_no_content("SPECIAL ISSUES\nPact") - end + click_on "Save" + expect(page).to have_no_content("SPECIAL ISSUES\nPact") + end - scenario "can add and remove only MST to an issue" do - go_to_queue_edit_issues_page_with_legacy_appeal(legacy_appeal_mst_pact_unchecked) - click_edit_intake_issue_dropdown_by_number(1) - check("Military Sexual Trauma (MST)", allow_label_click: true, visible: false) - click_on "Save" + step "can add and remove only MST to an issue" do + click_on "Correct issues" + click_edit_intake_issue_dropdown_by_number(1) + check("Military Sexual Trauma (MST)", allow_label_click: true, visible: false) + click_on "Save" - click_on "Save" - expect(page).to have_content("SPECIAL ISSUES\nMST") + click_on "Save" + expect(page).to have_content("SPECIAL ISSUES\nMST") - click_on "Correct issues" - click_edit_intake_issue_dropdown_by_number(1) - uncheck("Military Sexual Trauma (MST)", allow_label_click: true, visible: false) - click_on "Save" + click_on "Correct issues" + click_edit_intake_issue_dropdown_by_number(1) + uncheck("Military Sexual Trauma (MST)", allow_label_click: true, visible: false) + click_on "Save" - click_on "Save" - expect(page).to have_no_content("SPECIAL ISSUES\nMST") + click_on "Save" + expect(page).to have_no_content("SPECIAL ISSUES\nMST") + end end end end @@ -1426,102 +1050,69 @@ def go_to_queue_edit_issues_page_with_legacy_appeal(legacy_appeal) end after { FeatureToggle.disable!(:specialty_case_team_distribution) } - scenario "appeal moves to sct queue when vha issue is added" do - reload_case_detail_page(appeal3.uuid) - click_on "Correct issues" - click_remove_intake_issue_dropdown("Unknown Issue Category") - click_intake_add_issue - fill_in "Benefit type", with: "Veterans Health Administration" - find("#issue-benefit-type").send_keys :enter - fill_in "Issue category", with: "Beneficiary Travel" - find("#issue-category").send_keys :enter - fill_in "Issue description", with: "I am a VHA issue" - fill_in "Decision date", with: 5.months.ago.mdY - - radio_choices = page.all(".cf-form-radio-option > label") - radio_choices[1].click - - safe_click ".add-issue" - click_edit_submit - expect(page).to have_content("Move appeal to SCT queue") - expect(page).to have_button("Move") - safe_click ".confirm" - expect(page).to have_content("You have successfully updated issues on this appeal") - expect(page).to have_content( - "The appeal for #{appeal3.claimant.name} " \ - "(ID: #{appeal3.veteran.file_number}) has been moved to the SCT queue." - ) - end - end - - context "Removing all Specialty Case Team issues from an appeal" do - let!(:appeal3) do - create(:appeal, - :assigned_to_judge, - :completed_distribution_task, - veteran_file_number: create(:veteran).file_number, - receipt_date: receipt_date, - docket_type: Constants.AMA_DOCKETS.direct_review) - end - let!(:request_issue) do - create(:request_issue, - benefit_type: "compensation", - nonrating_issue_category: "Unknown Issue Category", - nonrating_issue_description: "Compensation issue", - decision_date: 5.months.ago, - decision_review: appeal3) - end - let!(:sct_request_issue) do - create(:request_issue, - benefit_type: "vha", - nonrating_issue_category: "CHAMPVA", - nonrating_issue_description: "VHA issue", - decision_date: 5.months.ago, - decision_review: appeal3) - end - - before do - SpecialtyCaseTeam.singleton.add_user(current_user) - BvaIntake.singleton.add_user(current_user) - User.authenticate!(user: current_user) - FeatureToggle.enable!(:specialty_case_team_distribution) - - # Add a Specialty Case Team Assign Task to the appeal - SpecialtyCaseTeamAssignTask.create!(appeal: appeal3, - parent: appeal3.root_task, - assigned_to: SpecialtyCaseTeam.singleton) - end - - after { FeatureToggle.disable!(:specialty_case_team_distribution) } + scenario "appeal moves to sct queue when vha issue is added and moves back to distribution when removed" do + step "add VHA issue and remove non-VHA issue" do + reload_case_detail_page(appeal3.uuid) + click_on "Correct issues" + click_remove_intake_issue_dropdown("Unknown Issue Category") + click_intake_add_issue + fill_in "Benefit type", with: "Veterans Health Administration" + find("#issue-benefit-type").send_keys :enter + fill_in "Issue category", with: "Beneficiary Travel" + find("#issue-category").send_keys :enter + fill_in "Issue description", with: "I am a VHA issue" + fill_in "Decision date", with: 5.months.ago.mdY + radio_choices = page.all(".cf-form-radio-option > label") + radio_choices[1].click + safe_click ".add-issue" + + click_edit_submit + expect(page).to have_content("Move appeal to SCT queue") + expect(page).to have_button("Move") + safe_click ".confirm" + expect(page).to have_content("You have successfully updated issues on this appeal") + expect(page).to have_content( + "The appeal for #{appeal3.claimant.name} " \ + "(ID: #{appeal3.veteran.file_number}) has been moved to the SCT queue." + ) + end - scenario "appeal moves back to distribution when all SCT issues are removed" do - reload_case_detail_page(appeal3.uuid) - click_on "Correct issues" - click_remove_intake_issue_dropdown("CHAMPVA") - click_edit_submit_and_confirm + step "remove VHA issue and add non-VHA issue" do + reload_case_detail_page(appeal3.uuid) + click_on "Correct issues" + click_remove_intake_issue_dropdown("Beneficiary Travel") + click_intake_add_issue + add_intake_nonrating_issue( + benefit_type: "compensation", + category: "Unknown Issue Category", + description: "non vha issue", + date: 1.day.ago.to_date.mdY + ) - expect(page).to have_content(COPY::MOVE_TO_DISTRIBUTION_MODAL_TITLE) - expect(page).to have_content(COPY::MOVE_TO_DISTRIBUTION_MODAL_BODY) - expect(page).to have_button("Move") - safe_click ".confirm" - expect(page).to have_content("You have successfully updated issues on this appeal") - expect(page).to have_content( - "The appeal for #{appeal3.claimant.name} " \ - "(ID: #{appeal3.veteran.file_number}) has been moved to the regular distribution pool." - ) - expect(page).to have_current_path("/queue/appeals/#{appeal3.uuid}") - - # Verify task tree status - appeal3.reload - appeal3.tasks.reload - appeal3.request_issues.reload - distribution_task = appeal3.tasks.find { |task| task.is_a?(DistributionTask) } - expect(distribution_task.assigned_by).to eq(current_user) - expect(distribution_task.status).to eq("assigned") - expect(appeal3.ready_for_distribution?).to eq(true) - expect(appeal3.can_redistribute_appeal?).to eq(true) - expect(appeal3.request_issues.active.count).to eq(1) - expect(appeal3.tasks.find { |task| task.is_a?(SpecialtyCaseTeamAssignTask) }.status).to eq("cancelled") + click_edit_submit + expect(page).to have_content(COPY::MOVE_TO_DISTRIBUTION_MODAL_TITLE) + expect(page).to have_content(COPY::MOVE_TO_DISTRIBUTION_MODAL_BODY) + expect(page).to have_button("Move") + safe_click ".confirm" + expect(page).to have_content("You have successfully updated issues on this appeal") + expect(page).to have_content( + "The appeal for #{appeal3.claimant.name} " \ + "(ID: #{appeal3.veteran.file_number}) has been moved to the regular distribution pool." + ) + expect(page).to have_current_path("/queue/appeals/#{appeal3.uuid}") + + # Verify task tree status + appeal3.reload + appeal3.tasks.reload + appeal3.request_issues.reload + distribution_task = appeal3.tasks.find { |task| task.is_a?(DistributionTask) } + expect(distribution_task.assigned_by).to eq(current_user) + expect(distribution_task.status).to eq("assigned") + expect(appeal3.ready_for_distribution?).to eq(true) + expect(appeal3.can_redistribute_appeal?).to eq(true) + expect(appeal3.request_issues.active.count).to eq(1) + expect(appeal3.tasks.find { |task| task.is_a?(SpecialtyCaseTeamAssignTask) }.status).to eq("cancelled") + end end end end diff --git a/spec/jobs/dependencies_report_service_log_job_spec.rb b/spec/jobs/dependencies_report_service_log_job_spec.rb index 9a72fdd9ee0..dee57e5dd62 100644 --- a/spec/jobs/dependencies_report_service_log_job_spec.rb +++ b/spec/jobs/dependencies_report_service_log_job_spec.rb @@ -1,21 +1,6 @@ # frozen_string_literal: true describe DependenciesReportServiceLogJob do - DEPENDENCIES_REPORT_WITH_OUTAGES = <<-'EOF'.strip_heredoc.freeze - { - "BGS":{"name":"BGS","up_rate_5":100.0}, - "VACOLS":{"name":"VACOLS","up_rate_5":10.0}, - "VBMS":{"name":"VBMS","up_rate_5":49.0}, - "VBMS.FindDocumentVersionReference":{"name":"VBMS.FindDocumentVersionReference", - "up_rate_5":100.0} - } - EOF - DEPENDENCIES_REPORT_WITH_INVALID_DATA = <<-'EOF'.strip_heredoc.freeze - { - "BGS":{"name":"BGS","bad_field":"a"}, - } - EOF - context "when outage is present" do before do Rails.cache.write(:degraded_service_banner_bgs, :display)