Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

akonhilas/APPEALS-40915 #20948

Merged
merged 23 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ebf5b15
APPEALS-40915: initial commit
konhilas-ariana Feb 26, 2024
b3270a0
APPEALS-40909 Create migration and write spec tests
jefftmarks Feb 26, 2024
ad32a20
APPEALS-40909 Update conference_link model to associate with polymorp…
jefftmarks Feb 26, 2024
6026be8
APPEALS-40909 Write spec for add index to conference links
jefftmarks Feb 27, 2024
d322ecf
APPEALS-40909 Add spec to test conference link factory after null con…
jefftmarks Feb 27, 2024
99c3015
APPEALS-40909 Uncomment out code in migration to see if tests pass on…
jefftmarks Feb 27, 2024
4afa1b3
APPEALS-40915: updated comments to job
konhilas-ariana Feb 27, 2024
3bfde82
APPEALS-40909 Implement database cleaner fix and write down test for …
jefftmarks Feb 28, 2024
006a71d
APPEALS-40915: added error catching, updated hearing model, removed w…
konhilas-ariana Feb 28, 2024
5f1722e
APPEALS-40915: updated existing rspec tests to include/exclude new f…
konhilas-ariana Feb 28, 2024
10b464d
APPEALS-40909 Test conference links can belong to hearings and hearin…
adam-ducker Feb 29, 2024
cd9e845
APPEALS-40915: prepping branch for merge
konhilas-ariana Feb 29, 2024
53651d7
Merge branch 'jefftmarks/APPEALS-40909' into akonhilas/APPEALS-40915
konhilas-ariana Feb 29, 2024
8618845
Merge branch 'jefftmarks/APPEALS-40909' into akonhilas/APPEALS-40915
konhilas-ariana Feb 29, 2024
871cae4
APPEALS-40915: job creates a hearing conference link
konhilas-ariana Feb 29, 2024
c8315ba
APPEALS-40915: updating rspecs
konhilas-ariana Mar 1, 2024
aa0e340
APPEALS-40915: finished rspecs
konhilas-ariana Mar 4, 2024
d27e79d
APPEALS-40915: nullifying link values to resolve frontend errors
konhilas-ariana Mar 4, 2024
eb59f07
APPEALS-40915: added create nv conf call to correct spot, removed old…
konhilas-ariana Mar 6, 2024
8e010d5
APPEALS-40915: final rspec addition
konhilas-ariana Mar 7, 2024
56aaee4
Merge branch 'feature/APPEALS-25121' into akonhilas/APPEALS-40915
konhilas-ariana Mar 7, 2024
a5fddb9
APPEALS-40915: remove migration specs
konhilas-ariana Mar 7, 2024
5a1df08
APPEALS-40915: add code review updates
konhilas-ariana Mar 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/jobs/hearings/create_non_virtual_conference_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

# This job creates a Webex conference & link for a non virtual hearing

class Hearings::CreateNonVirtualConferenceJob < CaseflowJob
include Hearings::EnsureCurrentUserIsSet

queue_with_priority :high_priority
application_attr :hearing_schedule
attr_reader :hearing

# Retry if Webex returns an invalid response.
retry_on(Caseflow::Error::WebexApiError, wait: :exponentially_longer) do |job, exception|
job.log_error(exception)
end

def perform(hearing:)
ensure_current_user_is_set
WebexConferenceLink.find_or_create_by!(
hearing_id: hearing.id,
hearing_type: hearing.readable_request_type,
hearing: hearing,
created_by: hearing.created_by
)
end
end
12 changes: 12 additions & 0 deletions app/models/hearing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,18 @@ def serialized_email_events
end
end

def subject_for_conference
"#{docket_number}_#{id}_#{self.class}"
end

def nbf
scheduled_for.beginning_of_day.to_i
end

def exp
scheduled_for.end_of_day.to_i
end

private

def update_appeal_states_on_hearing_create
Expand Down
7 changes: 0 additions & 7 deletions app/models/hearing_day.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,6 @@ def find_or_create_conference_links!
created_by: created_by
)
end

