From 03dad6d200b78c71515d5ccd951073cc6460e484 Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Wed, 23 Oct 2024 17:32:30 -0400 Subject: [PATCH 01/14] Add feature test setup for all inactive appeal tasks --- .../correspondence/submit_intake_form_spec.rb | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index 02b8808b793..027a411ae37 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -240,4 +240,63 @@ end end end + + context "user adds tasks related to inactive appeals" do + let(:tasks_json) { JSON.parse!(File.read("client/constants/QUEUE_INTAKE_FORM_TASK_TYPES.json")) } + let(:inactive_appeal_tasks) { tasks_json["relatedToAppealInactive"] } + let(:inactive_appeal_tasks_count) { tasks_json["relatedToAppealInactive"].length } + let(:max_new_tasks) { 4 } + + before do + # Need to add user to BvaDispatch - new BvaDispatch tasks are automatically assigned to users + BvaDispatch.singleton.add_user(create(:user)) + + # Visit page with inactive appeals + visit_intake_form_step_2_with_inactive_appeals + existing_appeal_radio_options[:yes].click + using_wait_time(wait_time) do + within ".cf-case-list-table" do + appeal_checkboxes = page.all(".cf-form-checkbox")[0, (inactive_appeal_tasks_count / max_new_tasks).ceil] + appeal_checkboxes.each(&:click) + end + end + + # Add a new task for each existing related to inactive appeal task + add_task_buttons = page.all("#button-addTasks") + add_task_buttons.each { |button| max_new_tasks.times { button.click } } + + # Select each unique related to inactive appeal task + react_select_containers = page.all("#reactSelectContainer") + react_select_containers.each_with_index do |select_container, index| + select_container.click + using_wait_time(wait_time) do + within "div[class*=MenuList]" do + # Take out with CAVC Mail Task changes 273 - 277 + # replace line 278, exact_text: with inactive_appeal_tasks[index]["label"] + text_match = if inactive_appeal_tasks[index]["label"] == "CAVC Correspondence" + "Other Motion" + else + inactive_appeal_tasks[index]["label"] + end + find("div", exact_text: text_match).click + end + end + end + + # Fill in all the required text boxes for all tasks + task_text_content_boxes = page.all("textarea#content") + task_text_content_boxes.each { |box| box.fill_in with: "Correspondence Text" } + + click_button("Continue") + click_button("Submit") + click_button("Confirm") + using_wait_time(wait_time) do + expect(page).to have_content("You have successfully submitted a correspondence record") + end + end + + it "creates the associated mail task and mail root task" do + true + end + end end From 95a34291aa8b519c43beba0d22e07f0626a21560 Mon Sep 17 00:00:00 2001 From: SanthiParakal133 <132940479+SanthiParakal133@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:19:50 -0400 Subject: [PATCH 02/14] Deepak/appeals 56223 (#23310) * update restrictions to add task * update check_inbound_ops_team_user method * update specs * update specs --- .../tasks/cavc_correspondence_mail_task.rb | 13 +++++++ app/models/tasks/mail_task.rb | 3 +- .../correspondence/submit_intake_form_spec.rb | 39 +++++++++++++++++++ .../cavc_correspondence_mail_task_spec.rb | 15 ++++--- 4 files changed, 63 insertions(+), 7 deletions(-) diff --git a/app/models/tasks/cavc_correspondence_mail_task.rb b/app/models/tasks/cavc_correspondence_mail_task.rb index cd56d7da7de..3ecc392122e 100644 --- a/app/models/tasks/cavc_correspondence_mail_task.rb +++ b/app/models/tasks/cavc_correspondence_mail_task.rb @@ -32,9 +32,16 @@ def available_actions(user) [] end + def self.create_from_params(params, user) + @assigned_by = user + super(params, user) + end + private def cavc_appeal_stream + return if check_inbound_ops_team_user + if !appeal.cavc? fail Caseflow::Error::ActionForbiddenError, message: "CAVC Correspondence can only be added to Court Remand Appeals." @@ -42,12 +49,18 @@ def cavc_appeal_stream end def appeal_at_cavc_lit_support + return if check_inbound_ops_team_user + if !open_cavc_task fail Caseflow::Error::ActionForbiddenError, message: "CAVC Correspondence can only be added while the appeal is with CAVC Litigation Support." end end + def check_inbound_ops_team_user + InboundOpsTeam.singleton.user_has_access?(assigned_by) + end + def open_cavc_task appeal.open_cavc_task end diff --git a/app/models/tasks/mail_task.rb b/app/models/tasks/mail_task.rb index 89f0bf1fe22..5368d711b6d 100644 --- a/app/models/tasks/mail_task.rb +++ b/app/models/tasks/mail_task.rb @@ -78,7 +78,8 @@ def create_from_params(params, user) appeal: parent_task.appeal, parent_id: parent_if_blocking_task(parent_task).id, assigned_to: MailTeam.singleton, - instructions: [params[:instructions]].flatten + instructions: [params[:instructions]].flatten, + assigned_by: @assigned_by ) end diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index 027a411ae37..5af6d6d81ad 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -167,6 +167,45 @@ expect(docket_assignee.class).to eq(ClerkOfTheBoard) end end + + describe "with Cavc Correspondence Mail Task added" do + before do + visit_intake_form_step_2_with_appeals + existing_appeal_radio_options[:yes].click + + using_wait_time(wait_time) do + within ".cf-case-list-table" do + page.all(".cf-form-checkbox").last.click + end + end + + page.find("#button-addTasks").click + all("#reactSelectContainer")[0].click + find("div", exact_text: "CAVC Correspondence").click + find_by_id("content").fill_in with: "Correspondence Text" + click_button("Continue") + click_button("Submit") + click_button("Confirm") + using_wait_time(wait_time) do + expect(page).to have_content("You have successfully submitted a correspondence record") + end + end + + it "creates CavcCorrespondenceMailTask for Appeal and Corespondence" do + expect(CavcCorrespondenceMailTask.all.count).to eq(2) + appeal = Appeal.find(CavcCorrespondenceMailTask.first.appeal_id) + correspondence_appeal = CorrespondenceAppeal.find_by(appeal_id: appeal.id) + expect(appeal.tasks.count { |e| e.instance_of?(CavcCorrespondenceMailTask) }).to eq(2) + expect(correspondence_appeal.tasks.count { |e| e.instance_of?(CavcCorrespondenceMailTask) }).to eq(1) + end + + it "allows InboundOpsTeam user to assign CavcCorrespondenceMailTask to CavcLitigationSupport organization" do + assigner = User.find(CavcCorrespondenceMailTask.last.assigned_by_id) + assignee = Organization.find(CavcCorrespondenceMailTask.last.assigned_to_id) + expect(assigner.organizations).to include(InboundOpsTeam) + expect(assignee.class).to eq(CavcLitigationSupport) + end + end end describe "failure" do diff --git a/spec/models/tasks/cavc_correspondence_mail_task_spec.rb b/spec/models/tasks/cavc_correspondence_mail_task_spec.rb index 44bac308f05..2c4f134bc8b 100644 --- a/spec/models/tasks/cavc_correspondence_mail_task_spec.rb +++ b/spec/models/tasks/cavc_correspondence_mail_task_spec.rb @@ -147,8 +147,9 @@ context "on a non-CAVC Appeal Stream" do let(:root_task) { create(:root_task) } - it "fails to create the task" do - expect { subject }.to raise_error(Caseflow::Error::ActionForbiddenError) + it "create the task" do + subject + expect(CavcCorrespondenceMailTask.last.assigned_to).to eq(CavcLitigationSupport.singleton) end end @@ -159,16 +160,18 @@ context "without a CAVC task" do before { CavcTask.find_by(appeal: appeal).destroy } - it "fails to create the task" do - expect { subject }.to raise_error(Caseflow::Error::ActionForbiddenError) + it "create the task" do + subject + expect(CavcCorrespondenceMailTask.last.assigned_to).to eq(CavcLitigationSupport.singleton) end end context "after the CAVC Lit Support work is complete" do before { CavcTask.find_by(appeal: appeal).completed! } - it "fails to create the task" do - expect { subject }.to raise_error(Caseflow::Error::ActionForbiddenError) + it "create the task" do + subject + expect(CavcCorrespondenceMailTask.last.assigned_to).to eq(CavcLitigationSupport.singleton) end end From be354ecd5a19cdaf627fc00a3c846f055296b276 Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Wed, 23 Oct 2024 18:33:39 -0400 Subject: [PATCH 03/14] test for creation & association of task objs --- .../correspondence/submit_intake_form_spec.rb | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index 5af6d6d81ad..76255bb8eb8 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -310,14 +310,14 @@ select_container.click using_wait_time(wait_time) do within "div[class*=MenuList]" do - # Take out with CAVC Mail Task changes 273 - 277 - # replace line 278, exact_text: with inactive_appeal_tasks[index]["label"] - text_match = if inactive_appeal_tasks[index]["label"] == "CAVC Correspondence" - "Other Motion" - else - inactive_appeal_tasks[index]["label"] - end - find("div", exact_text: text_match).click + # # Take out with CAVC Mail Task changes 273 - 277 + # # replace line 278, exact_text: with inactive_appeal_tasks[index]["label"] + # text_match = if inactive_appeal_tasks[index]["label"] == "CAVC Correspondence" + # "Other Motion" + # else + # inactive_appeal_tasks[index]["label"] + # end + find("div", exact_text: inactive_appeal_tasks[index]["label"]).click end end end @@ -334,8 +334,14 @@ end end - it "creates the associated mail task and mail root task" do - true + it "creates and associates each task related to an inactive appeal" do + correspondence_appeals = CorrespondenceAppeal.where(correspondence_id: Correspondence.first.id) + created_tasks = correspondence_appeals.each_with_object([]) do |appeal, arr| + tasks = appeal.tasks + tasks.each { |task| arr << task.class.to_s } + end + klasses = inactive_appeal_tasks.map { |json_obj| json_obj["value"]["klass"] } + expect(klasses).to eq(created_tasks) end end end From 43282ed7007b80fba169fea9cc5ff572138bf3e7 Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Wed, 23 Oct 2024 18:34:06 -0400 Subject: [PATCH 04/14] remove comment --- .../queue/correspondence/submit_intake_form_spec.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index 76255bb8eb8..602eec0b64f 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -310,13 +310,6 @@ select_container.click using_wait_time(wait_time) do within "div[class*=MenuList]" do - # # Take out with CAVC Mail Task changes 273 - 277 - # # replace line 278, exact_text: with inactive_appeal_tasks[index]["label"] - # text_match = if inactive_appeal_tasks[index]["label"] == "CAVC Correspondence" - # "Other Motion" - # else - # inactive_appeal_tasks[index]["label"] - # end find("div", exact_text: inactive_appeal_tasks[index]["label"]).click end end From efaad17e0c0d74e5cd237f95d14c212fac74158f Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Thu, 24 Oct 2024 11:41:38 -0400 Subject: [PATCH 05/14] refactor and add more test checks --- .../correspondence/submit_intake_form_spec.rb | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index 602eec0b64f..f88c6ec627c 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -285,6 +285,8 @@ let(:inactive_appeal_tasks) { tasks_json["relatedToAppealInactive"] } let(:inactive_appeal_tasks_count) { tasks_json["relatedToAppealInactive"].length } let(:max_new_tasks) { 4 } + let(:correspondence_appeals) { CorrespondenceAppeal.where(correspondence_id: Correspondence.first.id) } + let(:created_tasks) { correspondence_appeals.map(&:tasks).flatten } before do # Need to add user to BvaDispatch - new BvaDispatch tasks are automatically assigned to users @@ -328,13 +330,20 @@ end it "creates and associates each task related to an inactive appeal" do - correspondence_appeals = CorrespondenceAppeal.where(correspondence_id: Correspondence.first.id) - created_tasks = correspondence_appeals.each_with_object([]) do |appeal, arr| - tasks = appeal.tasks - tasks.each { |task| arr << task.class.to_s } - end + created_task_strings = created_tasks.map { |task| task.class.to_s } klasses = inactive_appeal_tasks.map { |json_obj| json_obj["value"]["klass"] } - expect(klasses).to eq(created_tasks) + expect(klasses).to eq(created_task_strings) + end + + it "assigns each created task to the proper organization" do + created_tasks.each do |task| + expect(task.assigned?).to eq(true) + end + end + + it "does not change the status of appeal root tasks - appeals remain inactive" do + appeals = Correspondence.first.appeals + appeals.each { |appeal| expect(appeal.active?).to eq(false) } end end end From e99d85a1c9c98750160e0538296a22797c8cac2c Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:39:27 -0400 Subject: [PATCH 06/14] feature test updates --- .../queue/correspondence/submit_intake_form_spec.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index f88c6ec627c..119106a5aea 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -287,8 +287,15 @@ let(:max_new_tasks) { 4 } let(:correspondence_appeals) { CorrespondenceAppeal.where(correspondence_id: Correspondence.first.id) } let(:created_tasks) { correspondence_appeals.map(&:tasks).flatten } + let(:organization_assignments) do + groups_by_organization = inactive_appeal_tasks.group_by { |e| e["value"]["assigned_to"] } + groups_by_organization.each do |key, value| + new_value = value.map { |v| v["value"]["klass"] } + groups_by_organization[key] = new_value + end + end - before do + before(:all) do # Need to add user to BvaDispatch - new BvaDispatch tasks are automatically assigned to users BvaDispatch.singleton.add_user(create(:user)) @@ -337,7 +344,10 @@ it "assigns each created task to the proper organization" do created_tasks.each do |task| + org_klass_string = Organization.find(task.assigned_to_id).class.to_s expect(task.assigned?).to eq(true) + expect(task.assigned_to_type).to eq("Organization") + expect(organization_assignments[org_klass_string]).to include(task.class.to_s) end end From 8aa82d300bce0ceb8ba24cff8b98210268f534f9 Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Thu, 24 Oct 2024 15:20:56 -0400 Subject: [PATCH 07/14] combined into one it block to speed up testing --- .../queue/correspondence/submit_intake_form_spec.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index 119106a5aea..5d2c3dad1bd 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -295,7 +295,7 @@ end end - before(:all) do + before do # Need to add user to BvaDispatch - new BvaDispatch tasks are automatically assigned to users BvaDispatch.singleton.add_user(create(:user)) @@ -336,22 +336,18 @@ end end - it "creates and associates each task related to an inactive appeal" do + it "tasks are created and assigned to proper organization without changing appeal root task" do created_task_strings = created_tasks.map { |task| task.class.to_s } klasses = inactive_appeal_tasks.map { |json_obj| json_obj["value"]["klass"] } expect(klasses).to eq(created_task_strings) - end - it "assigns each created task to the proper organization" do created_tasks.each do |task| org_klass_string = Organization.find(task.assigned_to_id).class.to_s expect(task.assigned?).to eq(true) expect(task.assigned_to_type).to eq("Organization") expect(organization_assignments[org_klass_string]).to include(task.class.to_s) end - end - it "does not change the status of appeal root tasks - appeals remain inactive" do appeals = Correspondence.first.appeals appeals.each { |appeal| expect(appeal.active?).to eq(false) } end From ff1a1a0cd15535ea117925e083868f249ba458ec Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:40:50 -0400 Subject: [PATCH 08/14] Add BvaDispatch task exception --- .../queue/correspondence/submit_intake_form_spec.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index 5d2c3dad1bd..f4f646c264c 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -343,9 +343,17 @@ created_tasks.each do |task| org_klass_string = Organization.find(task.assigned_to_id).class.to_s - expect(task.assigned?).to eq(true) + task_klass_string = task.class.to_s + + # BvaDispatch tasks are automatically assigned to a BvaDispatch user + if organization_assignments["BvaDispatch"].include?(task_klass_string) + expect(task.assigned?).to eq(true) + else + expect(task.on_hold?).to eq(true) + end + expect(task.assigned_to_type).to eq("Organization") - expect(organization_assignments[org_klass_string]).to include(task.class.to_s) + expect(organization_assignments[org_klass_string]).to include(task_klass_string) end appeals = Correspondence.first.appeals From 21c8d35c2da205126f4c6d5e3c1417fb04e76beb Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:44:11 -0400 Subject: [PATCH 09/14] correct conditional stmt --- spec/feature/queue/correspondence/submit_intake_form_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index f4f646c264c..7d8651f458c 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -347,9 +347,9 @@ # BvaDispatch tasks are automatically assigned to a BvaDispatch user if organization_assignments["BvaDispatch"].include?(task_klass_string) - expect(task.assigned?).to eq(true) - else expect(task.on_hold?).to eq(true) + else + expect(task.assigned?).to eq(true) end expect(task.assigned_to_type).to eq("Organization") From 5c2904f4e75174eb9e30938ce1fab6c429bd40e3 Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:50:33 -0400 Subject: [PATCH 10/14] added retry helper method when element not found --- spec/support/correspondence_helpers.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/support/correspondence_helpers.rb b/spec/support/correspondence_helpers.rb index 89961127c56..d7d1e0a2430 100644 --- a/spec/support/correspondence_helpers.rb +++ b/spec/support/correspondence_helpers.rb @@ -193,5 +193,16 @@ def inbound_ops_team_admin_setup User.authenticate!(user: current_user) end + def retry_if_not_found(max_attempts: 3, cleanup: nil) + attempts = 0 + begin + yield + rescue Capybara::ElementNotFound + attempts += 1 + cleanup&.call + retry if attempts < max_attempts + end + end + # rubocop:enable Metrics/ModuleLength end From 6ea4ff0ebc80667421951b391c1b72adddcccaa4 Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:50:48 -0400 Subject: [PATCH 11/14] Wrap flaky portion of test in retry block --- .../queue/correspondence/submit_intake_form_spec.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index 7d8651f458c..ad504aa259b 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -316,10 +316,13 @@ # Select each unique related to inactive appeal task react_select_containers = page.all("#reactSelectContainer") react_select_containers.each_with_index do |select_container, index| - select_container.click using_wait_time(wait_time) do - within "div[class*=MenuList]" do - find("div", exact_text: inactive_appeal_tasks[index]["label"]).click + retry_if_not_found(cleanup: find("body").click) do + select_container.click + expect(page).to have_selector("div[class*=MenuList]", visible: true) + within "div[class*=MenuList]" do + find("div", exact_text: inactive_appeal_tasks[index]["label"]).click + end end end end From e1967fae54a49b5755008f725a172dafb0ee9503 Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:07:16 -0400 Subject: [PATCH 12/14] define action in method --- spec/feature/queue/correspondence/submit_intake_form_spec.rb | 2 +- spec/support/correspondence_helpers.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index ad504aa259b..649da041eb7 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -317,7 +317,7 @@ react_select_containers = page.all("#reactSelectContainer") react_select_containers.each_with_index do |select_container, index| using_wait_time(wait_time) do - retry_if_not_found(cleanup: find("body").click) do + retry_if_not_found(cleanup: click_page_body) do select_container.click expect(page).to have_selector("div[class*=MenuList]", visible: true) within "div[class*=MenuList]" do diff --git a/spec/support/correspondence_helpers.rb b/spec/support/correspondence_helpers.rb index d7d1e0a2430..29b27503a20 100644 --- a/spec/support/correspondence_helpers.rb +++ b/spec/support/correspondence_helpers.rb @@ -204,5 +204,9 @@ def retry_if_not_found(max_attempts: 3, cleanup: nil) end end + def click_page_body + find("body").click + end + # rubocop:enable Metrics/ModuleLength end From d9705f028cec2cac9e1d7698c8613195ecee1365 Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Fri, 25 Oct 2024 15:52:52 -0400 Subject: [PATCH 13/14] add logging to retry --- spec/support/correspondence_helpers.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/support/correspondence_helpers.rb b/spec/support/correspondence_helpers.rb index 29b27503a20..1aa16bf992f 100644 --- a/spec/support/correspondence_helpers.rb +++ b/spec/support/correspondence_helpers.rb @@ -194,11 +194,12 @@ def inbound_ops_team_admin_setup end def retry_if_not_found(max_attempts: 3, cleanup: nil) - attempts = 0 + attempts ||= 0 begin yield - rescue Capybara::ElementNotFound + rescue Capybara::ElementNotFound => e attempts += 1 + Rails.logger.warn("#{e} caught. Retry attempt: #{attempts}") cleanup&.call retry if attempts < max_attempts end From 626a657a9f645be5919cf5aee98f7ac5f245a3a0 Mon Sep 17 00:00:00 2001 From: Kevin Ma <104021955+Kevma50287@users.noreply.github.com> Date: Fri, 25 Oct 2024 15:54:31 -0400 Subject: [PATCH 14/14] update test --- .../queue/correspondence/submit_intake_form_spec.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/spec/feature/queue/correspondence/submit_intake_form_spec.rb b/spec/feature/queue/correspondence/submit_intake_form_spec.rb index 649da041eb7..7e3999246a5 100644 --- a/spec/feature/queue/correspondence/submit_intake_form_spec.rb +++ b/spec/feature/queue/correspondence/submit_intake_form_spec.rb @@ -316,13 +316,10 @@ # Select each unique related to inactive appeal task react_select_containers = page.all("#reactSelectContainer") react_select_containers.each_with_index do |select_container, index| - using_wait_time(wait_time) do - retry_if_not_found(cleanup: click_page_body) do + retry_if_not_found(cleanup: click_page_body) do + using_wait_time(wait_time) do select_container.click - expect(page).to have_selector("div[class*=MenuList]", visible: true) - within "div[class*=MenuList]" do - find("div", exact_text: inactive_appeal_tasks[index]["label"]).click - end + find("div", exact_text: inactive_appeal_tasks[index]["label"]).click end end end