Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.
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
11 changes: 2 additions & 9 deletions src/applications/lgy/coe/form/components/PreSubmitInfo2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,18 @@
const STATEMENT_OF_TRUTH = {
body:
'I confirm that the identifying information in this form is accurate and has been represented correctly.',
fullNamePath: 'fullName',
useProfileFullName: true,
};

export const PreSubmitInfo2 = ({
formData,
showError,
user,
onSectionComplete,
}) => {
export const PreSubmitInfo2 = ({ formData, showError, onSectionComplete }) => {
const [signature, setSignature] = useState('');
const [certified, setCertified] = useState(false);
const [signatureBlurred, setSignatureBlurred] = useState(false);

const expectedFullName = statementOfTruthFullName(
formData,
STATEMENT_OF_TRUTH,
user?.profile?.userFullName,
);

const signatureMismatch =
Expand Down Expand Up @@ -64,8 +59,6 @@

PreSubmitInfo2.propTypes = {
formData: PropTypes.object,
onSectionComplete: PropTypes.func,

Check warning on line 62 in src/applications/lgy/coe/form/components/PreSubmitInfo2.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/lgy/coe/form/components/PreSubmitInfo2.jsx:62:3:Callback prop types must be listed after all other prop types

Check warning on line 62 in src/applications/lgy/coe/form/components/PreSubmitInfo2.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/lgy/coe/form/components/PreSubmitInfo2.jsx:62:3:Callback prop types must be listed after all other prop types
preSubmitInfo: PropTypes.object,
showError: PropTypes.bool,
user: PropTypes.object,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ import sinon from 'sinon';
import { fireEvent, render, waitFor } from '@testing-library/react';
import { PreSubmitInfo2 } from '../../../components/PreSubmitInfo2';

const buildUser = (fullName = { first: 'John', last: 'Doe' }) => ({
profile: { userFullName: fullName },
});

describe('COE PreSubmitInfo2', () => {
it('renders a va-statement-of-truth with the expected heading and input label', () => {
const { container } = render(
<PreSubmitInfo2
formData={{}}
showError={false}
user={buildUser()}
onSectionComplete={() => {}}
/>,
);
Expand All @@ -30,7 +25,6 @@ describe('COE PreSubmitInfo2', () => {
<PreSubmitInfo2
formData={{}}
showError={false}
user={buildUser()}
onSectionComplete={() => {}}
/>,
);
Expand All @@ -44,7 +38,6 @@ describe('COE PreSubmitInfo2', () => {
<PreSubmitInfo2
formData={{}}
showError={false}
user={buildUser()}
onSectionComplete={() => {}}
/>,
);
Expand All @@ -59,7 +52,6 @@ describe('COE PreSubmitInfo2', () => {
<PreSubmitInfo2
formData={{}}
showError={false}
user={buildUser()}
onSectionComplete={onSectionComplete}
/>,
);
Expand All @@ -78,12 +70,7 @@ describe('COE PreSubmitInfo2', () => {

it('shows a checkbox error when showError is true and the box is unchecked', async () => {
const { container } = render(
<PreSubmitInfo2
formData={{}}
showError
user={buildUser()}
onSectionComplete={() => {}}
/>,
<PreSubmitInfo2 formData={{}} showError onSectionComplete={() => {}} />,
);
await waitFor(() => {
const sot = container.querySelector('va-statement-of-truth');
Expand All @@ -95,12 +82,7 @@ describe('COE PreSubmitInfo2', () => {

it('clears the checkbox error after the box is checked', async () => {
const { container } = render(
<PreSubmitInfo2
formData={{}}
showError
user={buildUser()}
onSectionComplete={() => {}}
/>,
<PreSubmitInfo2 formData={{}} showError onSectionComplete={() => {}} />,
);
const sot = container.querySelector('va-statement-of-truth');
fireEvent(
Expand All @@ -112,12 +94,11 @@ describe('COE PreSubmitInfo2', () => {
});
});

it('shows a signature mismatch error after blur when the signature does not match the profile name', async () => {
it('shows a signature mismatch error after blur when the signature does not match the expected name', async () => {
const { container } = render(
<PreSubmitInfo2
formData={{}}
formData={{ fullName: { first: 'John', last: 'Doe' } }}
showError={false}
user={buildUser({ first: 'John', last: 'Doe' })}
onSectionComplete={() => {}}
/>,
);
Expand All @@ -143,7 +124,6 @@ describe('COE PreSubmitInfo2', () => {
<PreSubmitInfo2
formData={{}}
showError={false}
user={buildUser()}
onSectionComplete={() => {}}
/>,
);
Expand All @@ -159,12 +139,11 @@ describe('COE PreSubmitInfo2', () => {
expect(sot.getAttribute('input-error')).to.be.null;
});

it('does not show a mismatch error when the signature matches the profile name (case/whitespace insensitive)', async () => {
it('does not show a mismatch error when the signature matches the expected name (case/whitespace insensitive)', async () => {
const { container } = render(
<PreSubmitInfo2
formData={{}}
formData={{ fullName: { first: 'John', last: 'Doe' } }}
showError
user={buildUser({ first: 'John', last: 'Doe' })}
onSectionComplete={() => {}}
/>,
);
Expand All @@ -184,13 +163,11 @@ describe('COE PreSubmitInfo2', () => {
it('shows a mismatch error when showError is true even if the input has not been blurred', async () => {
const { container } = render(
<PreSubmitInfo2
formData={{}}
formData={{ fullName: { first: 'John', last: 'Doe' } }}
showError
user={buildUser()}
onSectionComplete={() => {}}
/>,
);
// empty signature mismatches profile name -> should surface the input error
const sot = container.querySelector('va-statement-of-truth');
await waitFor(() => {
expect(sot.getAttribute('input-error')).to.include('John Doe');
Expand All @@ -202,7 +179,6 @@ describe('COE PreSubmitInfo2', () => {
<PreSubmitInfo2
formData={{}}
showError={false}
user={buildUser()}
onSectionComplete={() => {}}
/>,
);
Expand Down
Loading