Skip to content

Commit

Permalink
RSpec to replicate duplicate JudgeAssignTasks problem (#16382)
Browse files Browse the repository at this point in the history
* RSpec to replicate problem
* lint
* refactor
  • Loading branch information
yoomlam committed Jun 22, 2021
1 parent d851a61 commit 44618a8
Show file tree
Hide file tree
Showing 2 changed files with 1,373 additions and 0 deletions.
71 changes: 71 additions & 0 deletions spec/fixes/investigate_duplicate_judge_assign_task_spec.rb
@@ -0,0 +1,71 @@
# frozen_string_literal: true

require "helpers/sanitized_json_configuration.rb"
require "helpers/sanitized_json_importer.rb"

# required to load `explain` endpoint in an RSpec
require "helpers/sanitized_json_exporter.rb"
require "helpers/intake_renderer.rb"

feature "duplicate JudgeAssignTask investigation" do
before do
User.authenticate!(css_id: "PETERSBVAM")
Functions.grant!("System Admin", users: ["PETERSBVAM"]) # enable access to `export` endpoint
end

# Ticket: https://github.com/department-of-veterans-affairs/dsva-vacols/issues/174
# Target state: should only have 1 open JudgeAssignTask
describe "Judge cancels AttorneyTask in 2 browser windows" do
let!(:appeal) do
sji = SanitizedJsonImporter.from_file("spec/records/appeal-121304-dup_jatasks.json", verbosity: 0)
sji.import
appeal = sji.imported_records[Appeal.table_name].first

judge = User.find_by_css_id("PETERSBVAM")
create(:staff, :judge_role, user: judge)

appeal.reload
end

scenario "Caseflow creates 2 open JudgeAssignTasks" do
within_window open_new_window do
# Get a narrative of what happened; search for ":50:38" and ":50:44"
visit "/explain/appeals/#{appeal.uuid}"
expect(page).to have_content("Narrative table")
end

# Delete tasks created on or after 2021-06-13 so we can recreate the problem
appeal.tasks.where("created_at >= ?", "2021-06-13").delete_all
# Set task status so that user as task actions
Task.find(2_001_437_274).assigned!
Task.find(2_001_437_273).on_hold!

# In first window
visit "/queue/appeals/#{appeal.uuid}"

# Open another window to the same page
second_window = open_new_window
within_window second_window do
visit "/queue/appeals/#{appeal.uuid}"
end

# Back in first window
click_dropdown(prompt: "Select an action", text: "Cancel task and return to judge")
fill_in(COPY::ADD_COLOCATED_TASK_INSTRUCTIONS_LABEL, with: "cancel once")
click_on "Submit"
expect(page).to have_content("case has been cancelled")

# Repeat same actions in second_window
within_window second_window do
click_dropdown(prompt: "Select an action", text: "Cancel task and return to judge")
fill_in(COPY::ADD_COLOCATED_TASK_INSTRUCTIONS_LABEL, with: "cancel once")
click_on "Submit"
expect(page).to have_content("case has been cancelled")
end

# Notice there are 2 open JudgeAssignTasks
appeal.reload.treee
# binding.pry # Uncomment to examine the browser tabs
end
end
end

0 comments on commit 44618a8

Please sign in to comment.