Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,57 @@ import { render, screen, within } from '@testing-library/react';
import DocumentCaptureReviewIssues from '@18f/identity-document-capture/components/document-capture-review-issues';
import { InPersonContext } from '@18f/identity-document-capture/context';
import { toFormEntryError } from '@18f/identity-document-capture/services/upload';
import { I18nContext } from '@18f/identity-react-i18n';
import { I18n } from '@18f/identity-i18n';
import { expect } from 'chai';
import { composeComponents } from '@18f/identity-compose-components';

describe('DocumentCaptureReviewIssues', () => {
const DEFAULT_OPTIONS = {
registerField: () => undefined,
captureHints: true,
remainingAttempts: 2,
value: {},
onChange: () => undefined,
onError: () => undefined,
isFailedSelfie: false,
isFailedDocType: false,
isFailedSelfieLivenessOrQuality: false,
remainingSubmitAttempts: Infinity,
unknownFieldErrors: [],
errors: [],
hasDismissed: false,
toPreviousStep: () => undefined,
};

context('with default props', () => {
it('does not display infinity remaining attempts', () => {
const { queryByText } = render(
<I18nContext.Provider
value={
new I18n({
strings: {
'idv.failure.attempts_html': 'You have %{count} attempts remaining.',
},
})
}
>
<DocumentCaptureReviewIssues {...DEFAULT_OPTIONS} />
</I18nContext.Provider>,
);

expect(queryByText('You have Infinity attempts remaining.')).to.equal(null);
});
});

context('with doc error', () => {
it('renders for non doc type failure', () => {
const props = {
isFailedDocType: false,
remainingSubmitAttempts: 2,
unknownFieldErrors: [
{
field: 'general',
error: toFormEntryError({ field: 'general', message: 'general error' }),
error: toFormEntryError({ field: 'network', message: 'general error' }),
},
],
errors: [
Expand All @@ -44,6 +75,16 @@ describe('DocumentCaptureReviewIssues', () => {
},
},
],
[
I18nContext.Provider,
{
value: new I18n({
strings: {
'idv.failure.attempts_html': 'You have %{count} attempts remaining.',
},
}),
},
],
[
DocumentCaptureReviewIssues,
{
Expand All @@ -58,6 +99,8 @@ describe('DocumentCaptureReviewIssues', () => {

expect(getByText('general error')).to.be.ok();

expect(getByText('You have 2 attempts remaining.')).to.be.ok();

// tips header
expect(getByText('doc_auth.tips.review_issues_id_header_text')).to.be.ok();
const lists = getAllByRole('list');
Expand All @@ -80,31 +123,37 @@ describe('DocumentCaptureReviewIssues', () => {
});

it('renders for a doc type failure', () => {
const props = {
isFailedDocType: true,
unknownFieldErrors: [
{
field: 'general',
error: toFormEntryError({ field: 'general', message: 'general error' }),
},
],
errors: [
{
field: 'front',
error: toFormEntryError({ field: 'front', message: 'front side doc type error' }),
},
{
field: 'back',
error: toFormEntryError({ field: 'back', message: 'back side doc type error' }),
},
],
};
const { getByText, getByLabelText, getByRole } = render(
<InPersonContext.Provider value={{ inPersonURL: '/verify/doc_capture' }}>
<InPersonContext.Provider
value={{
inPersonURL: '/verify/doc_capture',
locationsURL: '',
addressSearchURL: '',
inPersonFullAddressEntryEnabled: false,
inPersonOutageMessageEnabled: false,
optedInToInPersonProofing: false,
usStatesTerritories: [['Los Angeles', 'NY']],
}}
>
<DocumentCaptureReviewIssues
{...{
...DEFAULT_OPTIONS,
...props,
isFailedDocType: true,
unknownFieldErrors: [
{
error: toFormEntryError({ field: 'network', message: 'general error' }),
},
],
errors: [
{
field: 'front',
error: toFormEntryError({ field: 'front', message: 'front side doc type error' }),
},
{
field: 'back',
error: toFormEntryError({ field: 'back', message: 'back side doc type error' }),
},
],
}}
/>
</InPersonContext.Provider>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ function DocumentCaptureReviewIssues({
altFailedDocTypeMsg={isFailedDocType ? t('doc_auth.errors.doc.wrong_id_type_html') : null}
hasDismissed={hasDismissed}
/>
<p>
<HtmlTextWithStrongNoWrap
text={t('idv.failure.attempts_html', { count: remainingSubmitAttempts })}
/>
</p>
{Number.isFinite(remainingSubmitAttempts) && (
<p>
<HtmlTextWithStrongNoWrap
text={t('idv.failure.attempts_html', { count: remainingSubmitAttempts })}
/>
</p>
)}
{!isFailedDocType && captureHints && (
<TipList
titleClassName="margin-bottom-0 margin-top-2"
Expand Down
1 change: 0 additions & 1 deletion scripts/enforce-typescript-files.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const LEGACY_FILE_EXCEPTIONS = [
'spec/javascript/packages/document-capture/components/acuant-selfie-camera-spec.jsx',
'spec/javascript/packages/document-capture/components/acuant-selfie-capture-canvas-spec.jsx',
'spec/javascript/packages/document-capture/components/callback-on-mount-spec.jsx',
'spec/javascript/packages/document-capture/components/document-capture-review-issues-spec.jsx',
'spec/javascript/packages/document-capture/components/document-capture-spec.jsx',
'spec/javascript/packages/document-capture/components/document-capture-warning-spec.jsx',
'spec/javascript/packages/document-capture/components/file-image-spec.jsx',
Expand Down