From 05f1f275682ccfe9d97dd30f72b63c2bd3e8e743 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Mon, 15 Jul 2024 11:55:14 -0500 Subject: [PATCH 01/19] consolidate member not admin tests --- .../audit_lever_history_table_spec.rb | 71 ------ .../acd_levers/affinity_days_levers_spec.rb | 17 -- .../ama_np_dist_goals_by_docket_lever_spec.rb | 15 -- .../acd_levers/batch_size_levers_spec.rb | 11 - .../inactive_data_elements_levers_spec.rb | 9 - .../acd_levers/lever_buttons_spec.rb | 9 - .../case_distribution_levers/admin_ui_spec.rb | 203 ++++++++++++++++++ 7 files changed, 203 insertions(+), 132 deletions(-) create mode 100644 spec/feature/case_distribution_levers/admin_ui_spec.rb 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 index c1662fc1a04..b50d560fd4e 100644 --- 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 @@ -14,77 +14,6 @@ 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 } 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 index cb215a42751..a60d4ca1d03 100644 --- 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 @@ -26,23 +26,6 @@ ] 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) 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 index 952483fc2ed..ada3a22a46c 100644 --- 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 @@ -17,21 +17,6 @@ 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) 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 index 31a3e5f82d5..b5b24520c60 100644 --- 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 @@ -12,17 +12,6 @@ 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) 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 index 661f144c83b..2d02b7f814e 100644 --- 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 @@ -13,15 +13,6 @@ 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) 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 index bbdb850961a..acb15f245e6 100644 --- a/spec/feature/automatic_case_distribution/acd_levers/lever_buttons_spec.rb +++ b/spec/feature/automatic_case_distribution/acd_levers/lever_buttons_spec.rb @@ -15,15 +15,6 @@ 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" } 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..befd7dfb21a --- /dev/null +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -0,0 +1,203 @@ +# frozen_string_literal: true + +RSpec.feature "Admin UI" do + # TODO: break this out if possible + 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(: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 } + + context "user is in Case Distro Algorithm Control organization but not an admin" do + let!(:audit_lever_entry_1) do + create(:case_distribution_audit_lever_entry, + case_distribution_lever: ama_direct_reviews_lever, + previous_value: 10, + update_value: 15, + created_at: 5.days.ago) + end + let!(:audit_lever_entry_2) do + create(:case_distribution_audit_lever_entry, + case_distribution_lever: alternate_batch_size_lever, + previous_value: 7, + update_value: 6, + created_at: 4.days.ago) + end + let!(:audit_lever_entry_3) do + Timecop.travel(3.days.ago) 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: 2, + update_value: 4) + end + end + + scenario "the lever control page operates correctly", :aggregate_failures do + step "page renders" 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 + + 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") + + 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 + + step "lever history displays correctly" do + # 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}") + + # create(:case_distribution_audit_lever_entry, + # case_distribution_lever: alternate_batch_size_lever, + # previous_value: 7, + # update_value: 6) + + # visit "case-distribution-controls" + + # 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("10 #{ama_direct_reviews_lever.unit}") + # expect(find("#lever-history-table-row-1")).to have_content("15 #{ama_direct_reviews_lever.unit}") + + # Timecop.freeze 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: 2, + # update_value: 4) + # end + + # visit "case-distribution-controls" + byebug + 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("15 #{ama_direct_reviews_lever.unit}") + expect(find("#lever-history-table-row-0")).to have_content("5 #{ama_direct_reviews_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(alternate_batch_size_lever.title) + expect(find("#lever-history-table-row-1")).to have_content("7 #{alternate_batch_size_lever.unit}") + expect(find("#lever-history-table-row-1")).to have_content("6 #{alternate_batch_size_lever.unit}") + + expect(find("#lever-history-table-row-2")).to have_content(current_user.css_id) + expect(find("#lever-history-table-row-2")).to have_content(ama_direct_reviews_lever.title) + expect(find("#lever-history-table-row-2")).to have_content("10 #{ama_direct_reviews_lever.unit}") + expect(find("#lever-history-table-row-2")).to have_content("15 #{ama_direct_reviews_lever.unit}") + end + end + end + + context "user is a Case Distro Algorithm Control admin" do + before do + OrganizationsUser.make_user_admin(current_user, CDAControlGroup.singleton) + 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(COPY::CASE_DISTRIBUTION_DOCKET_TIME_GOALS_SECTION_TITLE) + expect(page).to have_content(COPY::CASE_DISTRIBUTION_BATCH_SIZE_H2_TITLE) + expect(page).to have_content(COPY::CASE_DISTRIBUTION_HISTORY_TITLE) + expect(page).to have_content(COPY::CASE_DISTRIBUTION_HISTORY_DESCRIPTION) + 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) + 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) + 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) + + 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") + + expect(page).not_to have_button("Cancel") + expect(page).not_to have_button("Save") + end + # rubocop:enable Metrics/AbcSize +end From 91d0af610907aa5571ca70176a46a16f6c816c7d Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Mon, 15 Jul 2024 11:57:15 -0500 Subject: [PATCH 02/19] remove commented portions of test --- .../case_distribution_levers/admin_ui_spec.rb | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/spec/feature/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index befd7dfb21a..8ae2927c0bb 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -101,41 +101,6 @@ end step "lever history displays correctly" do - # 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}") - - # create(:case_distribution_audit_lever_entry, - # case_distribution_lever: alternate_batch_size_lever, - # previous_value: 7, - # update_value: 6) - - # visit "case-distribution-controls" - - # 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("10 #{ama_direct_reviews_lever.unit}") - # expect(find("#lever-history-table-row-1")).to have_content("15 #{ama_direct_reviews_lever.unit}") - - # Timecop.freeze 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: 2, - # update_value: 4) - # end - - # visit "case-distribution-controls" - byebug 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}") From 7ba0778d4cc0234edfe6af4fb8c6a32151732db7 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Mon, 15 Jul 2024 13:22:15 -0500 Subject: [PATCH 03/19] move tests from affinity_days_levers_spec.rb --- .../audit_lever_history_table_spec.rb | 59 ------------------- .../case_distribution_levers/admin_ui_spec.rb | 43 ++++++++++++-- 2 files changed, 38 insertions(+), 64 deletions(-) delete mode 100644 spec/feature/automatic_case_distribution/acd_audit_history/audit_lever_history_table_spec.rb 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 b50d560fd4e..00000000000 --- a/spec/feature/automatic_case_distribution/acd_audit_history/audit_lever_history_table_spec.rb +++ /dev/null @@ -1,59 +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 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/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index 8ae2927c0bb..82634baeef3 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -38,12 +38,13 @@ 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(:ama_direct_reviews_field) { Constants.DISTRIBUTION.ama_direct_review_docket_time_goals } + context "user is in Case Distro Algorithm Control organization but not an admin" do let!(:audit_lever_entry_1) do create(:case_distribution_audit_lever_entry, @@ -72,10 +73,12 @@ end end - scenario "the lever control page operates correctly", :aggregate_failures do + it "the lever control page renders correctly", :aggregate_failures do step "page renders" do visit "case-distribution-controls" confirm_page_and_section_loaded + expect(page).not_to have_button("Cancel") + expect(page).not_to have_button("Save") disabled_lever_list.each do |item| expect(find("#lever-wrapper-#{item}")).to match_css(".lever-disabled") @@ -126,6 +129,31 @@ before do OrganizationsUser.make_user_admin(current_user, CDAControlGroup.singleton) end + + it "the lever control page operates correctly" do + step "lever history displays on page" 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: "" + 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 # rubocop:disable Metrics/AbcSize @@ -160,9 +188,14 @@ def confirm_page_and_section_loaded expect(find("##{bust_backlog}-description")).to match_css(".description-styling") expect(find("##{bust_backlog}-product")).to match_css(".value-styling") - - expect(page).not_to have_button("Cancel") - expect(page).not_to have_button("Save") end # rubocop:enable Metrics/AbcSize + + def click_save_button + find("#LeversSaveButton").click + end + + def click_modal_confirm_button + find("#save-modal-confirm").click + end end From f391519a5075e67e90c32c51381afdcf7e1dff2c Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Mon, 15 Jul 2024 13:38:54 -0500 Subject: [PATCH 04/19] move tests from affinity_days_levers_spec.rb, last commit was from audit_lever_history_table_spec.rb --- .../acd_levers/affinity_days_levers_spec.rb | 66 ------------------- .../case_distribution_levers/admin_ui_spec.rb | 37 ++++++++++- 2 files changed, 35 insertions(+), 68 deletions(-) delete mode 100644 spec/feature/automatic_case_distribution/acd_levers/affinity_days_levers_spec.rb 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 a60d4ca1d03..00000000000 --- a/spec/feature/automatic_case_distribution/acd_levers/affinity_days_levers_spec.rb +++ /dev/null @@ -1,66 +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 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/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index 82634baeef3..179c1295dd5 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -131,10 +131,43 @@ end it "the lever control page operates correctly" do + visit "case-distribution-controls" + confirm_page_and_section_loaded + + 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 "lever history displays on page" do - visit "case-distribution-controls" - confirm_page_and_section_loaded + # 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 + # From ../acd_audit_history/audit_lever_history_table_spec.rb 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) From 09eed2da1c1b42ef4e771644b0d52b05dde5afe7 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Mon, 15 Jul 2024 13:47:00 -0500 Subject: [PATCH 05/19] remove ama_np_dist_goals_by_docket_lever_spec.rb --- .../ama_np_dist_goals_by_docket_lever_spec.rb | 67 ------------------- .../case_distribution_levers/admin_ui_spec.rb | 42 ++++++++---- 2 files changed, 29 insertions(+), 80 deletions(-) delete mode 100644 spec/feature/automatic_case_distribution/acd_levers/ama_np_dist_goals_by_docket_lever_spec.rb 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 ada3a22a46c..00000000000 --- a/spec/feature/automatic_case_distribution/acd_levers/ama_np_dist_goals_by_docket_lever_spec.rb +++ /dev/null @@ -1,67 +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 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/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index 179c1295dd5..72de1f70a29 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -31,6 +31,10 @@ 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 } @@ -151,22 +155,31 @@ end end - step "lever history displays on page" do - # From affinity_days_levers_spec.rb - option_list = [Constants.ACD_LEVERS.omit, Constants.ACD_LEVERS.infinite, Constants.ACD_LEVERS.value] + step "levers initally display correctly" do + # From ama_np_dist_goals_by_docket_lever_spec.rb + 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) - disabled_lever_list.each do |disabled_lever| - option_list.each do |option| - expect(find("##{disabled_lever}-#{option}", visible: false)).to be_disabled - end - end + 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 - 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 + step "error displays for invalid input" do + # From ama_np_dist_goals_by_docket_lever_spec.rb + 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 + + step "error clears with valid input" do # From ../acd_audit_history/audit_lever_history_table_spec.rb 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) @@ -175,7 +188,10 @@ fill_in ama_direct_reviews_field, with: "123" click_save_button click_modal_confirm_button + end + step "lever history displays on page" do + # From ../acd_audit_history/audit_lever_history_table_spec.rb 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) From f1faa609182125d3854d02cf2d4b3253b1f8c8af Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Mon, 15 Jul 2024 14:09:53 -0500 Subject: [PATCH 06/19] remove batch_size_levers_spec.rb --- .../acd_levers/batch_size_levers_spec.rb | 75 ------------------- .../case_distribution_levers/admin_ui_spec.rb | 34 ++++++++- 2 files changed, 31 insertions(+), 78 deletions(-) delete mode 100644 spec/feature/automatic_case_distribution/acd_levers/batch_size_levers_spec.rb 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 b5b24520c60..00000000000 --- a/spec/feature/automatic_case_distribution/acd_levers/batch_size_levers_spec.rb +++ /dev/null @@ -1,75 +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 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/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index 72de1f70a29..1c8d6ee410c 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -138,6 +138,8 @@ visit "case-distribution-controls" confirm_page_and_section_loaded + 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] @@ -166,9 +168,8 @@ expect(page).to have_button("toggle-switch-#{ama_evidence_submissions}", disabled: false) end - step "error displays for invalid input" do + step "error displays for invalid input on time goals section" do # From ama_np_dist_goals_by_docket_lever_spec.rb - 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: "") @@ -179,7 +180,7 @@ expect(find("##{ama_direct_reviews_field}-lever").has_no_content?(empty_error_message)).to eq(true) end - step "error clears with valid input" do + step "time goals section error clears with valid input" do # From ../acd_audit_history/audit_lever_history_table_spec.rb 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) @@ -190,6 +191,33 @@ click_modal_confirm_button end + step "batch size lever section errors display with invalid inputs" do + # From batch_size_levers_spec.rb + 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 + # From batch_size_levers_spec.rb + 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 + step "lever history displays on page" do # From ../acd_audit_history/audit_lever_history_table_spec.rb expect(find("#lever-history-table").has_content?("123 days")).to eq(true) From 03639cc4fedbcd09fda92e36feec56152ce06700 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Mon, 15 Jul 2024 14:16:51 -0500 Subject: [PATCH 07/19] remove inactive_data_elements_levers_spec.rb --- .../inactive_data_elements_levers_spec.rb | 79 ------------------- .../case_distribution_levers/admin_ui_spec.rb | 34 +++++++- 2 files changed, 31 insertions(+), 82 deletions(-) delete mode 100644 spec/feature/automatic_case_distribution/acd_levers/inactive_data_elements_levers_spec.rb 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 2d02b7f814e..00000000000 --- a/spec/feature/automatic_case_distribution/acd_levers/inactive_data_elements_levers_spec.rb +++ /dev/null @@ -1,79 +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 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/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index 1c8d6ee410c..7a2af75c539 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -168,6 +168,31 @@ expect(page).to have_button("toggle-switch-#{ama_evidence_submissions}", disabled: false) end + step "inactive levers are displayed with values" do + # From inactive_data_elements_levers_spec.rb + 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 + step "error displays for invalid input on time goals section" do # From ama_np_dist_goals_by_docket_lever_spec.rb @@ -240,6 +265,7 @@ def confirm_page_and_section_loaded expect(page).to have_content(COPY::CASE_DISTRIBUTION_BATCH_SIZE_H2_TITLE) expect(page).to have_content(COPY::CASE_DISTRIBUTION_HISTORY_TITLE) expect(page).to have_content(COPY::CASE_DISTRIBUTION_HISTORY_DESCRIPTION) + expect(page).to have_content(COPY::CASE_DISTRIBUTION_STATIC_LEVERS_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) @@ -254,15 +280,17 @@ def confirm_page_and_section_loaded expect(page).to have_content(Constants.DISTRIBUTION.batch_size_per_attorney_title) expect(page).to have_content(Constants.DISTRIBUTION.request_more_cases_minimum_title) + # From inactive_data_elements_levers_spec.rb + 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) 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 From 90db15e002b0a52840412033dc2cc72a422f6cea Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Mon, 15 Jul 2024 14:56:17 -0500 Subject: [PATCH 08/19] remove lever_buttons_spec.rb --- .../acd_levers/lever_buttons_spec.rb | 159 ------------------ .../case_distribution_levers/admin_ui_spec.rb | 52 +++++- 2 files changed, 50 insertions(+), 161 deletions(-) delete mode 100644 spec/feature/automatic_case_distribution/acd_levers/lever_buttons_spec.rb 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 acb15f245e6..00000000000 --- a/spec/feature/automatic_case_distribution/acd_levers/lever_buttons_spec.rb +++ /dev/null @@ -1,159 +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 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 index 7a2af75c539..0b0569a8fb3 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -47,7 +47,7 @@ let(:nod_adjustment) { Constants.DISTRIBUTION.nod_adjustment } let(:bust_backlog) { Constants.DISTRIBUTION.bust_backlog } - let(:ama_direct_reviews_field) { Constants.DISTRIBUTION.ama_direct_review_docket_time_goals } + let(:alternative_batch_size_field) { "#{Constants.DISTRIBUTION.alternative_batch_size}-field" } context "user is in Case Distro Algorithm Control organization but not an admin" do let!(:audit_lever_entry_1) do @@ -77,7 +77,7 @@ end end - it "the lever control page renders correctly", :aggregate_failures do + it "the lever control page renders correctly and has no options to change/save values", :aggregate_failures do step "page renders" do visit "case-distribution-controls" confirm_page_and_section_loaded @@ -193,6 +193,42 @@ expect(find("##{bust_backlog}-value")).to have_content(bust_backlog_value + bust_backlog_lever.unit) end + step "cancelling 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: "" + + # From lever_buttons_spec.rb + 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 # From ama_np_dist_goals_by_docket_lever_spec.rb @@ -210,8 +246,10 @@ 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 lever_buttons_spec.rb 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 end @@ -253,6 +291,7 @@ click_modal_confirm_button expect(find("#lever-history-table").has_content?("123 days")).to eq(true) + expect(find("#lever-history-table").has_content?("456 days")).to eq(true) expect(find("#lever-history-table").has_content?("300 days")).to eq(true) end end @@ -260,6 +299,7 @@ # rubocop:disable Metrics/AbcSize def confirm_page_and_section_loaded + expect(page).to have_content(COPY::CASE_DISTRIBUTION_TITLE) expect(page).to have_content(COPY::CASE_DISTRIBUTION_AFFINITY_DAYS_H2_TITLE) expect(page).to have_content(COPY::CASE_DISTRIBUTION_DOCKET_TIME_GOALS_SECTION_TITLE) expect(page).to have_content(COPY::CASE_DISTRIBUTION_BATCH_SIZE_H2_TITLE) @@ -303,4 +343,12 @@ def click_save_button 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 From 77318d0e8000861d4f4e7f6202f5a61bf960c3d5 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Mon, 15 Jul 2024 16:34:58 -0500 Subject: [PATCH 09/19] refactor --- .../case_distribution_levers/admin_ui_spec.rb | 81 +++---------------- 1 file changed, 9 insertions(+), 72 deletions(-) diff --git a/spec/feature/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index 0b0569a8fb3..f9f98d49447 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -80,20 +80,10 @@ it "the lever control page renders correctly and has no options to change/save values", :aggregate_failures do step "page renders" do visit "case-distribution-controls" - confirm_page_and_section_loaded + expect(page).to have_content("Case Distribution Algorithm Values") expect(page).not_to have_button("Cancel") expect(page).not_to have_button("Save") - 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 - 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") @@ -136,7 +126,7 @@ it "the lever control page operates correctly" do visit "case-distribution-controls" - confirm_page_and_section_loaded + expect(page).to have_content("Case Distribution Algorithm Values") empty_error_message = "Please enter a value greater than or equal to 0" @@ -170,27 +160,10 @@ step "inactive levers are displayed with values" do # From inactive_data_elements_levers_spec.rb - 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) + 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 changes resets values" do @@ -290,6 +263,9 @@ click_save_button click_modal_confirm_button + # Refresh page to validate back end saved the levers correctly + visit "case-distribution-controls" + expect(find("#lever-history-table").has_content?("123 days")).to eq(true) expect(find("#lever-history-table").has_content?("456 days")).to eq(true) expect(find("#lever-history-table").has_content?("300 days")).to eq(true) @@ -297,45 +273,6 @@ end end - # rubocop:disable Metrics/AbcSize - def confirm_page_and_section_loaded - expect(page).to have_content(COPY::CASE_DISTRIBUTION_TITLE) - expect(page).to have_content(COPY::CASE_DISTRIBUTION_AFFINITY_DAYS_H2_TITLE) - expect(page).to have_content(COPY::CASE_DISTRIBUTION_DOCKET_TIME_GOALS_SECTION_TITLE) - expect(page).to have_content(COPY::CASE_DISTRIBUTION_BATCH_SIZE_H2_TITLE) - expect(page).to have_content(COPY::CASE_DISTRIBUTION_HISTORY_TITLE) - expect(page).to have_content(COPY::CASE_DISTRIBUTION_HISTORY_DESCRIPTION) - expect(page).to have_content(COPY::CASE_DISTRIBUTION_STATIC_LEVERS_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) - 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) - 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) - - # From inactive_data_elements_levers_spec.rb - 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) - 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 - # rubocop:enable Metrics/AbcSize - def click_save_button find("#LeversSaveButton").click end From 58360d2ac78db67995c40c377d244dbcbaa19ce7 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Tue, 16 Jul 2024 08:58:04 -0500 Subject: [PATCH 10/19] move jest file for convention, add snapshot --- .../{pages => }/CaseDistributionApp.test.js | 37 +- .../CaseDistributionApp.test.js.snap | 1243 +++++++++++++++++ 2 files changed, 1274 insertions(+), 6 deletions(-) rename client/test/app/caseDistribution/{pages => }/CaseDistributionApp.test.js (55%) create mode 100644 client/test/app/caseDistribution/__snapshots__/CaseDistributionApp.test.js.snap diff --git a/client/test/app/caseDistribution/pages/CaseDistributionApp.test.js b/client/test/app/caseDistribution/CaseDistributionApp.test.js similarity index 55% rename from client/test/app/caseDistribution/pages/CaseDistributionApp.test.js rename to client/test/app/caseDistribution/CaseDistributionApp.test.js index 6eff989b4ab..9a6e8ac853f 100644 --- a/client/test/app/caseDistribution/pages/CaseDistributionApp.test.js +++ b/client/test/app/caseDistribution/CaseDistributionApp.test.js @@ -1,10 +1,19 @@ 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'; import thunk from 'redux-thunk'; import { mount } from 'enzyme'; +import { render } from '@testing-library/react'; describe('render Case Distribution Application', () => { @@ -13,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(() => { @@ -32,7 +41,7 @@ describe('render Case Distribution Application', () => { @@ -45,5 +54,21 @@ describe('render Case Distribution Application', () => { expect(wrapper.find('.lever-content').exists()).toBeTruthy(); }); + it('matches snapshot', () => { + const store = getStore(); + + const { container } = render( + + + + ); + + expect(container).toMatchSnapshot(); + }); }); diff --git a/client/test/app/caseDistribution/__snapshots__/CaseDistributionApp.test.js.snap b/client/test/app/caseDistribution/__snapshots__/CaseDistributionApp.test.js.snap new file mode 100644 index 00000000000..66ac32d5d7f --- /dev/null +++ b/client/test/app/caseDistribution/__snapshots__/CaseDistributionApp.test.js.snap @@ -0,0 +1,1243 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`render Case Distribution Application matches snapshot 1`] = ` +
+
+
+
+

