Skip to content

Commit

Permalink
Extend session when changing document capture steps (#11333)
Browse files Browse the repository at this point in the history
* Extend session when moving between document capture steps

changelog: Bug Fixes, Document Capture, Extend session when moving between document capture steps

* Update spec/javascript/packages/document-capture/components/document-capture-spec.jsx

Co-authored-by: Andrew Duthie <[email protected]>

---------

Co-authored-by: Andrew Duthie <[email protected]>
  • Loading branch information
2 people authored and MrNagoo committed Oct 25, 2024
1 parent 234bb27 commit 4e65e03
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion app/javascript/packs/document-capture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { isCameraCapableMobile } from '@18f/identity-device';
import { FlowContext } from '@18f/identity-verify-flow';
import { trackEvent as baseTrackEvent } from '@18f/identity-analytics';
import { extendSession } from '@18f/identity-session';
import type { FlowPath, DeviceContextValue } from '@18f/identity-document-capture';

/**
Expand All @@ -40,6 +41,7 @@ interface AppRootData {
docAuthSelfieDesktopTestMode: string;
locationsUrl: string;
addressSearchUrl: string;
sessionsUrl: string;
docAuthSeparatePagesEnabled: string;
}

Expand Down Expand Up @@ -112,6 +114,7 @@ const {
docAuthSeparatePagesEnabled,
locationsUrl: locationsURL,
addressSearchUrl: addressSearchURL,
sessionsUrl: sessionsURL,
} = appRoot.dataset as DOMStringMap & AppRootData;

let parsedUsStatesTerritories = [];
Expand Down Expand Up @@ -201,7 +204,12 @@ const App = composeComponents(
maxSubmissionAttemptsBeforeNativeCamera: Number(maxSubmissionAttemptsBeforeNativeCamera),
},
],
[DocumentCapture],
[
DocumentCapture,
{
onStepChange: () => extendSession(sessionsURL),
},
],
);

render(<App />, appRoot);
1 change: 1 addition & 0 deletions app/views/idv/shared/_document_capture.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
how_to_verify_url: idv_how_to_verify_url,
previous_step_url: @previous_step_url,
locations_url: idv_in_person_usps_locations_url,
sessions_url: api_internal_sessions_path,
doc_auth_separate_pages_enabled: IdentityConfig.store.doc_auth_separate_pages_enabled,
address_search_url: '',
} %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ describe('document-capture/components/document-capture', () => {

context('in person steps', () => {
it('renders the step indicator', async () => {
const callback = sandbox.spy();
const endpoint = '/upload';
const { getByLabelText, getByText, queryByText, findByText } = render(
<UploadContextProvider upload={httpUpload} endpoint={endpoint}>
Expand All @@ -326,7 +327,7 @@ describe('document-capture/components/document-capture', () => {
inPersonURL: '/in_person',
}}
>
<DocumentCapture />
<DocumentCapture onStepChange={callback} />
</InPersonContext.Provider>
</FlowContext.Provider>
</ServiceProviderContextProvider>
Expand Down Expand Up @@ -364,6 +365,7 @@ describe('document-capture/components/document-capture', () => {

expect(step).to.be.ok();
expect(step.closest('.step-indicator__step--current')).to.exist();
expect(callback).to.have.been.calledOnce();
});
});
});
Expand Down

0 comments on commit 4e65e03

Please sign in to comment.