Skip to content

Commit

Permalink
APPEALS-51237, APPEALS-51536: Optimize feature tests in intake/appeal…
Browse files Browse the repository at this point in the history
…/edit_spec.rb and optimize automatic case distribution tests (#22280)

* refactoring edit_spec

* move one assertion and remove duplicate test

* refactor withdraw issues context

* move duplicate test assertions

* move duplicate test assertions to existing tests and remove duplicate tests

* move assertion and remove duplicate test

* consolidate SCT appeal tests

* refactor SCT tests to use step blocks

* consolidate a individual test into a step

* move CC appeal task tests to appeals_controller_spec intead of a feature test

* remove unnecessary code comments

* consolidate member not admin tests

* remove commented portions of test

* move tests from affinity_days_levers_spec.rb

* move tests from affinity_days_levers_spec.rb, last commit was from audit_lever_history_table_spec.rb

* remove ama_np_dist_goals_by_docket_lever_spec.rb

* remove batch_size_levers_spec.rb

* remove inactive_data_elements_levers_spec.rb

* remove lever_buttons_spec.rb

* refactor

* move jest file for convention, add snapshot

* move test for admin ui not interactable for non-admins to a jest test

* remove unnecessary comments, whitespace

* restore jest folder structure

* modify edit spec to use case details page instead of searching again

* modify assertions

* remove TODO comment

* add assertion to allow async save actions to be executed

* add check to ensure banner is gone before trying to save

* refactor assertions for lever history display

* fix failing dependency report tests
  • Loading branch information
craigrva authored and AdamShawBAH committed Aug 8, 2024
1 parent 81a0486 commit e9c6c94
Show file tree
Hide file tree
Showing 11 changed files with 880 additions and 1,573 deletions.
20 changes: 14 additions & 6 deletions client/test/app/caseDistribution/pages/CaseDistributionApp.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
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';
Expand All @@ -14,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(() => {
Expand All @@ -33,7 +41,7 @@ describe('render Case Distribution Application', () => {
<CaseDistributionApp
acdLeversForStore={testLevers}
acd_levers={testLevers}
acd_history={[]}
acd_history={leverHistory}
user_is_an_acd_admin
/>
</Provider>
Expand Down
157 changes: 156 additions & 1 deletion spec/controllers/appeals_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ def allow_vbms_to_return_empty_array
end

describe "POST update" do
context "AMA Appeal" do
context "AMA Appeal updates for MST/PACT issues" do
before do
User.authenticate!(roles: ["System Admin"])
Fakes::Initializer.load!
Expand Down Expand Up @@ -1059,5 +1059,160 @@ def allow_vbms_to_return_empty_array
expect(response).to be_successful
end
end

context "Adding a contested claim issue" do
let!(:current_user) { User.authenticate!(roles: ["Mail Intake"]) }
let!(:appeal) do
create(:appeal, :with_post_intake_tasks, docket_type: docket)
end
let(:docket) { nil }

before do
User.authenticate!(user: current_user)
end

subject do
post :update, params: {
request_issues: [
{
benefit_type: "compensation",
nonrating_issue_category: "Contested Claims - Attorney Fees",
decision_text: "Test Issue",
decision_date: 1.week.ago.to_date,
ineligible_due_to_id: nil,
ineligible_reason: nil,
withdrawal_date: nil,
is_predocket_needed: nil,
mst_status: false,
pact_status: false
}
],
controller: "appeals",
action: "update",
appeal_id: appeal.uuid
}
end

context "with the feature toggle off" do
let(:docket) { Constants.AMA_DOCKETS.direct_review }

it "does not create a SendInitialNotificationLetterTask" do
expect_any_instance_of(AppealsController).to_not receive(:send_initial_notification_letter)

subject
task = Task.find_by(type: SendInitialNotificationLetterTask.name, appeal: appeal)

expect(task).to be nil
end
end

context "with the feature toggle on" do
before do
FeatureToggle.enable!(:cc_appeal_workflow)
FeatureToggle.enable!(:indicator_for_contested_claims)
ClerkOfTheBoard.singleton
end

after do
FeatureToggle.disable!(:cc_appeal_workflow)
FeatureToggle.disable!(:indicator_for_contested_claims)
end

context "to a direct review docket appeal" do
let(:docket) { Constants.AMA_DOCKETS.direct_review }

it "creates SendInitialNotificationLetterTask as child of DistributionTask" do
subject
task = Task.find_by(type: SendInitialNotificationLetterTask.name, appeal: appeal)

expect(response).to be_successful
expect(task.present?).to be true
expect(task.parent.type).to eq DistributionTask.name
expect(task.assigned_to).to eq ClerkOfTheBoard.singleton
expect(task.assigned_by).to eq current_user
end
end

context "to an evidence submission docket appeal" do
let(:docket) { Constants.AMA_DOCKETS.evidence_submission }

it "creates SendInitialNotificationLetterTask as child of EvidenceSubmissionWindowTask" do
subject
task = Task.find_by(type: SendInitialNotificationLetterTask.name, appeal: appeal)

expect(response).to be_successful
expect(task.present?).to be true
expect(task.parent.type).to eq EvidenceSubmissionWindowTask.name
expect(task.assigned_to).to eq ClerkOfTheBoard.singleton
expect(task.assigned_by).to eq current_user
end
end

context "to a hearing docket appeal" do
let(:docket) { Constants.AMA_DOCKETS.hearing }

it "creates SendInitialNotificationLetterTask as child of ScheduleHearingTask" do
subject
task = Task.find_by(type: SendInitialNotificationLetterTask.name, appeal: appeal)

expect(response).to be_successful
expect(task.present?).to be true
expect(task.parent.type).to eq ScheduleHearingTask.name
expect(task.assigned_to).to eq ClerkOfTheBoard.singleton
expect(task.assigned_by).to eq current_user
end
end

context "when an appeal already has a SendInitialNotificationLetterTask" do
let(:docket) { Constants.AMA_DOCKETS.direct_review }
let!(:inital_letter_task) do
build(:task,
type: SendInitialNotificationLetterTask.name,
assigned_to: ClerkOfTheBoard.singleton,
assigned_by: current_user,
assigned_at: Time.zone.now,
appeal: appeal,
parent: appeal.tasks.where(type: DistributionTask.name).first,
status: task_status,
updated_at: Time.zone.now).tap { |t| t.save(validate: false) }
end

context "which is active" do
let(:task_status) { Constants.TASK_STATUSES.assigned }

it "does not create a new SendInitialNotificationLetterTask" do
subject

expect(response).to be_successful
expect(Task.where(appeal: appeal, type: SendInitialNotificationLetterTask.name).count).to eq 1
end
end

context "which is completed" do
let(:task_status) { Constants.TASK_STATUSES.completed }

it "creates a new SendInitialNotificationLetterTask" do
subject

expect(response).to be_successful
expect(Task.where(appeal: appeal, type: SendInitialNotificationLetterTask.name).count).to eq 2
expect(Task.active.where(appeal: appeal, type: SendInitialNotificationLetterTask.name).count).to eq 1
end
end

context "which is cancelled" do
let(:task_status) { Constants.TASK_STATUSES.cancelled }

it "creates a new SendInitialNotificationLetterTask" do
subject

expect(response).to be_successful
expect(Task.where(appeal: appeal, type: SendInitialNotificationLetterTask.name).count).to eq 2
expect(Task.active.where(appeal: appeal, type: SendInitialNotificationLetterTask.name).count).to eq 1
end
end
end
end
end
end
end

This file was deleted.

Loading

0 comments on commit e9c6c94

Please sign in to comment.