+ Administration +

+
+ +

+ Case Distribution Algorithm Values +

+

+ The Case Distribution Algorithm determines how cases are assigned to VLJs and their teams. Current algorithm is "Docket Date." +

+
+ +

+ + Active Data Elements + +

+
+

+ You may make changes to the Case Distribution algorithm values based on the data elements below. Changes will be applied to the next case distribution event unless subsequent confirmed changes are made to the same variable. +

+
+

+ Excluding Appeals by Docket Type and Priority from Automatic Case Distribution +

+

+ For both Non-priority and Priority cases, you may use the sliders to turn on or off all options for each row. When you turn off a slider, all items in that row will be automatically deselected and visa versa. ​Additionally, If you wish to select only some options in a row or column, the slider will automatically turn off. You can make individual selections for that row or column at any point. +

+

+ Selected docket type/priority combination options will be excluded from automatic case distribution beginning with the next distribution. +

+
+
+ + + + + + + + + + + + + + + + + +
+ Legacy Appeals + + AMA Hearings Appeals + + AMA Direct Review Appeals + + AMA Evidence Submission Appeals +
+ +

+ All Non-priority +

+ +
+
+ +

+ All Priority +

+ +
+
+
+
+
+

+ Batch Size +

+
+ + Data Elements + +
+
+ + Value + +
+
+
+
+ + Test Title Lever* + * + +

