Skip to content

Commit

Permalink
APPEALS-24999 First pass at feature tests for 24999 and 27763
Browse files Browse the repository at this point in the history
  • Loading branch information
jefftmarks committed Aug 15, 2023
1 parent 749e509 commit 01686b3
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def hide_from_case_timeline
assigned_to.type == "MailTeam"
end

def recent_hearing
@recent_hearing ||= open_assign_hearing_disposition_task&.hearing
def open_hearing
@open_hearing ||= open_assign_hearing_disposition_task&.hearing
end

def hearing_task
@hearing_task ||= recent_hearing&.hearing_task || active_schedule_hearing_task&.parent
@hearing_task ||= open_hearing&.hearing_task || active_schedule_hearing_task&.parent
end

private
Expand All @@ -90,16 +90,16 @@ def open_assign_hearing_disposition_task

# Associated appeal has an upcoming hearing with an open status
def hearing_scheduled_and_awaiting_disposition?
return false if recent_hearing.nil?
return false if open_hearing.nil?

# Ensure associated hearing is not scheduled for the past
!recent_hearing.scheduled_for_past?
!open_hearing.scheduled_for_past?
end

def update_hearing_and_create_tasks(after_disposition_update)
multi_transaction do
# If hearing exists, postpone previous hearing and handle conference links
unless recent_hearing.nil?
unless open_hearing.nil?
update_hearing(disposition: Constants.HEARING_DISPOSITION_TYPES.postponed)
clean_up_virtual_hearing
end
Expand All @@ -108,17 +108,16 @@ def update_hearing_and_create_tasks(after_disposition_update)
end
end


def update_hearing(hearing_hash)
if recent_hearing.is_a?(LegacyHearing)
recent_hearing.update_caseflow_and_vacols(hearing_hash)
if open_hearing.is_a?(LegacyHearing)
open_hearing.update_caseflow_and_vacols(hearing_hash)
else
recent_hearing.update(hearing_hash)
open_hearing.update(hearing_hash)
end
end

def clean_up_virtual_hearing
if recent_hearing.virtual?
if open_hearing.virtual?
perform_later_or_now(VirtualHearings::DeleteConferencesJob)
end
end
Expand Down
141 changes: 124 additions & 17 deletions spec/feature/queue/mail_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
HearingAdmin.singleton.add_user(User.current_user)
end
let(:hpr_task) { create(:hearing_postponement_request_mail_task, :with_unscheduled_hearing, assigned_by_id: User.system_user.id) }
let(:appeal) { hpr_task.appeal }

context "changing task type" do
it "submit button starts out disabled" do
Expand Down Expand Up @@ -271,30 +272,136 @@
end
end

context "Ruling is Granted" do
context "scheduling a veteran immediately" do
it "schedule a veteran" do
FeatureToggle.enable!(:schedule_veteran_virtual_hearing)
p = "queue/appeals/#{hpr_task.appeal.uuid}"
visit(p)
click_dropdown(prompt: COPY::TASK_ACTION_DROPDOWN_BOX_LABEL,
text: "Mark as complete")
find(".cf-form-radio-option", text: "Granted").click
fill_in("rulingDateSelector", with: "08/15/2023")
find(:css, ".cf-form-radio-option label", text: "Reschedule immediately").click
fill_in("instructionsField", with: "instructions")
click_button("Mark as complete")
expect(page.current_path).to eq("/queue/appeals/#{hpr_task.appeal.uuid}/tasks/#{hpr_task.id}/modal/complete_and_postpone")
context "mark as complete" do
let(:ruling_date) { "08/15/2023" }
let(:instructions) { "instructions" }

shared_examples "whether granted or denied" do
it "completes HearingPostponementRequestMailTask on Case Timeline" do
hpr_task = find("#case-timeline-table tr:nth-child(1)")

expect(hpr_task).to have_content("COMPLETED ON\n#{hpr_task.updated_at.strftime('%m/%d/%Y')}")
expect(hpr_task).to have_content("HearingPostponementRequestMailTask completed")
expect(hpr_task).to have_content("COMPLETED BY\n#{User.current_user.css_id}")
end

it "updates instructions of HearingPostponementRequestMailTask on Case Timeline" do
find(:css, "#case-timeline-table .cf-btn-link", text: "View task instructions", match: :first).click
instructions = find("div", class: ".task-instructions")

expect(instructions).to have_content("Motion to postpone #{ruling}")
expect(instructions).to have_content("DATE OF RULING\n#{ruling_date}")
expect(instructions).to have_content("INSTRUCTIONS\n#{instructions}")
end
end

context "sending to schedule veteran list" do
context "ruling is granted" do
let(:ruling) { "GRANTED"}

