From e101d3377f7ced3391f5ad68bcc6a6718768f430 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Mon, 19 Aug 2024 10:39:41 -0400 Subject: [PATCH] Jmax/lg 13875 rename documentstep in doc auth (#11092) * Renamed component DocumentsStep -> DocumentsAndSelfieStep Renamed files to match new component name. Because policy, the rename meant moving from a .jsx file to a .tsx file, so there was some Typescript cleanup to do; it amounted to adding dummy arguments to component rendering in the specs. changelog: Upcoming Features,biometric verification,Renamed `DocumentsStep` to `DocumentsAndSelfieStep` --- .../document-capture-review-issues.tsx | 2 +- .../components/document-capture.tsx | 4 +- ...step.tsx => documents-and-selfie-step.tsx} | 10 +-- scripts/enforce-typescript-files.mjs | 1 - ...jsx => documents-and-selfie-step-spec.tsx} | 78 ++++++++++++++++--- 5 files changed, 73 insertions(+), 22 deletions(-) rename app/javascript/packages/document-capture/components/{documents-step.tsx => documents-and-selfie-step.tsx} (95%) rename spec/javascript/packages/document-capture/components/{documents-step-spec.jsx => documents-and-selfie-step-spec.tsx} (71%) diff --git a/app/javascript/packages/document-capture/components/document-capture-review-issues.tsx b/app/javascript/packages/document-capture/components/document-capture-review-issues.tsx index af3547394dc..3ccbe0454cf 100644 --- a/app/javascript/packages/document-capture/components/document-capture-review-issues.tsx +++ b/app/javascript/packages/document-capture/components/document-capture-review-issues.tsx @@ -11,7 +11,7 @@ import { DocumentCaptureSubheaderOne, SelfieCaptureWithHeader, DocumentFrontAndBackCapture, -} from './documents-step'; +} from './documents-and-selfie-step'; import type { ReviewIssuesStepValue } from './review-issues-step'; interface DocumentCaptureReviewIssuesProps extends FormStepComponentProps { diff --git a/app/javascript/packages/document-capture/components/document-capture.tsx b/app/javascript/packages/document-capture/components/document-capture.tsx index afbacbc27d6..5bfe414d3d7 100644 --- a/app/javascript/packages/document-capture/components/document-capture.tsx +++ b/app/javascript/packages/document-capture/components/document-capture.tsx @@ -7,7 +7,7 @@ import { useDidUpdateEffect } from '@18f/identity-react-hooks'; import type { FormStep } from '@18f/identity-form-steps'; import { getConfigValue } from '@18f/identity-config'; import { UploadFormEntriesError } from '../services/upload'; -import DocumentsStep from './documents-step'; +import DocumentsAndSelfieStep from './documents-and-selfie-step'; import InPersonPrepareStep from './in-person-prepare-step'; import InPersonLocationPostOfficeSearchStep from './in-person-location-post-office-search-step'; import InPersonLocationFullAddressEntryPostOfficeSearchStep from './in-person-location-full-address-entry-post-office-search-step'; @@ -53,7 +53,7 @@ function DocumentCapture({ onStepChange = () => {} }: DocumentCaptureProps) { // Define different states to be used in human readable array declaration const documentFormStep: FormStep = { name: 'documents', - form: DocumentsStep, + form: DocumentsAndSelfieStep, title: t('doc_auth.headings.document_capture'), }; const reviewFormStep: FormStep = { diff --git a/app/javascript/packages/document-capture/components/documents-step.tsx b/app/javascript/packages/document-capture/components/documents-and-selfie-step.tsx similarity index 95% rename from app/javascript/packages/document-capture/components/documents-step.tsx rename to app/javascript/packages/document-capture/components/documents-and-selfie-step.tsx index 69da4edb4f2..f0ae2ec5ede 100644 --- a/app/javascript/packages/document-capture/components/documents-step.tsx +++ b/app/javascript/packages/document-capture/components/documents-and-selfie-step.tsx @@ -84,7 +84,7 @@ export function DocumentFrontAndBackCapture({ type ImageValue = Blob | string | null | undefined; -interface DocumentsStepValue { +interface DocumentsAndSelfieStepValue { front: ImageValue; back: ImageValue; selfie: ImageValue; @@ -93,17 +93,17 @@ interface DocumentsStepValue { } type DefaultSideProps = Pick< - FormStepComponentProps, + FormStepComponentProps, 'registerField' | 'onChange' | 'errors' | 'onError' >; -function DocumentsStep({ +export default function DocumentsAndSelfieStep({ value = {}, onChange = () => {}, errors = [], onError = () => {}, registerField = () => undefined, -}: FormStepComponentProps) { +}: FormStepComponentProps) { const { t } = useI18n(); const { isMobile } = useContext(DeviceContext); const { isLastStep } = useContext(FormStepsContext); @@ -145,5 +145,3 @@ function DocumentsStep({ ); } - -export default DocumentsStep; diff --git a/scripts/enforce-typescript-files.mjs b/scripts/enforce-typescript-files.mjs index 02ef7efe969..6496502e94d 100755 --- a/scripts/enforce-typescript-files.mjs +++ b/scripts/enforce-typescript-files.mjs @@ -47,7 +47,6 @@ const LEGACY_FILE_EXCEPTIONS = [ '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/documents-step-spec.jsx', 'spec/javascript/packages/document-capture/components/file-image-spec.jsx', 'spec/javascript/packages/document-capture/components/file-input-spec.jsx', 'spec/javascript/packages/document-capture/components/review-issues-step-spec.jsx', diff --git a/spec/javascript/packages/document-capture/components/documents-step-spec.jsx b/spec/javascript/packages/document-capture/components/documents-and-selfie-step-spec.tsx similarity index 71% rename from spec/javascript/packages/document-capture/components/documents-step-spec.jsx rename to spec/javascript/packages/document-capture/components/documents-and-selfie-step-spec.tsx index 8f0f2a03605..482ad5ca2be 100644 --- a/spec/javascript/packages/document-capture/components/documents-step-spec.jsx +++ b/spec/javascript/packages/document-capture/components/documents-and-selfie-step-spec.tsx @@ -9,14 +9,24 @@ import { FailedCaptureAttemptsContextProvider, SelfieCaptureContext, } from '@18f/identity-document-capture'; -import DocumentsStep from '@18f/identity-document-capture/components/documents-step'; +import DocumentsAndSelfieStep from '@18f/identity-document-capture/components/documents-and-selfie-step'; import { composeComponents } from '@18f/identity-compose-components'; import { render } from '../../../support/document-capture'; import { getFixtureFile } from '../../../support/file'; -describe('document-capture/components/documents-step', () => { +describe('document-capture/components/documents-and-selfie-step', () => { it('renders with only front and back inputs by default', () => { - const { getByLabelText, queryByLabelText } = render(); + const { getByLabelText, queryByLabelText } = render( + undefined} + errors={[]} + onError={() => undefined} + registerField={() => undefined} + unknownFieldErrors={[]} + toPreviousStep={() => undefined} + />, + ); const front = getByLabelText('doc_auth.headings.document_capture_front'); const back = getByLabelText('doc_auth.headings.document_capture_back'); @@ -33,8 +43,18 @@ describe('document-capture/components/documents-step', () => { - , + undefined} + registerField={() => undefined} + unknownFieldErrors={[]} + toPreviousStep={() => undefined} + /> + , , ); const file = await getFixtureFile('doc_auth_images/id-back.jpg'); @@ -52,13 +72,31 @@ describe('document-capture/components/documents-step', () => { it('renders device-specific instructions', () => { let { getByText } = render( - + undefined} + errors={[]} + onError={() => undefined} + registerField={() => undefined} + unknownFieldErrors={[]} + toPreviousStep={() => undefined} + /> , ); expect(() => getByText('doc_auth.tips.document_capture_id_text4')).to.throw(); - getByText = render().getByText; + getByText = render( + undefined} + errors={[]} + onError={() => undefined} + registerField={() => undefined} + unknownFieldErrors={[]} + toPreviousStep={() => undefined} + />, + ).getByText; expect(() => getByText('doc_auth.tips.document_capture_id_text4')).not.to.throw(); }); @@ -66,8 +104,16 @@ describe('document-capture/components/documents-step', () => { it('renders the hybrid flow warning if the flow is hybrid', () => { const { getByText } = render( - - + + undefined} + errors={[]} + onError={() => undefined} + registerField={() => undefined} + unknownFieldErrors={[]} + toPreviousStep={() => undefined} + /> , ); @@ -79,8 +125,16 @@ describe('document-capture/components/documents-step', () => { it('does not render the hybrid flow warning if the flow is standard (default)', () => { const { queryByText } = render( - - + + undefined} + errors={[]} + onError={() => undefined} + registerField={() => undefined} + unknownFieldErrors={[]} + toPreviousStep={() => undefined} + /> , ); @@ -100,7 +154,7 @@ describe('document-capture/components/documents-step', () => { }, }, ], - [DocumentsStep], + [DocumentsAndSelfieStep], ); const { getAllByRole, getByText, getByRole, getByLabelText, queryByLabelText } = render( , @@ -150,7 +204,7 @@ describe('document-capture/components/documents-step', () => { }, }, ], - [DocumentsStep], + [DocumentsAndSelfieStep], ); const { queryByRole, getByRole, getByLabelText } = render();