+ Test Description for Lever data outOfBoundsBatchLever. +

+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+ + Test Title Lever2* + * + +

+ Test Description for Lever data disabled-in-ui. +

+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+ + Test Text Title Lever3 + * + +

+ Test Description for Lever data type text +

+
+
+
+
+ + +
+ +
+
+
+
+
+ +
+
+
+
+

+ Affinity Days +

+
+ + Data Elements + +
+
+ + Value + +
+
+
+
+ + AMA Hearing Case Affinity Days + + +

+ For non-priority AMA Hearing cases, sets the number of days an AMA Hearing Case is tied to the judge that held the hearing. +

+
+
+
+
+ + +
+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+ + AMA Hearing Case AOD Affinity Days + + +

+ Sets the number of days an AMA Hearing appeal that is also AOD will respect the affinity to the most-recent hearing judge before distributing the appeal to any available judge. +

+
+
+
+
+ + +
+
+
+
+ +
+ +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+

+ AMA Non-priority Distribution Goals by Docket +

+

+ + Docket Time Goal + + set the completion target for AMA non-priority appeals by docket type. It represents the number of calendar days that are added to the receipt date of the appeal to establish the decision target date. +

+

+ + Start Distribution Prior to Docket Time Goal + + days sets the number of calendar days prior to the Docket Time Goal for that docket type when appeals become eligible for distribution. +