if FeatureToggle.enabled?(:webex_conference_service)
links << WebexConferenceLink.find_or_create_by!(
hearing_day: self,
created_by: created_by
)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/hearings/webex_conference_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def generate_conference_information
apikey: ENV["WEBEX_BOTTOKEN"],
domain: ENV["WEBEX_DOMAIN_IC"],
api_endpoint: ENV["WEBEX_API_IC"]
).create_conference(hearing_day)
).create_conference(hearing)

update!(
host_link: conference_response.host_link,
Expand Down
19 changes: 19 additions & 0 deletions app/models/tasks/schedule_hearing_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ def create_schedule_hearing_tasks(params)
# Create and assign the hearing now that it has been scheduled
created_tasks << AssignHearingDispositionTask.create_assign_hearing_disposition_task!(appeal, parent, hearing)

# Starts the process to create the one to one webex conference room for a non virtual hearing
maybe_create_non_virtual_conference

# The only other option is to cancel the schedule hearing task
elsif params[:status] == Constants.TASK_STATUSES.cancelled
# If we are cancelling the schedule hearing task, we need to withdraw the request
Expand Down Expand Up @@ -272,4 +275,20 @@ def create_hearing(task_values)
def set_assignee
self.assigned_to ||= Bva.singleton
end

def start_non_virtual_hearing_job?
hearing.disposition.nil? &&
hearing.conference_provider == "webex" &&
hearing.virtual_hearing.nil? &&
ConferenceLink.find_by(hearing_id: hearing.id).nil?
end

def start_non_virtual_hearing_job
perform_later_or_now(Hearings::CreateNonVirtualConferenceJob, hearing: hearing)
end

# Complexity of create schedule hearing task was too large - had to break out
def maybe_create_non_virtual_conference
start_non_virtual_hearing_job if start_non_virtual_hearing_job?
end
end
3 changes: 2 additions & 1 deletion client/app/hearings/components/VirtualHearingLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const VirtualHearingLink = ({
}) => {
return (
<Link
href={isVirtual ? link : hearing.dailyDocketConferenceLinks[1].coHostLink}
// TODO: Update null for non virtual hearing link
href={isVirtual ? link : null}
target={newWindow ? '_blank' : '_self'}
>
<strong>{label}</strong>
Expand Down
3 changes: 2 additions & 1 deletion client/app/hearings/components/details/HearingLinks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ export const HearingLinks = ({ hearing, virtualHearing, isVirtual, wasVirtual, u
hearing={hearing}
isVirtual={isVirtual}
label={COPY.HC_VIRTUAL_HEARING_LINK_LABEL}
link={hearing.dailyDocketConferenceLinks[1].coHostLink}
// TODO: update here for non virtual hearing links
link={null}
linkText={COPY.VLJ_VIRTUAL_HEARINGS_LINK_TEXT}
role="HC"
user={user}
Expand Down
43 changes: 43 additions & 0 deletions spec/jobs/hearings/create_non_virtual_conference_job_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# frozen_string_literal: true

describe Hearings::CreateNonVirtualConferenceJob, type: :job do
include ActiveJob::TestHelper
let(:nyc_ro_eastern) { "RO06" }
let(:video_type) { HearingDay::REQUEST_TYPES[:video] }
let(:hearing_day) { create(:hearing_day, regional_office: nyc_ro_eastern, request_type: video_type) }
let!(:hearing) do
create(:hearing, hearing_day: hearing_day).tap do |hearing|
hearing.meeting_type.update(service_name: "webex")
end
end

subject { described_class.perform_now(hearing: hearing) }

context "Non Virtual Hearing" do
it "creates a conference for the hearing" do
subject
conference_link = ConferenceLink.find_by(hearing_id: hearing.id)
expect(conference_link.hearing_id).to eq(hearing.id)
end
end

context "job errors" do
before do
allow_any_instance_of(WebexService)
.to receive(:create_conference)
.with(hearing)
.and_raise(Caseflow::Error::WebexApiError.new(code: 400, message: "Fake Error"))
end

it "Successfully catches errors and adds to retry queue" do
subject
expect(enqueued_jobs.size).to eq(1)
end

it "retries and logs errors" do
subject
expect(Rails.logger).to receive(:error).twice
perform_enqueued_jobs { described_class.perform_later(hearing: hearing) }
end
end
end
58 changes: 2 additions & 56 deletions spec/models/hearing_day_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -582,52 +582,6 @@ def format_begins_at_from_db(time_string, scheduled_for)
expect(subject).to eq []
end
end

context "Only the Webex service is disabled" do
before { FeatureToggle.enable!(:webex_conference_service) }

it "Only the Webex conference link is generated whenever requested" do
expect(subject).to eq []
end
end
end

context "#subject_for_conference" do
include_context "Enable both conference services"

let(:assigned_date) { "Sep 21, 2023" }
let(:id) { 2_000_006_656 }
let(:expected_date_parsed) { Date.parse(assigned_date) }
let(:hearing_day) do
build(
:hearing_day,
scheduled_for: expected_date_parsed,
id: id
)
end

subject { hearing_day.subject_for_conference }

it "returns the expected meeting conference details" do
expected_date = "09 21, 2023"
is_expected.to eq("#{hearing_day.id}_#{expected_date}")
end

context "nbf and exp" do
subject { hearing_day.nbf }

it "returns correct nbf" do
expect subject == 1_695_254_400
end

before do
subject { hearing_day.exp }
end

it "returns correct exp" do
expect subject == 1_695_340_799
end
end
end

context "hearing day in the future, conference link doesnt exist" do
Expand All @@ -650,9 +604,9 @@ def format_begins_at_from_db(time_string, scheduled_for)
FeatureToggle.enable!(:webex_conference_service)
end

it "Both conference links are created whenever requested" do
it "Only pexip conference links are created for the entire hearing day requested" do
expect(subject.pluck(:type)).to match_array(
[PexipConferenceLink.name, WebexConferenceLink.name]
[PexipConferenceLink.name]
)
end
end
Expand All @@ -670,13 +624,5 @@ def format_begins_at_from_db(time_string, scheduled_for)
expect(subject.pluck(:type)).to match_array [PexipConferenceLink.name]
end
end

context "Only the Webex service is disabled" do
before { FeatureToggle.enable!(:webex_conference_service) }

it "Only the Webex conference link is generated whenever requested" do
expect(subject.pluck(:type)).to match_array [WebexConferenceLink.name]
end
end
end
end
11 changes: 11 additions & 0 deletions spec/models/hearing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,15 @@
expect(hearing.daily_docket_conference_links).to eq(conference_links)
end
end

context "correct subject nbf and exp" do
let(:hearing_day) { create(:hearing_day) }
let(:hearing) { create(:hearing, hearing_day: hearing_day) }

it "sub nbf and exp are correct" do
expect(hearing.subject_for_conference).to eq("#{hearing.docket_number}_#{hearing.id}_#{hearing.class}")
expect(hearing.nbf).to eq(hearing.scheduled_for.beginning_of_day.to_i)
expect(hearing.exp).to eq(hearing.scheduled_for.end_of_day.to_i)
end
end
end
15 changes: 15 additions & 0 deletions spec/models/tasks/schedule_hearing_task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@
end
end

context "for non virtual hearings scheduled by a webex users" do
before do
hearings_management_user.meeting_type.update!(service_name: "webex")
end
it "creates a webex conference associated to the hearing" do
subject
conference_link = ConferenceLink.find_by(hearing_id: Hearing.first.id)
expect(Hearing.count).to eq(1)
expect(Hearing.first.virtual?).to eq(false)
expect(Hearing.first.virtual_hearing).to eq(nil)
expect(conference_link.nil?).to eq(false)
expect(conference_link.host_link).to include("instant-usgov.webex.com")
end
end

context "when params includes virtual_hearing_attributes" do
let(:appellant_email) { "fake@email.com" }
let(:virtual_hearing_attributes) do
Expand Down
3 changes: 2 additions & 1 deletion spec/serializers/conference_link_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
end

let(:hearing_day) { create(:hearing_day) }
let(:hearing) { create(:hearing) }

shared_examples "Serialized conferenced link attributes meet expectations" do
it "calling serializable_hash gets result" do
Expand Down Expand Up @@ -40,7 +41,7 @@
end

context "With a Webex conference link" do
let(:conference_link) { create(:webex_conference_link, hearing_day: hearing_day) }
let(:conference_link) { create(:webex_conference_link, hearing: hearing) }

include_examples "Serialized conferenced link attributes meet expectations"
end
Expand Down
Loading