Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/APPEALS-46639
Browse files Browse the repository at this point in the history
  • Loading branch information
brandondorner authored Jul 31, 2024
2 parents 4de1d35 + 4d1bfd3 commit 2bfe003
Show file tree
Hide file tree
Showing 14 changed files with 2,209 additions and 1,575 deletions.
10 changes: 9 additions & 1 deletion app/queries/hearing_request_distribution_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def not_genpop_appeals
ama_non_aod_hearing_query.or(ama_aod_hearing_query).uniq
end

# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def only_genpop_appeals
ama_non_aod_hearing_query = generate_ama_only_genpop_non_aod_hearing_query(base_relation)
ama_aod_hearing_query = generate_ama_only_genpop_aod_hearing_query(base_relation)
Expand All @@ -79,9 +80,16 @@ def only_genpop_appeals
# the base result is doing an inner join with hearings so it isn't retrieving any appeals that have no hearings
# yet, so we add with_no_hearings to retrieve those appeals
no_hearings_or_no_held_hearings = with_no_hearings.or(with_no_held_hearings)
no_hearings_or_only_no_held_hearings = []
no_hearings_or_no_held_hearings.each do |appeal|
if appeal.hearings.blank? || appeal.hearings.pluck(:disposition).exclude?("held")
no_hearings_or_only_no_held_hearings << appeal
end
end

[*result, *no_hearings_or_no_held_hearings].uniq
[*result, *no_hearings_or_only_no_held_hearings].uniq
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength

def generate_ama_not_genpop_non_aod_hearing_query(base_relation)
query =
Expand Down
66 changes: 59 additions & 7 deletions client/test/app/caseDistribution/pages/CaseDistributionApp.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
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';
import thunk from 'redux-thunk';
import { mount } from 'enzyme';
import { render } from '@testing-library/react';

describe('render Case Distribution Application', () => {

Expand All @@ -13,26 +22,26 @@ 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(() => {
jest.clearAllMocks();
});

it('renders Case Distribution App', () => {
it('renders Case Distribution App as editable for an admin', () => {
const store = getStore();

let wrapper = mount(
<Provider store={store}>
<CaseDistributionApp
acdLeversForStore={testLevers}
acd_levers={testLevers}
acd_history={[]}
acd_history={leverHistory}
user_is_an_acd_admin
/>
</Provider>
Expand All @@ -43,7 +52,50 @@ describe('render Case Distribution Application', () => {
expect(wrapper.find('#lever-history-table').exists()).toBeTruthy();
expect(wrapper.find('.inactive-data-content').exists()).toBeTruthy();
expect(wrapper.find('.lever-content').exists()).toBeTruthy();
// the buttons and inputs will only render for admin users
expect(wrapper.find('button').exists()).toBe(true);
expect(wrapper.find('input').length > 0).toBe(true);
});

it('renders Case Distribution App as read-only for a non admin', () => {
const store = getStore();

let wrapper = mount(
<Provider store={store}>
<CaseDistributionApp
acdLeversForStore={testLevers}
acd_levers={testLevers}
acd_history={leverHistory}
user_is_an_acd_admin={false}
/>
</Provider>
);

wrapper.update();

expect(wrapper.find('#lever-history-table').exists()).toBeTruthy();
expect(wrapper.find('.inactive-data-content').exists()).toBeTruthy();
expect(wrapper.find('.lever-content').exists()).toBeTruthy();
// the buttons and inputs will only render for admin users
expect(wrapper.find('button').exists()).toBe(false);
expect(wrapper.find('input').length === 0).toBe(true);
});

it('matches snapshot', () => {
const store = getStore();

const { container } = render(
<Provider store={store}>
<CaseDistributionApp
acdLeversForStore={testLevers}
acd_levers={testLevers}
acd_history={leverHistory}
user_is_an_acd_admin
/>
</Provider>
);

expect(container).toMatchSnapshot();
});
});

Loading

0 comments on commit 2bfe003

Please sign in to comment.