+

+ Please note, if turned on, non-priority appeals of that docket type will not be distributed until eligible, which may disrupt strict docket-date-order distribution across dockets. +

+
+
+ +
+
+ + Docket Time Goal + +
+
+ + Start Distribution Prior to Docket Time Goal + +
+
+
+
+
+ + AMA Hearings + +
+
+
+
+ + +
+ +
+
+
+
+
+ +
+
+
+ + +
+ +
+
+
+
+
+
+
+
+ + AMA Direct Review + +
+
+
+
+ + +
+ +
+
+
+
+
+ +
+
+
+ + +
+ +
+
+
+
+
+
+
+
+
+ + + +
+
+ + + +
+
+
+
+
+
+ +

+ + Inactive Data Elements + +

+
+

+ The below values do not effect the current active Case Distribution algorithm. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Data Elements + + Values +
+ Maximum Direct Review Proportion +
+ Sets the maximum number of direct reviews in relation to due direct review proportion to prevent a complete halt to work on other dockets should demand for direct reviews approach the Board's capacity. + + + 80 + + % + + +
+ Minimum Legacy Proportion +
+ Sets the minimum proportion of legacy appeals that will be distributed. + + + 20 + + % + + +
+ NOD Adjustment +
+ Applied for docket balancing reflecting the likelihood that NODs will advance to a Form 9. + + + 90 + + % + + +
+ Priority Bust Backlog +
+ Distribute legacy cases tied to a judge to the Board-provided limit of 30, regardless of the legacy docket range. + + + True + + +
+
+
+
+