context "scheduling a veteran immediately" do
# it "schedule a veteran" do
# FeatureToggle.enable!(:schedule_veteran_virtual_hearing)
# p = "queue/appeals/#{hpr_task.appeal.uuid}"
# visit(p)
# click_dropdown(prompt: COPY::TASK_ACTION_DROPDOWN_BOX_LABEL,
# text: "Mark as complete")
# find(".cf-form-radio-option", text: "Granted").click
# fill_in("rulingDateSelector", with: "08/15/2023")
# find(:css, ".cf-form-radio-option label", text: "Reschedule immediately").click
# fill_in("instructionsField", with: "instructions")
# click_button("Mark as complete")
# expect(page.current_path).to eq("/queue/appeals/#{hpr_task.appeal.uuid}/tasks/#{hpr_task.id}/modal/complete_and_postpone")
# end
end

context "send to schedule veteran list" do
before :each do
FeatureToggle.enable!(:schedule_veteran_virtual_hearing)
page = "queue/appeals/#{appeal.uuid}"
visit(page)
click_dropdown(prompt: COPY::TASK_ACTION_DROPDOWN_BOX_LABEL,
text: Constants.TASK_ACTIONS.COMPLETE_AND_POSTPONE.label)
find(".cf-form-radio-option", text: "Granted").click
fill_in("rulingDateSelector", with: ruling_date)
find(:css, ".cf-form-radio-option label", text: "Send to Schedule Veteran list").click
fill_in("instructionsField", with: instructions)
click_button("Mark as complete")
end

shared_examples "whether or not appeal has scheduled hearing" do
it "creates new ScheduleHearing task under Task Actions" do
new_task = appeal.tasks.last
most_recent_task = find("tr", text: "TASK", match: :first)
expect(most_recent_task).to have_content("ASSIGNED ON\n#{new_task.assigned_at.strftime('%m/%d/%Y')}")
expect(most_recent_task).to have_content("TASK\nSchedule hearing")
end

it "cancels Hearing task on Case Timeline" do
hearing_task = find("#case-timeline-table tr:nth-child(2)")

expect(hearing_task).to have_content("CANCELLED ON\n#{hpr_task.updated_at.strftime('%m/%d/%Y')}")
expect(hearing_task).to have_content("HearingTask cancelled")
expect(hearing_task).to have_content("CANCELLED BY\n#{User.current_user.css_id}")
end
end

context "appeal has unscheduled hearing" do
let(:hpr_task) do
create(:hearing_postponement_request_mail_task,
:with_unscheduled_hearing,
assigned_by_id: User.system_user.id)
end

include_examples "whether granted or denied"
include_examples "whether or not appeal has scheduled hearing"

it "cancels ScheduleHearing task on Case Timeline" do
schedule_task = find("#case-timeline-table tr:nth-child(3)")

expect(schedule_task).to have_content("CANCELLED ON\n#{hpr_task.updated_at.strftime('%m/%d/%Y')}")
expect(schedule_task).to have_content("ScheduleHearingTask cancelled")
expect(schedule_task).to have_content("CANCELLED BY\n#{User.current_user.css_id}")
end
end

context "appeal has scheduled hearing" do
let(:hpr_task) do
create(:hearing_postponement_request_mail_task,
:with_scheduled_hearing,
assigned_by_id: User.system_user.id)
end

include_examples "whether granted or denied"
include_examples "whether or not appeal has scheduled hearing"

it "cancels AssignHearingDisposition task on Case Timeline" do
disposition_task = find("#case-timeline-table tr:nth-child(3)")

expect(disposition_task).to have_content("CANCELLED ON\n#{hpr_task.updated_at.strftime('%m/%d/%Y')}")
expect(disposition_task).to have_content("AssignHearingDispositionTask cancelled")
expect(disposition_task).to have_content("CANCELLED BY\n#{User.current_user.css_id}")
end
end
end
end
end

context "Ruling is Denied" do
context "ruling is denied" do
let(:ruling) { "DENIED" }

before do
FeatureToggle.enable!(:schedule_veteran_virtual_hearing)
page = "queue/appeals/#{appeal.uuid}"
visit(page)
click_dropdown(prompt: COPY::TASK_ACTION_DROPDOWN_BOX_LABEL,
text: Constants.TASK_ACTIONS.COMPLETE_AND_POSTPONE.label)
find(".cf-form-radio-option", text: "Denied").click
fill_in("rulingDateSelector", with: ruling_date)
fill_in("instructionsField", with: instructions)
click_button("Mark as complete")
end

include_examples "whether granted or denied"
end
end
end
end

0 comments on commit 01686b3

Please sign in to comment.