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

Raymond/APPEALS-28937 #19218

Closed
wants to merge 87 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
c468255
Added feature toggles to index.html.rb
breedbah Jul 20, 2023
7f0bae2
Added toggle to index.html.erb
breedbah Jul 21, 2023
5fe4690
Progress on conference types radio field
lauren-e-thompson Jul 21, 2023
6780e00
adding conference type selection logic
lauren-e-thompson Jul 24, 2023
72cc092
APPEALS-25141: created migrations to add pexip bool column to users v…
konhilas-ariana Jul 24, 2023
e18314c
APPEALS-25141: set default value to true on users
konhilas-ariana Jul 24, 2023
07be387
Work on radio field selection
lauren-e-thompson Jul 24, 2023
4d9694c
Fixed errors with conference selection radio field
lauren-e-thompson Jul 24, 2023
3264c4b
Clean up code after new import file
lauren-e-thompson Jul 25, 2023
fc72e95
Update copy file and state
lauren-e-thompson Jul 25, 2023
6fc2c0f
APPEALS-25112 Added styling for radio field component
lauren-e-thompson Jul 26, 2023
8db7067
Merge branch 'lthompson/APPEALS-25112' into b_reed/APPEALS-25130-v3
breedbah Jul 26, 2023
6957d77
APPEALS-25130 updated user.rb
breedbah Jul 26, 2023
ba63cf8
APPEALS-25141: rolling back changes, creating new migrations, deletin…
konhilas-ariana Jul 26, 2023
0e48803
APPEALS-25141: removed version 5.2 from migrations
konhilas-ariana Jul 26, 2023
e22ddda
Merge branch 'b_reed/APPEALS-25130-v3' of https://github.com/departme…
breedbah Jul 27, 2023
ab8ce3c
Merge pull request #19038 from department-of-veterans-affairs/b_reed/…
mchbidwell Jul 27, 2023
bdc3a52
Create jest test
lauren-e-thompson Jul 28, 2023
3dae8f5
Test passing
lauren-e-thompson Jul 28, 2023
5bfdc9b
Fixed syntax errors from merged code
lauren-e-thompson Jul 28, 2023
c023af4
Radio buttons fixed to only display on Hearings Admin page
lauren-e-thompson Jul 28, 2023
08c7910
Wrap li elements in ul elements
lauren-e-thompson Jul 28, 2023
7421103
Test that radio button values change when selected
lauren-e-thompson Jul 28, 2023
daae3bf
Update to testing logic with radio buttons
lauren-e-thompson Jul 28, 2023
5115f7c
APPEALS-25141: refactoring migrations to include up/down methods, add…
konhilas-ariana Jul 31, 2023
78af497
Styling comments updated after review
lauren-e-thompson Aug 1, 2023
ba97e73
Merge branch 'master' into akonhilas/APPEALS-25141
mchbidwell Aug 1, 2023
0ab42a3
Revert 'Merge pull request #19038 from department-of-veterans-affairs…
ThorntonMatthew Aug 1, 2023
97bba81
Fixed linting issues and updated jest snapshot
lauren-e-thompson Aug 1, 2023
6e9c1e8
Merge branch 'feature/APPEALS-25109' into lthompson/APPEALS-25112
ThorntonMatthew Aug 1, 2023
a6c4afa
Merge pull request #19057 from department-of-veterans-affairs/lthomps…
ThorntonMatthew Aug 1, 2023
bf5b312
Merge branch 'master' into feature/APPEALS-25109
ThorntonMatthew Aug 2, 2023
88d9317
Merge branch 'master' into feature/APPEALS-25109
ThorntonMatthew Aug 2, 2023
b78168a
APPEALS-25141: updated user_spec.rb
konhilas-ariana Aug 3, 2023
f048b80
Merge branch 'akonhilas/APPEALS-25141' of https://github.com/departme…
konhilas-ariana Aug 3, 2023
2fc1c02
Merge branch 'master' into feature/APPEALS-25109
ThorntonMatthew Aug 3, 2023
df20d92
APPEALS-26633 Added method to update meeting_type in Users Controller…
lauren-e-thompson Aug 3, 2023
fbdffcf
Merge branch 'feature/APPEALS-25109' into akonhilas/APPEALS-25141
ThorntonMatthew Aug 4, 2023
4987df1
Merge pull request #19055 from department-of-veterans-affairs/akonhil…
mchbidwell Aug 7, 2023
6a8edf6
APPEALS-26633 Progress on linking backend and frontend radio option c…
lauren-e-thompson Aug 7, 2023
1b1353e
Merge branch 'feature/APPEALS-25109' into lthompson/APPEALS-26633
lauren-e-thompson Aug 7, 2023
55ac16f
APPEALS-26633 Framing for logic to link onChange function
lauren-e-thompson Aug 7, 2023
e670373
Adding modifyConferenceType to patch to backend
lauren-e-thompson Aug 9, 2023
8d74aad
Adding shell script for DTA/DOO description remediaiton SOP
raymond-hughes Aug 14, 2023
26fd479
First iteration of DTA/DOO description remediation script
raymond-hughes Aug 14, 2023
c376385
Add meeting_type to user to capture new meeting type from frontend, d…
lauren-e-thompson Aug 15, 2023
2252eb2
Updating DTA DOO remediation script
raymond-hughes Aug 15, 2023
d5df546
Fixed bug so frontend hearings change is persisted to backend and upd…
lauren-e-thompson Aug 15, 2023
6b2dad9
Fixed linting issues and added rspec test to check the new meeting type
lauren-e-thompson Aug 17, 2023
14d7675
Add information about patch response test
lauren-e-thompson Aug 17, 2023
7c0f3c6
Fix code climates issues
lauren-e-thompson Aug 17, 2023
73aa405
Jest testing fixed to check for changing values by radio button selec…
lauren-e-thompson Aug 18, 2023
fac53e0
Updating script to fix duplication
raymond-hughes Aug 21, 2023
c741cc4
Pamatya/APPEALS-24131: Fix flaky/skipped tests in models/idt/token_sp…
pamatyatake2 Aug 21, 2023
96cc94e
Remove skipped and unneeded feature test (#19214)
brandondorner Aug 21, 2023
71aefea
APPEALS-24145 Fix test scenario "Assigning it to complete the claims …
seancva Aug 21, 2023
71e5a1e
Cleaning up loop for disposition selection and remediation
raymond-hughes Aug 21, 2023
b5d3f28
Revert "laurenoelle/APPEALS-19871 initial files"
mikefinneran Aug 21, 2023
6812eb5
Merge pull request #19222 from department-of-veterans-affairs/revert-…
mikefinneran Aug 21, 2023
0ae9576
Hearing Admin selection changed to Hearings Management
lauren-e-thompson Aug 22, 2023
ea346a2
Merge branch 'master' into dev-support/flaky-test-updates
craigrva Aug 22, 2023
d753fe1
Merge pull request #19220 from department-of-veterans-affairs/dev-sup…
craigrva Aug 22, 2023
923fb83
Merge branch 'master' into lthompson/APPEALS-26633
mchbidwell Aug 23, 2023
09bf07c
fixing flaky test (#19231)
pamatyatake2 Aug 23, 2023
68b51af
fix flakey tests in login spec (#19233)
csheepy Aug 23, 2023
83509ba
Merge pull request #19112 from department-of-veterans-affairs/lthomps…
mchbidwell Aug 23, 2023
de3c51c
Revert "lthompson/APPEALS-26633"
mchbidwell Aug 23, 2023
1a4a11a
APPEALS-28989 Added Ensure block that will always update last_synced_…
Aaron-Willis Aug 23, 2023
4029e97
Merge pull request #19239 from department-of-veterans-affairs/revert-…
mchbidwell Aug 23, 2023
1a3def3
Add jest tests for `CancelIntakeModal` (#19238)
brandondorner Aug 23, 2023
340d8d5
Merge branch 'master' into dev-support/skipped-test-updates
craigrva Aug 23, 2023
9b5777a
Merge branch 'master' into hotfix/APPEALS-28989
Aaron-Willis Aug 23, 2023
e2aa205
added the code needed for the test to pass (#19243)
seancva Aug 23, 2023
5924165
TYLERB/APPEALS-29085: Fix flakyness in the pre_docket_spec.rb file (#…
TylerBroyles Aug 23, 2023
a2bec4a
Merge pull request #19244 from department-of-veterans-affairs/dev-sup…
craigrva Aug 24, 2023
1a1e63a
Merge branch 'master' into hotfix/APPEALS-28989
Aaron-Willis Aug 24, 2023
db8c17f
Merge pull request #19240 from department-of-veterans-affairs/hotfix/…
Aaron-Willis Aug 24, 2023
8125b6c
Update MAC_M1.md
craigrva Aug 25, 2023
4bd6e43
Updating script
raymond-hughes Aug 25, 2023
9c34873
Adding shell script for DTA/DOO description remediaiton SOP
raymond-hughes Aug 14, 2023
c461f59
First iteration of DTA/DOO description remediation script
raymond-hughes Aug 14, 2023
c1f87bf
Updating DTA DOO remediation script
raymond-hughes Aug 15, 2023
f56c225
Updating script to fix duplication
raymond-hughes Aug 21, 2023
c51691b
Cleaning up loop for disposition selection and remediation
raymond-hughes Aug 21, 2023
7d804bf
Updating script
raymond-hughes Aug 25, 2023
b634807
Merge branch 'Raymond/APPEALS-28937' of github.com:department-of-vete…
raymond-hughes Aug 28, 2023
1d07248
Fixing error from testing in UAT
raymond-hughes Aug 30, 2023
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
22 changes: 13 additions & 9 deletions MAC_M1.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ OpenSSL
---
1. Download openssl@1.1 and openssl@3 from this [link](https://boozallen.sharepoint.com/teams/VABID/appeals/Documents/Forms/AllItems.aspx?id=%2Fteams%2FVABID%2Fappeals%2FDocuments%2FDevelopment%2FDeveloper%20Setup%20Resources%2FM1%20Mac%20Developer%20Setup&viewid=8a8eaf3e%2D2c12%2D4c87%2Db95f%2D4eab3428febd)
2. Open “Finder” and find the two folders under “Downloads”
3. Extract the `.tar.gz` files
3. Extract the `.tar.gz` or `.zip` archives
4. In each of the extracted folders:
1. Navigate to the `/usr/local/homebrew/Cellar` subfolder
2. Copy the openssl folder to your local machine's `/usr/local/homebrew/Cellar` folder
Expand Down Expand Up @@ -168,22 +168,26 @@ Run dev setup scripts in Caseflow repo
1. Open a **Rosetta** terminal and navigate to /usr/local, run the command ```sudo spctl --global-disable```
2. In the **Rosetta** terminal, install pyenv and the required python2 version:
1. `brew install pyenv`
2. `pyenv install 2.7.18`
3. In the caseflow directory, run `pyenv local 2.7.18` to set the version
2. `pyenv rehash`
3. `pyenv install 2.7.18`
4. In the caseflow directory, run `pyenv local 2.7.18` to set the version
3. In the **Rosetta** terminal navigate to caseflow folder:
1. set ```RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/homebrew/Cellar/openssl@1.1"```
2. run `rbenv install 2.7.3`
3. run `gem install pg:1.1.4 -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config`
4. Install v8@3.15 by doing the following (these steps assume that vi/vim is the default editor):
1. set ```export RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/homebrew/Cellar/openssl@1.1"```
2. run `rbenv install $(cat .ruby-version)`
3. run `rbenv rehash`
4. run `gem install bundler -v $(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)`
5. run `gem install pg:1.1.4 -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config`
6. Install v8@3.15 by doing the following (these steps assume that vi/vim is the default editor):
1. run `brew edit v8@3.15`
2. go to line 21 in the editor by typing `:21`
Note: the line being removed is `disable! date: "2023-06-19", because: "depends on Python 2 to build"`
3. delete the line by pressing `d` twice
4. save and quit by typing `:x`
5. Configure build opts for gem `therubyracer`:
5. run `HOMEBREW_NO_INSTALL_FROM_API=1 brew install v8@3.15`
7. Configure build opts for gem `therubyracer`:
1. `bundle config build.libv8 --with-system-v8`
2. `bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8@3.15)`
6. run ```./scripts/dev_env_setup_step2.sh```
8. run ```./scripts/dev_env_setup_step2.sh```
If you get a permission error while running gem install or bundle install, **do not run using sudo.**
Set the permissions back to you for every directory under /.rbenv
* Enter command: `sudo chown -R <your name under /Users> /Users/<your name>/.rbenv`
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,6 @@ def feedback_url
end
helper_method :feedback_url

def efolder_express_url
Rails.application.config.efolder_url.to_s
end
helper_method :efolder_express_url

def help_url
{
"certification" => certification_help_path,
Expand Down
10 changes: 6 additions & 4 deletions app/models/end_product_establishment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,7 @@ def sync!
contentions unless result.status_type_code == EndProduct::STATUSES.key("Canceled")

transaction do
update!(
synced_status: result.status_type_code,
last_synced_at: Time.zone.now
)
update!(synced_status: result.status_type_code)
status_cancelled? ? handle_cancelled_ep! : sync_source!
close_request_issues_with_no_decision!
end
Expand All @@ -224,6 +221,11 @@ def sync!
rescue StandardError => error
Raven.extra_context(end_product_establishment_id: id)
raise error
ensure
# Always update last_synced_at to ensure that SyncReviewsJob does not immediately re-enqueue
# End Product Establishments that fail to sync with BGS into the EndProductSyncJob.
# This will allow for other End Product Establishments to sync first before re-attempting.
update!(last_synced_at: Time.zone.now)
end

def fetch_dispositions_from_vbms
Expand Down
1 change: 0 additions & 1 deletion app/views/reader/appeal/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
applicationUrls: application_urls,
page: "DecisionReviewer",
feedbackUrl: feedback_url,
efolderExpressUrl: efolder_express_url,
featureToggles: {
interfaceVersion2: FeatureToggle.enabled?(:interface_version_2, user: current_user),
windowSlider: FeatureToggle.enabled?(:window_slider, user: current_user),
Expand Down
2 changes: 0 additions & 2 deletions client/app/reader/DecisionReviewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export class DecisionReviewer extends React.PureComponent {
annotations={this.props.annotations}
vacolsId={vacolsId}>
<PdfListView
efolderExpressUrl={this.props.efolderExpressUrl}
showPdf={this.showPdf(props.history, vacolsId)}
sortBy={this.state.sortBy}
selectedLabels={this.state.selectedLabels}
Expand Down Expand Up @@ -174,7 +173,6 @@ DecisionReviewer.propTypes = {
dropdownUrls: PropTypes.array,
featureToggles: PropTypes.any,
feedbackUrl: PropTypes.any,
efolderExpressUrl: PropTypes.any,
isPlacingAnnotation: PropTypes.any,
onScrollToComment: PropTypes.func,
setCategoryFilter: PropTypes.func,
Expand Down
7 changes: 3 additions & 4 deletions client/app/reader/DocumentList/DocumentListActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,8 @@ export const setViewingDocumentsOrComments = (documentsOrComments) => ({
}
});

export const onReceiveManifests = (manifestVbmsFetchedAt) => ({
export const onReceiveManifests = (manifestVbmsFetchedAt, manifestVvaFetchedAt) => ({
type: Constants.RECEIVE_MANIFESTS,
payload: {
manifestVbmsFetchedAt
}
payload: { manifestVbmsFetchedAt,
manifestVvaFetchedAt }
});
6 changes: 5 additions & 1 deletion client/app/reader/DocumentList/DocumentListReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ const initialState = {
category: false
}
},
manifestVbmsFetchedAt: null
manifestVbmsFetchedAt: null,
manifestVvaFetchedAt: null
};

const documentListReducer = (state = initialState, action = {}) => {
Expand Down Expand Up @@ -180,6 +181,9 @@ const documentListReducer = (state = initialState, action = {}) => {
return update(state, {
manifestVbmsFetchedAt: {
$set: action.payload.manifestVbmsFetchedAt
},
manifestVvaFetchedAt: {
$set: action.payload.manifestVvaFetchedAt
}
});
case Constants.UPDATE_FILTERED_RESULTS:
Expand Down
38 changes: 16 additions & 22 deletions client/app/reader/LastRetrievalAlert.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import _ from 'lodash';
import moment from 'moment';
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import Alert from '../components/Alert';
import { css } from 'glamor';
Expand All @@ -16,33 +15,34 @@ class LastRetrievalAlert extends React.PureComponent {

render() {

// Check that document manifests have been recieved from VBMS -- red banner
if (!this.props.manifestVbmsFetchedAt) {
// Check that document manifests have been recieved from VVA and VBMS
if (!this.props.manifestVbmsFetchedAt || !this.props.manifestVvaFetchedAt) {
return <div {...alertStyling}>
<Alert title="Error" type="error">
Some of {this.props.appeal.veteran_full_name}'s documents are unavailable at the moment due to
a loading error from their eFolder. As a result, you may be viewing a partial list of eFolder documents.
Some of {this.props.appeal.veteran_full_name}'s documents are not available at the moment due to
a loading error from VBMS or VVA. As a result, you may be viewing a partial list of claims folder documents.
<br />
Please visit <a href={this.props.efolderExpressUrl} target="_blank" rel="noopener noreferrer"> eFolder Express </a> to fetch the
latest list of documents or submit a support ticket to sync their eFolder with Reader.
<br />
Please refresh your browser at a later point to view a complete list of documents in the claims
folder.
</Alert>
</div>;
}

const staleCacheTime = moment().subtract(CACHE_TIMEOUT_HOURS, 'h'),
vbmsManifestTimestamp = moment(this.props.manifestVbmsFetchedAt, 'MM/DD/YY HH:mma Z');
vbmsManifestTimestamp = moment(this.props.manifestVbmsFetchedAt, 'MM/DD/YY HH:mma Z'),
vvaManifestTimestamp = moment(this.props.manifestVvaFetchedAt, 'MM/DD/YY HH:mma Z');

// Check that manifest results are fresh -- yellow banner
if (vbmsManifestTimestamp.isBefore(staleCacheTime)) {
// Check that manifest results are fresh
if (vbmsManifestTimestamp.isBefore(staleCacheTime) || vvaManifestTimestamp.isBefore(staleCacheTime)) {
const now = moment(),
vbmsDiff = now.diff(vbmsManifestTimestamp, 'hours');
vbmsDiff = now.diff(vbmsManifestTimestamp, 'hours'),
vvaDiff = now.diff(vvaManifestTimestamp, 'hours');

return <div {...alertStyling}>
<Alert title="Warning" type="warning">
Reader last synced the list of documents with {this.props.appeal.veteran_full_name}'s eFolder
{vbmsDiff} hours ago. If you'd like to view documents in Reader uploaded to their eFolder since
the last sync, please visit <a href={this.props.efolderExpressUrl} target="_blank" rel="noopener noreferrer"> eFolder Express </a>
to fetch the latest list of documents or submit a support ticket to sync their eFolder with Reader.
We last synced with VBMS and VVA {Math.max(vbmsDiff, vvaDiff)} hours ago. If you'd like to check for new
documents, refresh the page.
</Alert>
</div>;
}
Expand All @@ -51,12 +51,6 @@ class LastRetrievalAlert extends React.PureComponent {
}
}

LastRetrievalAlert.propTypes = {
manifestVbmsFetchedAt: PropTypes.string,
efolderExpressUrl: PropTypes.string,
appeal: PropTypes.object,
};

export default connect(
(state) => _.pick(state.documentList, 'manifestVbmsFetchedAt')
(state) => _.pick(state.documentList, ['manifestVvaFetchedAt', 'manifestVbmsFetchedAt'])
)(LastRetrievalAlert);
13 changes: 10 additions & 3 deletions client/app/reader/LastRetrievalInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ class UnconnectedLastRetrievalInfo extends React.PureComponent {
return [
this.props.manifestVbmsFetchedAt ?
<div id="vbms-manifest-retrieved-at" key="vbms">
Last synced with {this.props.appeal.veteran_full_name}'s eFolder: {this.props.manifestVbmsFetchedAt.slice(0, -5)}
Last VBMS retrieval: {this.props.manifestVbmsFetchedAt.slice(0, -5)}
</div> :
<div className="cf-red-text" key="vbms">
Unable to display eFolder documents at this time
Unable to display VBMS documents at this time
</div>,
this.props.manifestVvaFetchedAt ?
<div id="vva-manifest-retrieved-at" key="vva">
Last VVA retrieval: {this.props.manifestVvaFetchedAt.slice(0, -5)}
</div> :
<div className="cf-red-text" key="vva">
Unable to display VVA documents at this time
</div>
];
}
}

export default connect(
(state) => _.pick(state.documentList, 'manifestVbmsFetchedAt')
(state) => _.pick(state.documentList, ['manifestVvaFetchedAt', 'manifestVbmsFetchedAt'])
)(UnconnectedLastRetrievalInfo);
8 changes: 3 additions & 5 deletions client/app/reader/PdfListView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ export class PdfListView extends React.Component {
<AppSegment filledBackground>
<div className="section--document-list">
<ClaimsFolderDetails appeal={this.props.appeal} documents={this.props.documents} />
<LastRetrievalAlert efolderExpressUrl={this.props.efolderExpressUrl} appeal={this.props.appeal} />
<LastRetrievalAlert appeal={this.props.appeal} />
<DocumentListHeader
documents={this.props.documents}
noDocuments={noDocuments}
/>
{tableView}
</div>
</AppSegment>
<LastRetrievalInfo appeal={this.props.appeal} />
<LastRetrievalInfo />
</div>;
}
}
Expand Down Expand Up @@ -108,8 +108,6 @@ export default connect(

PdfListView.propTypes = {
documents: PropTypes.arrayOf(PropTypes.object).isRequired,
efolderExpressUrl: PropTypes.string,
onJumpToComment: PropTypes.func,
sortBy: PropTypes.string,
appeal: PropTypes.object,
sortBy: PropTypes.string
};
100 changes: 100 additions & 0 deletions client/test/app/intake/components/CancelIntakeModal.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Provider } from 'react-redux';
import userEvent from '@testing-library/user-event';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from 'app/queue/reducers';
import CancelIntakeModal from 'app/intake/components/CancelIntakeModal';
import { CANCELLATION_REASONS } from 'app/intake/constants';

jest.mock('redux', () => ({
...jest.requireActual('redux'),
bindActionCreators: () => jest.fn().mockImplementation(() => Promise.resolve(true)),
}));

describe('CancelIntakeModal', () => {
const defaultProps = {
closeHandler: () => {},
intakeId: '123 change?',
clearClaimant: jest.fn().mockImplementation(() => Promise.resolve(true)),
clearPoa: jest.fn().mockImplementation(() => Promise.resolve(true)),
submitCancel: jest.fn().mockImplementation(() => Promise.resolve(true))
};
const buttonText = 'Cancel intake';

afterEach(() => {
jest.clearAllMocks();
});

const store = createStore(rootReducer, applyMiddleware(thunk));

const setup = (props) =>
render(
<Provider store={store}>
<CancelIntakeModal
{...props}
/>
</Provider>
);

it('renders correctly', () => {
const modal = setup(defaultProps);

expect(modal).toMatchSnapshot();
});

it('displays cancellation options', () => {
const modal = setup(defaultProps);

Object.values(CANCELLATION_REASONS).map((reason) => (
expect(modal.getByText(reason.name)).toBeInTheDocument()
));
});

it('should show other reason input when other is selected', async () => {
const modal = setup(defaultProps);

await userEvent.click(screen.getByText('Other'));

expect(modal.getByText('Tell us more about your situation.')).toBeInTheDocument();
});

describe('cancel button', () => {
it('is disabled until "Other" is selected and the text input is filled out', async () => {
const modal = setup(defaultProps);

expect(modal.getByText(buttonText)).toBeDisabled();

await userEvent.click(modal.getByText('Other'));

expect(modal.getByText('Tell us more about your situation.')).toBeInTheDocument();
expect(modal.getByText(buttonText)).toBeDisabled();

await userEvent.type(modal.getByRole('textbox'), 'Test');

expect(modal.getByText(buttonText)).not.toBeDisabled();
});

it('is disabled until value (that is not "Other") is selected', async () => {
const modal = setup(defaultProps);

expect(modal.getByText(buttonText)).toBeDisabled();

await userEvent.click(modal.getByText('System error'));
expect(modal.getByText(buttonText)).not.toBeDisabled();
});
});

it('should call the appropiate functions when Cancel intake is clicked', async () => {
const modal = setup(defaultProps);

await userEvent.click(modal.getByText('System error'));
expect(modal.getByText(buttonText)).not.toBeDisabled();

await userEvent.click(modal.getByText('Cancel intake'));
expect(defaultProps.clearClaimant).toHaveBeenCalled();
expect(defaultProps.clearPoa).toHaveBeenCalled();
expect(defaultProps.submitCancel).toHaveBeenCalled();
});
});
Loading
Loading