-
Notifications
You must be signed in to change notification settings - Fork 1
Handle Unavailable Institutions #313
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
Open
codingLogan
wants to merge
7
commits into
master
Choose a base branch
from
lr/CTT-70
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
427c5f5
test(red): add tests for when institution.status is unavailable
codingLogan 20a11a4
test(green): Implement all code to satisfy the tests that were written
codingLogan c63765f
fix(load): go to the ins status details page when mx has set the stat…
codingLogan e5897c0
fix(institution): add fields to the types
codingLogan 4eadac8
fix(institution): make the unavailable tag red by using the colors th…
codingLogan 60c556a
fix(i18n): add translations
codingLogan 2bb3299
test(tile): remove the usage of act in tests
codingLogan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,65 +1,84 @@ | ||
| import React from 'react' | ||
| import { render, screen } from 'src/utilities/testingLibrary' | ||
| import { act } from 'react' | ||
| import { InstitutionTile } from '../InstitutionTile' | ||
| import { InstitutionStatusField } from 'src/utilities/institutionStatus' | ||
|
|
||
| describe('<InstitutionTile />', () => { | ||
| it('renders the logoUrl in the src if there is one', async () => { | ||
| it('renders the logoUrl in the src if there is one', () => { | ||
| const institution = { | ||
| name: 'testName', | ||
| logo_url: 'testLogoUrl', | ||
| } | ||
|
|
||
| await act(async () => { | ||
| render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) | ||
| }) | ||
| render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) | ||
|
|
||
| expect(screen.getByAltText(`${institution.name} logo`)).toHaveAttribute( | ||
| 'src', | ||
| institution.logo_url, | ||
| ) | ||
| }) | ||
|
|
||
| it('renders a generated url with the guid if there is no logoUrl', async () => { | ||
| it('renders a generated url with the guid if there is no logoUrl', () => { | ||
| const institution = { | ||
| guid: 'testGuid', | ||
| name: 'testName', | ||
| } | ||
|
|
||
| await act(async () => { | ||
| render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) | ||
| }) | ||
| render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) | ||
|
|
||
| expect(screen.getByAltText(`${institution.name} logo`).src.includes(institution.guid)).toBe( | ||
| true, | ||
| ) | ||
| }) | ||
|
|
||
| it('renders a disabled Chip if the institution is disabled', async () => { | ||
| it('renders a disabled Chip if the institution is disabled', () => { | ||
| const institution = { | ||
| guid: 'testGuid', | ||
| name: 'testName', | ||
| is_disabled_by_client: true, | ||
| } | ||
|
|
||
| await act(async () => { | ||
| render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) | ||
| }) | ||
| render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) | ||
|
|
||
| expect(screen.getByText('DISABLED')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('does not render a disabled Chip if the institution is not disabled', async () => { | ||
| it('does not render a disabled Chip if the institution is not disabled', () => { | ||
| const institution = { | ||
| guid: 'testGuid', | ||
| name: 'testName', | ||
| is_disabled_by_client: false, | ||
| } | ||
|
|
||
| await act(async () => { | ||
| render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) | ||
| }) | ||
| render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) | ||
|
|
||
| expect(screen.queryByText('DISABLED')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders an UNAVAILABLE Chip if the institution is unavailable by experiment values', () => { | ||
| const institution = { guid: 'testGuid', name: 'testName' } | ||
| const preloadedState = { | ||
| experimentalFeatures: { | ||
| unavailableInstitutions: [institution], | ||
| }, | ||
| } | ||
|
|
||
| render(<InstitutionTile institution={institution} selectInstitution={() => {}} />, { | ||
| preloadedState, | ||
| }) | ||
|
|
||
| expect(screen.getByText('UNAVAILABLE')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders an UNAVAILABLE Chip if the institution is unavailable by API', () => { | ||
| const institution = { | ||
| guid: 'testGuid', | ||
| name: 'testName', | ||
| status: InstitutionStatusField.UNAVAILABLE, | ||
| } | ||
|
|
||
| render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) | ||
|
|
||
| expect(screen.getByText('UNAVAILABLE')).toBeInTheDocument() | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import { | |
| useInstitutionStatusMessage, | ||
| useInstitutionStatus, | ||
| getInstitutionStatus, | ||
| InstitutionStatusField, | ||
| } from '../institutionStatus' | ||
| import * as institutionBlocks from '../institutionBlocks' | ||
| import { Provider } from 'react-redux' | ||
|
|
@@ -93,6 +94,20 @@ describe('institutionStatus', () => { | |
| const result = getInstitutionStatus(institution, unavailableInstitutions) | ||
| expect(result).toBe(InstitutionStatus.OPERATIONAL) | ||
| }) | ||
|
|
||
| // API response for institution.status | ||
| it('returns UNAVAILABLE_PER_MX when institution.status is set to UNAVAILABLE', () => { | ||
| const institution = { | ||
| guid: 'test-guid', | ||
| name: 'Test Bank', | ||
| status: InstitutionStatusField.UNAVAILABLE, | ||
| } | ||
| const unavailableInstitutions: { guid: string; name: string }[] = [] | ||
| vi.mocked(institutionBlocks.institutionIsBlockedForCostReasons).mockReturnValue(false) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to make this fail in a real way than mock it |
||
|
|
||
| const result = getInstitutionStatus(institution, unavailableInstitutions) | ||
| expect(result).toBe(InstitutionStatus.UNAVAILABLE_PER_MX) | ||
| }) | ||
| }) | ||
|
|
||
| describe('useInstitutionStatus', () => { | ||
|
|
@@ -108,6 +123,21 @@ describe('institutionStatus', () => { | |
| expect(result.current).toBe(InstitutionStatus.UNAVAILABLE) | ||
| }) | ||
|
|
||
| it('returns UNAVAILABLE_PER_MX when institution.status is set to UNAVAILABLE in API response', () => { | ||
| const institution = { | ||
| guid: 'test-guid', | ||
| name: 'Test Bank', | ||
| status: InstitutionStatusField.UNAVAILABLE, | ||
| } | ||
| const store = createMockStore([]) | ||
|
|
||
| const { result } = renderHook(() => useInstitutionStatus(institution), { | ||
| wrapper: ({ children }) => wrapper({ children, store }), | ||
| }) | ||
|
|
||
| expect(result.current).toBe(InstitutionStatus.UNAVAILABLE_PER_MX) | ||
| }) | ||
|
|
||
| it('handles null institution', () => { | ||
| const store = createMockStore([]) | ||
|
|
||
|
|
@@ -173,6 +203,25 @@ describe('institutionStatus', () => { | |
| }) | ||
| }) | ||
|
|
||
| it('returns a unique unavailable message when institution.status is set to UNAVAILABLE in API response', () => { | ||
| const institution = { | ||
| guid: 'test-guid', | ||
| name: 'Test Bank', | ||
| status: InstitutionStatusField.UNAVAILABLE, | ||
| } | ||
| const store = createMockStore([]) | ||
| vi.mocked(institutionBlocks.institutionIsBlockedForCostReasons).mockReturnValue(false) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
|
|
||
| const { result } = renderHook(() => useInstitutionStatusMessage(institution), { | ||
| wrapper: ({ children }) => wrapper({ children, store }), | ||
| }) | ||
|
|
||
| expect(result.current).toEqual({ | ||
| title: 'Connection unavailable', | ||
| body: "This institution is experiencing issues that prevent successful connections. It's unclear when this will be resolved.", | ||
| }) | ||
| }) | ||
|
|
||
| it('returns empty message for OPERATIONAL status', () => { | ||
| const institution = { guid: 'test-guid', name: 'Test Bank' } | ||
| const store = createMockStore([]) | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably worth using the same pattern you used on line 550 with the includes here