Skip to content

Commit

Permalink
APPEALS-51536: Optimize automatic case distribution tests (#22240)
Browse files Browse the repository at this point in the history
* 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 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 Jul 23, 2024
1 parent 3a5a7bd commit a69f909
Show file tree
Hide file tree
Showing 10 changed files with 1,507 additions and 659 deletions.
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 a69f909

Please sign in to comment.