-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5545 from flexion/10472-story
10472 story
- Loading branch information
Showing
18 changed files
with
149 additions
and
296 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
50 changes: 50 additions & 0 deletions
50
web-client/src/presenter/actions/getPDFForPreviewTabAction.test.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; | ||
import { getPDFForPreviewTabAction } from './getPDFForPreviewTabAction'; | ||
import { presenter } from '../presenter-mock'; | ||
import { runAction } from '@web-client/presenter/test.cerebral'; | ||
|
||
describe('getPDFForPreviewTabAction', () => { | ||
beforeAll(() => { | ||
presenter.providers.applicationContext = applicationContext; | ||
applicationContext | ||
.getUseCases() | ||
.loadPDFForPreviewInteractor.mockResolvedValue('fake file data'); | ||
}); | ||
|
||
it('returns original props if we already have what appears to be an actual file', async () => { | ||
const props = { file: { name: 'name of a file on a real file object' } }; | ||
const result = await runAction(getPDFForPreviewTabAction, { | ||
modules: { | ||
presenter, | ||
}, | ||
props, | ||
state: {}, | ||
}); | ||
expect(result.props).toEqual(props); | ||
expect( | ||
applicationContext.getUseCases().loadPDFForPreviewInteractor, | ||
).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('returns results from loadPDFForPreviewInteractor if provided a docketNumber and docketEntryId', async () => { | ||
const props = { file: { docketEntryId: '456' } }; | ||
await runAction(getPDFForPreviewTabAction, { | ||
modules: { | ||
presenter, | ||
}, | ||
props, | ||
state: { | ||
caseDetail: { | ||
docketNumber: '123-20', | ||
}, | ||
}, | ||
}); | ||
expect( | ||
applicationContext.getUseCases().loadPDFForPreviewInteractor.mock | ||
.calls[0][1], | ||
).toMatchObject({ | ||
docketEntryId: '456', | ||
docketNumber: '123-20', | ||
}); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
web-client/src/presenter/actions/getPDFForPreviewTabAction.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { state } from '@web-client/presenter/app.cerebral'; | ||
|
||
export const getPDFForPreviewTabAction = async ({ | ||
applicationContext, | ||
get, | ||
props, | ||
}: ActionProps) => { | ||
if (props.file.name) { | ||
return props; | ||
} | ||
const { docketEntryId } = props.file; | ||
const docketNumber = get(state.caseDetail.docketNumber); | ||
|
||
const pdfObj = await applicationContext | ||
.getUseCases() | ||
.loadPDFForPreviewInteractor(applicationContext, { | ||
docketEntryId, | ||
docketNumber, | ||
}); | ||
return { file: pdfObj }; | ||
}; |
6 changes: 0 additions & 6 deletions
6
web-client/src/presenter/actions/openCaseDocumentDownloadUrlAction.ts
This file contains 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 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
Oops, something went wrong.