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 @@ -202,7 +202,7 @@ interface AcuantDetectedResult {
}

/**
* @see https://github.com/Acuant/JavascriptWebSDKV11/tree/11.4.3/SimpleHTMLApp#acuantcamera
* @see https://github.com/Acuant/JavascriptWebSDKV11/tree/11.8.1#image-from-acuantcameraui-and-acuantcamera
*/
export interface AcuantSuccessResponse {
/**
Expand All @@ -212,7 +212,7 @@ export interface AcuantSuccessResponse {
/**
* Document type
*/
cardType: AcuantDocumentType;
cardtype: AcuantDocumentType;
/**
* Detected image glare
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface ImageAnalyticsPayload {
}

interface AcuantImageAnalyticsPayload extends ImageAnalyticsPayload {
documentType: AcuantDocumentTypeLabel;
documentType: AcuantDocumentTypeLabel | string;
dpi: number;
moire: number;
glare: number;
Expand Down Expand Up @@ -135,14 +135,16 @@ export const isAcuantCameraAccessFailure = (error: AcuantCaptureFailureError): e
* Returns a human-readable document label corresponding to the given document type constant.
*
*/
function getDocumentTypeLabel(documentType: AcuantDocumentType): AcuantDocumentTypeLabel {
function getDocumentTypeLabel(documentType: AcuantDocumentType): AcuantDocumentTypeLabel | string {
switch (documentType) {
case 0:
return 'none';
case 1:
return 'id';
case 2:
return 'passport';
default:
return 'none';
return `An error in document type returned: ${documentType}`;
}
}

Expand Down Expand Up @@ -433,7 +435,7 @@ function AcuantCapture(
}

function onAcuantImageCaptureSuccess(nextCapture: AcuantSuccessResponse) {
const { image, cardType, dpi, moire, glare, sharpness } = nextCapture;
const { image, cardtype, dpi, moire, glare, sharpness } = nextCapture;
const isAssessedAsGlare = glare < glareThreshold;
const isAssessedAsBlurry = sharpness < sharpnessThreshold;
const { width, height, data } = image;
Expand All @@ -454,7 +456,7 @@ function AcuantCapture(
height,
mimeType: 'image/jpeg', // Acuant Web SDK currently encodes all images as JPEG
source: 'acuant',
documentType: getDocumentTypeLabel(cardType),
documentType: getDocumentTypeLabel(cardtype),
dpi,
moire,
glare,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ACUANT_CAPTURE_SUCCESS_RESULT = {
width: 1748,
height: 1104,
},
cardType: 1,
cardtype: 1,
dpi: 519,
moire: 99,
moireraw: 99,
Expand Down Expand Up @@ -756,6 +756,41 @@ describe('document-capture/components/acuant-capture', () => {
});
});

it('logs a human readable error when the document type errs', async () => {
const trackEvent = sinon.spy();
const incorrectCardType = 5;
const { findByText, getByText } = render(
<AnalyticsContext.Provider value={{ trackEvent }}>
<DeviceContext.Provider value={{ isMobile: true }}>
<AcuantContextProvider sdkSrc="about:blank" cameraSrc="about:blank">
<AcuantCapture label="Image" name="test" />
</AcuantContextProvider>
</DeviceContext.Provider>
</AnalyticsContext.Provider>,
);

initialize({
start: sinon.stub().callsFake(async (callbacks) => {
await Promise.resolve();
callbacks.onCaptured();
await Promise.resolve();
callbacks.onCropped({ ...ACUANT_CAPTURE_SUCCESS_RESULT, cardtype: incorrectCardType });
}),
});

const button = getByText('doc_auth.buttons.take_picture');
fireEvent.click(button);

await findByText('doc_auth.info.image_loading');

expect(trackEvent).to.have.been.calledWith(
'IdV: test image added',
sinon.match({
documentType: `An error in document type returned: ${incorrectCardType}`,
}),
);
});

it('triggers forced upload', () => {
const { getByText } = render(
<I18nContext.Provider
Expand Down