-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates tests for ezr, mhv-landing-page, profile/dashboard, profile/d…
…irect-deposit
- Loading branch information
Showing
12 changed files
with
96 additions
and
113 deletions.
There are no files selected for viewing
43 changes: 23 additions & 20 deletions
43
src/applications/ezr/tests/unit/components/FormAlerts/IdentityVerificationAlert.unit.spec.js
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 |
---|---|---|
@@ -1,34 +1,37 @@ | ||
import React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
import { fireEvent } from '@testing-library/react'; | ||
import { expect } from 'chai'; | ||
import sinon from 'sinon'; | ||
import { renderInReduxProvider } from '@department-of-veterans-affairs/platform-testing/react-testing-library-helpers'; | ||
import IdentityVerificationAlert from '../../../../components/FormAlerts/IdentityVerificationAlert'; | ||
|
||
describe('ezr <IdentityVerificationAlert>', () => { | ||
context('when the component renders', () => { | ||
it('should render `va-alert` with status of `continue`', () => { | ||
const { container } = render(<IdentityVerificationAlert />); | ||
const selector = container.querySelector('va-alert'); | ||
expect(selector).to.exist; | ||
expect(selector).to.have.attr('status', 'continue'); | ||
}); | ||
|
||
it('should render `verify` button', () => { | ||
const { container } = render(<IdentityVerificationAlert />); | ||
const selector = container.querySelector('.vads-c-action-link--green'); | ||
it('should render `va-alert-sign-in` with status of `verifyIdMe`', () => { | ||
const { container } = renderInReduxProvider( | ||
<IdentityVerificationAlert />, | ||
{ | ||
initialState: { | ||
user: { profile: { signIn: { serviceName: 'idme ' } } }, | ||
}, | ||
}, | ||
); | ||
const selector = container.querySelector('va-alert-sign-in'); | ||
expect(selector).to.exist; | ||
expect(selector).to.have.attr('variant', 'verifyIdMe'); | ||
}); | ||
}); | ||
|
||
context('when the `verify` button is clicked', () => { | ||
it('should trigger the `onVerify` function', () => { | ||
const verifySpy = sinon.spy(); | ||
const { container } = render( | ||
<IdentityVerificationAlert onVerify={verifySpy} />, | ||
it('should render ID.me button', () => { | ||
const { container } = renderInReduxProvider( | ||
<IdentityVerificationAlert />, | ||
{ | ||
initialState: { | ||
user: { profile: { signIn: { serviceName: 'idme ' } } }, | ||
}, | ||
}, | ||
); | ||
const selector = container.querySelector('.vads-c-action-link--green'); | ||
const selector = container.querySelector('.idme-verify-button'); | ||
fireEvent.click(selector); | ||
expect(verifySpy.called).to.be.true; | ||
expect(selector).to.exist; | ||
}); | ||
}); | ||
}); |
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
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
8 changes: 6 additions & 2 deletions
8
src/applications/personalization/profile/components/direct-deposit/alerts/VerifyIdentity.jsx
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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
import React from 'react'; | ||
import VerifyAlert from '~/platform/user/authentication/components/VerifyAlert'; | ||
|
||
export default function VerifyIdentity() { | ||
return <VerifyAlert headingLevel={2} />; | ||
export default function VerifyIdentity({ dataTestId }) { | ||
Check warning on line 4 in src/applications/personalization/profile/components/direct-deposit/alerts/VerifyIdentity.jsx GitHub Actions / Linting (Files Changed)
|
||
return ( | ||
<div data-testid={dataTestId}> | ||
<VerifyAlert headingLevel={2} /> | ||
</div> | ||
); | ||
} |
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
91 changes: 26 additions & 65 deletions
91
...ions/personalization/profile/tests/components/direct-deposit/VerifyIdentity.unit.spec.jsx
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 |
---|---|---|
@@ -1,91 +1,52 @@ | ||
import React from 'react'; | ||
import { cleanup, waitFor } from '@testing-library/react'; | ||
import { cleanup } from '@testing-library/react'; | ||
import { expect } from 'chai'; | ||
import { mockCrypto } from 'platform/utilities/oauth/mockCrypto'; | ||
import { renderInReduxProvider } from '~/platform/testing/unit/react-testing-library-helpers'; | ||
import VerifyIdentity from '../../../components/direct-deposit/alerts/VerifyIdentity'; | ||
|
||
const oldCrypto = global.window.crypto; | ||
|
||
const initialState = { | ||
const generateStore = serviceName => ({ | ||
featureToggles: { | ||
profileShowCredentialRetirementMessaging: true, | ||
}, | ||
user: { | ||
profile: { | ||
signIn: { | ||
service: 'idme', | ||
}, | ||
}, | ||
profile: { signIn: { serviceName } }, | ||
}, | ||
}; | ||
}); | ||
|
||
describe('authenticated experience -- profile -- direct deposit', () => { | ||
describe('VerifyIdentity', () => { | ||
beforeEach(() => { | ||
global.window.crypto = mockCrypto; | ||
window.location = new URL('https://dev.va.gov/'); | ||
}); | ||
|
||
afterEach(() => { | ||
global.window.crypto = oldCrypto; | ||
cleanup(); | ||
}); | ||
|
||
it('renders the proper URLs for VerifyIdentity (SAML)', async () => { | ||
const screen = renderInReduxProvider( | ||
<VerifyIdentity useOAuth={false} />, | ||
{ initialState }, | ||
); | ||
const loginGovAnchor = await screen.findByTestId('logingov'); | ||
const idmeAnchor = await screen.findByTestId('idme'); | ||
it('renders the correct verify alert for ID.me', async () => { | ||
const { container } = renderInReduxProvider(<VerifyIdentity />, { | ||
initialState: generateStore('idme'), | ||
}); | ||
|
||
await waitFor(() => | ||
expect(loginGovAnchor.href).to.include(`logingov_signup_verified`), | ||
); | ||
await waitFor(() => | ||
expect(idmeAnchor.href).to.include('idme_signup_verified'), | ||
); | ||
screen.unmount(); | ||
const signInAlert = container.querySelector('va-alert-sign-in'); | ||
expect(signInAlert).to.exist; | ||
expect(signInAlert.getAttribute('variant')).to.eql('verifyIdMe'); | ||
}); | ||
|
||
it('renders the proper URLs for VerifyIdentity (OAuth)', async () => { | ||
const screen = renderInReduxProvider(<VerifyIdentity useOAuth />, { | ||
initialState, | ||
it('renders the correct verify alert for Login.gov', async () => { | ||
const { container } = renderInReduxProvider(<VerifyIdentity />, { | ||
initialState: generateStore('logingov'), | ||
}); | ||
const loginGovAnchor = await screen.findByTestId('logingov'); | ||
const idmeAnchor = await screen.findByTestId('idme'); | ||
|
||
await waitFor(() => | ||
expect(loginGovAnchor.href).to.include(`type=logingov`), | ||
); | ||
await waitFor(() => expect(loginGovAnchor.href).to.include(`acr=min`)); | ||
await waitFor(() => | ||
expect(loginGovAnchor.href).to.include(`client_id=vaweb`), | ||
); | ||
await waitFor(() => expect(loginGovAnchor.href).to.include('/authorize')); | ||
await waitFor(() => | ||
expect(loginGovAnchor.href).to.include('response_type=code'), | ||
); | ||
await waitFor(() => | ||
expect(loginGovAnchor.href).to.include('code_challenge='), | ||
); | ||
await waitFor(() => expect(loginGovAnchor.href).to.include('state=')); | ||
const signInAlert = container.querySelector('va-alert-sign-in'); | ||
expect(signInAlert).to.exist; | ||
expect(signInAlert.getAttribute('variant')).to.eql('verifyLoginGov'); | ||
}); | ||
|
||
it('renders the correct verify alert for ID.me', async () => { | ||
const { container } = renderInReduxProvider(<VerifyIdentity />, { | ||
initialState: generateStore('mhv'), | ||
}); | ||
|
||
await waitFor(() => expect(idmeAnchor.href).to.include(`type=idme`)); | ||
await waitFor(() => expect(idmeAnchor.href).to.include(`acr=min`)); | ||
await waitFor(() => | ||
expect(idmeAnchor.href).to.include(`client_id=vaweb`), | ||
); | ||
await waitFor(() => expect(idmeAnchor.href).to.include('/authorize')); | ||
await waitFor(() => | ||
expect(idmeAnchor.href).to.include('response_type=code'), | ||
); | ||
await waitFor(() => | ||
expect(idmeAnchor.href).to.include('code_challenge='), | ||
); | ||
await waitFor(() => expect(idmeAnchor.href).to.include('state=')); | ||
screen.unmount(); | ||
const signInAlert = container.querySelector('va-alert-sign-in'); | ||
expect(signInAlert).to.exist; | ||
expect(signInAlert.getAttribute('variant')).to.eql('signInEither'); | ||
}); | ||
}); | ||
}); |
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