+ + Case Distribution Algorithm Change History + +

+
+

+ Change history for Case Distribution Admin shows changes made in the last 365 days. +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ Date of Last Change + + User ID + + Data Element Changed + + Previous Value + + Updated Value +
+ Sat, Jul 1, 2023 12:10:01 + + +
    +
  1. +
+
+
    +
  1. + undefined +
  2. +
+
+
    +
  1. + undefined +
  2. +
+
+ Sat, Jul 1, 2023 10:10:01 + + +
    +
  1. +
  2. +
+
+
    +
  1. + undefined +
  2. +
  3. + undefined +
  4. +
+
+
    +
  1. + undefined +
  2. +
  3. + undefined +
  4. +
+
+
+
+
+
+
+
+
+
+`; From 41c9e6e82eb72dfeab203751699eaca14bc58e24 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Tue, 16 Jul 2024 09:35:04 -0500 Subject: [PATCH 11/19] move test for admin ui not interactable for non-admins to a jest test --- .../CaseDistributionApp.test.js | 29 +++++++- .../case_distribution_levers/admin_ui_spec.rb | 70 ------------------- 2 files changed, 28 insertions(+), 71 deletions(-) diff --git a/client/test/app/caseDistribution/CaseDistributionApp.test.js b/client/test/app/caseDistribution/CaseDistributionApp.test.js index 9a6e8ac853f..ab90b61d585 100644 --- a/client/test/app/caseDistribution/CaseDistributionApp.test.js +++ b/client/test/app/caseDistribution/CaseDistributionApp.test.js @@ -33,7 +33,7 @@ describe('render Case Distribution Application', () => { jest.clearAllMocks(); }); - it('renders Case Distribution App', () => { + it('renders Case Distribution App as editable for an admin', () => { const store = getStore(); let wrapper = mount( @@ -52,6 +52,33 @@ describe('render Case Distribution Application', () => { expect(wrapper.find('#lever-history-table').exists()).toBeTruthy(); expect(wrapper.find('.inactive-data-content').exists()).toBeTruthy(); expect(wrapper.find('.lever-content').exists()).toBeTruthy(); + // the buttons and inputs will only render for admin users + expect(wrapper.find('button').exists()).toBe(true); + expect(wrapper.find('input').length > 0).toBe(true); + }); + + it('renders Case Distribution App as read-only for a non admin', () => { + const store = getStore(); + + let wrapper = mount( + + + + ); + + wrapper.update(); + + expect(wrapper.find('#lever-history-table').exists()).toBeTruthy(); + expect(wrapper.find('.inactive-data-content').exists()).toBeTruthy(); + expect(wrapper.find('.lever-content').exists()).toBeTruthy(); + // the buttons and inputs will only render for admin users + expect(wrapper.find('button').exists()).toBe(false); + expect(wrapper.find('input').length === 0).toBe(true); }); it('matches snapshot', () => { diff --git a/spec/feature/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index f9f98d49447..b3e4628e12b 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -49,76 +49,6 @@ let(:alternative_batch_size_field) { "#{Constants.DISTRIBUTION.alternative_batch_size}-field" } - context "user is in Case Distro Algorithm Control organization but not an admin" do - let!(:audit_lever_entry_1) do - create(:case_distribution_audit_lever_entry, - case_distribution_lever: ama_direct_reviews_lever, - previous_value: 10, - update_value: 15, - created_at: 5.days.ago) - end - let!(:audit_lever_entry_2) do - create(:case_distribution_audit_lever_entry, - case_distribution_lever: alternate_batch_size_lever, - previous_value: 7, - update_value: 6, - created_at: 4.days.ago) - end - let!(:audit_lever_entry_3) do - Timecop.travel(3.days.ago) 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: 2, - update_value: 4) - end - end - - it "the lever control page renders correctly and has no options to change/save values", :aggregate_failures do - step "page renders" do - visit "case-distribution-controls" - expect(page).to have_content("Case Distribution Algorithm Values") - expect(page).not_to have_button("Cancel") - expect(page).not_to have_button("Save") - - 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") - - 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 - - step "lever history displays correctly" do - 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("15 #{ama_direct_reviews_lever.unit}") - expect(find("#lever-history-table-row-0")).to have_content("5 #{ama_direct_reviews_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(alternate_batch_size_lever.title) - expect(find("#lever-history-table-row-1")).to have_content("7 #{alternate_batch_size_lever.unit}") - expect(find("#lever-history-table-row-1")).to have_content("6 #{alternate_batch_size_lever.unit}") - - expect(find("#lever-history-table-row-2")).to have_content(current_user.css_id) - expect(find("#lever-history-table-row-2")).to have_content(ama_direct_reviews_lever.title) - expect(find("#lever-history-table-row-2")).to have_content("10 #{ama_direct_reviews_lever.unit}") - expect(find("#lever-history-table-row-2")).to have_content("15 #{ama_direct_reviews_lever.unit}") - end - end - end - context "user is a Case Distro Algorithm Control admin" do before do OrganizationsUser.make_user_admin(current_user, CDAControlGroup.singleton) From 817b38c79179b6d7f96f0d5a4850bb4b79094782 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Tue, 16 Jul 2024 09:49:37 -0500 Subject: [PATCH 12/19] remove unnecessary comments, whitespace --- .../case_distribution_levers/admin_ui_spec.rb | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/spec/feature/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index b3e4628e12b..d47573b242c 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -58,7 +58,7 @@ 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" + 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 @@ -77,8 +77,7 @@ end end - step "levers initally display correctly" do - # From ama_np_dist_goals_by_docket_lever_spec.rb + 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) @@ -89,18 +88,16 @@ end step "inactive levers are displayed with values" do - # From inactive_data_elements_levers_spec.rb 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 changes resets values" do + 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: "" - # From lever_buttons_spec.rb fill_in ama_direct_reviews_field, with: "123" expect(page).to have_field(ama_direct_reviews_field, with: "123") click_cancel_button @@ -133,23 +130,20 @@ end step "error displays for invalid input on time goals section" do - # From ama_np_dist_goals_by_docket_lever_spec.rb - 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) + 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) + 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 - # From ../acd_audit_history/audit_lever_history_table_spec.rb 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 lever_buttons_spec.rb + # 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" @@ -158,7 +152,6 @@ end step "batch size lever section errors display with invalid inputs" do - # From batch_size_levers_spec.rb 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) @@ -171,21 +164,19 @@ 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) + 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 - # From batch_size_levers_spec.rb 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) + expect(page).not_to have_content(EMPTY_ERROR_MESSAGE) end step "lever history displays on page" do - # From ../acd_audit_history/audit_lever_history_table_spec.rb 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) From 49a45af07d4259cc59d1e31151feb38647dd3800 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Fri, 19 Jul 2024 07:14:21 -0500 Subject: [PATCH 13/19] restore jest folder structure --- .../caseDistribution/{ => pages}/CaseDistributionApp.test.js | 2 +- .../{ => pages}/__snapshots__/CaseDistributionApp.test.js.snap | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename client/test/app/caseDistribution/{ => pages}/CaseDistributionApp.test.js (98%) rename client/test/app/caseDistribution/{ => pages}/__snapshots__/CaseDistributionApp.test.js.snap (100%) diff --git a/client/test/app/caseDistribution/CaseDistributionApp.test.js b/client/test/app/caseDistribution/pages/CaseDistributionApp.test.js similarity index 98% rename from client/test/app/caseDistribution/CaseDistributionApp.test.js rename to client/test/app/caseDistribution/pages/CaseDistributionApp.test.js index ab90b61d585..7e14759f438 100644 --- a/client/test/app/caseDistribution/CaseDistributionApp.test.js +++ b/client/test/app/caseDistribution/pages/CaseDistributionApp.test.js @@ -7,7 +7,7 @@ import { mockDocketDistributionPriorLevers, mockDocketTimeGoalsLevers, mockStaticLevers -} from '../../data/adminCaseDistributionLevers'; +} from '../../../data/adminCaseDistributionLevers'; import { Provider } from 'react-redux'; import { createStore, applyMiddleware } from 'redux'; import rootReducer from 'app/caseDistribution/reducers/root'; diff --git a/client/test/app/caseDistribution/__snapshots__/CaseDistributionApp.test.js.snap b/client/test/app/caseDistribution/pages/__snapshots__/CaseDistributionApp.test.js.snap similarity index 100% rename from client/test/app/caseDistribution/__snapshots__/CaseDistributionApp.test.js.snap rename to client/test/app/caseDistribution/pages/__snapshots__/CaseDistributionApp.test.js.snap From f56e257419053296ed28afd4d14e3b1648fea74f Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Fri, 19 Jul 2024 08:46:18 -0500 Subject: [PATCH 14/19] modify assertions --- spec/feature/case_distribution_levers/admin_ui_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/feature/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index d47573b242c..80f48daa933 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -177,8 +177,8 @@ end step "lever history displays on page" do - 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) + expect(page).to have_content("123 days") + expect(page).to have_no_content("300 days") fill_in ama_direct_reviews_field, with: "300" click_save_button @@ -187,9 +187,9 @@ # Refresh page to validate back end saved the levers correctly visit "case-distribution-controls" - expect(find("#lever-history-table").has_content?("123 days")).to eq(true) - expect(find("#lever-history-table").has_content?("456 days")).to eq(true) - expect(find("#lever-history-table").has_content?("300 days")).to eq(true) + expect(page).to have_content("123 days") + expect(page).to have_content("456 days") + expect(page).to have_content("300 days") end end end From 55664283780270936f31183f0bcb7db6ea32e683 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Fri, 19 Jul 2024 09:15:27 -0500 Subject: [PATCH 15/19] remove TODO comment --- spec/feature/case_distribution_levers/admin_ui_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/feature/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index 80f48daa933..4c88e5f6727 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true RSpec.feature "Admin UI" do - # TODO: break this out if possible before { Seeds::CaseDistributionLevers.new.seed! } let!(:current_user) do From d26ac7b3493eff303534c0b2efce56d28aa9dedb Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Fri, 19 Jul 2024 09:22:28 -0500 Subject: [PATCH 16/19] add assertion to allow async save actions to be executed --- spec/feature/case_distribution_levers/admin_ui_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/feature/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index 4c88e5f6727..3e4ce5d0e5c 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -182,6 +182,7 @@ fill_in ama_direct_reviews_field, with: "300" click_save_button click_modal_confirm_button + expect(page).to have_content(COPY::CASE_DISTRIBUTION_SUCCESS_BANNER_TITLE) # Refresh page to validate back end saved the levers correctly visit "case-distribution-controls" From 77795a6e5307a0e3e7beb3a8fd735387916a8449 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Fri, 19 Jul 2024 10:04:19 -0500 Subject: [PATCH 17/19] add check to ensure banner is gone before trying to save --- spec/feature/case_distribution_levers/admin_ui_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/feature/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index 3e4ce5d0e5c..ee271ece0c2 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -180,6 +180,7 @@ expect(page).to have_no_content("300 days") fill_in ama_direct_reviews_field, with: "300" + expect(page).to have_no_content(COPY::CASE_DISTRIBUTION_SUCCESS_BANNER_TITLE) click_save_button click_modal_confirm_button expect(page).to have_content(COPY::CASE_DISTRIBUTION_SUCCESS_BANNER_TITLE) From 90c207b96fbf4c343511f7cb69fca7979906fb46 Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Fri, 19 Jul 2024 10:49:21 -0500 Subject: [PATCH 18/19] refactor assertions for lever history display --- .../case_distribution_levers/admin_ui_spec.rb | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/spec/feature/case_distribution_levers/admin_ui_spec.rb b/spec/feature/case_distribution_levers/admin_ui_spec.rb index ee271ece0c2..a52390941d7 100644 --- a/spec/feature/case_distribution_levers/admin_ui_spec.rb +++ b/spec/feature/case_distribution_levers/admin_ui_spec.rb @@ -148,6 +148,16 @@ 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 @@ -174,24 +184,6 @@ expect(page).not_to have_content(EMPTY_ERROR_MESSAGE) end - - step "lever history displays on page" do - expect(page).to have_content("123 days") - expect(page).to have_no_content("300 days") - - fill_in ama_direct_reviews_field, with: "300" - expect(page).to have_no_content(COPY::CASE_DISTRIBUTION_SUCCESS_BANNER_TITLE) - click_save_button - click_modal_confirm_button - expect(page).to have_content(COPY::CASE_DISTRIBUTION_SUCCESS_BANNER_TITLE) - - # Refresh page to validate back end saved the levers correctly - visit "case-distribution-controls" - - expect(page).to have_content("123 days") - expect(page).to have_content("456 days") - expect(page).to have_content("300 days") - end end end From dd9abbd2b4100441aeec39aa9cb6c284595ed35f Mon Sep 17 00:00:00 2001 From: Craig Reese Date: Tue, 23 Jul 2024 07:47:50 -0500 Subject: [PATCH 19/19] fix failing dependency report tests --- .../dependencies_report_service_log_job_spec.rb | 15 --------------- 1 file changed, 15 deletions(-) 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)