From dadbde2f8b2603b05f50537f5a634ddaebb3d32c Mon Sep 17 00:00:00 2001 From: David Ly Date: Mon, 13 Jan 2025 14:50:29 +0100 Subject: [PATCH] Fixed conflits with VideoCapture feature --- .../DamageDisclosurePage.tsx | 5 +++- .../PhotoCapturePage/PhotoCapturePage.tsx | 3 ++- .../src/DamageDisclosure/DamageDisclosure.tsx | 11 ++++++-- .../DamageDisclosureHUD.tsx | 19 ++++++++++++-- .../DamageDisclosureHUDElements.tsx | 14 ++++++++-- .../src/PhotoCapture/PhotoCapture.tsx | 18 ++++++++----- .../PhotoCaptureHUD/PhotoCaptureHUD.tsx | 17 ++++++++++-- .../PhotoCaptureHUDElements.tsx | 16 ++++++++++-- .../SightGuideline/SightGuideline.tsx | 4 +-- .../PhotoCaptureHUDElementsSight/hooks.ts | 2 +- .../PhotoCaptureHUDTutorial.tsx | 2 +- .../src/PhotoCapture/hooks/index.ts | 1 - .../PartSelection/PartSelection.tsx | 10 ++++--- .../src/hooks/useAddDamageMode.ts | 4 +-- .../src/hooks/useUploadQueue.ts | 2 +- .../DamageDisclosure.test.tsx | 3 +++ .../DamageDisclosureHUDElements.test.tsx | 4 +-- .../DamageDislosureHUD.test.tsx | 3 ++- .../test/PhotoCapture/PhotoCapture.test.tsx | 16 +++++------- .../PhotoCaptureHUD/PhotoCaptureHUD.test.tsx | 26 +++---------------- .../PhotoCaptureHUDElements.test.tsx | 3 ++- packages/network/src/api/image/requests.ts | 6 +++-- 22 files changed, 123 insertions(+), 66 deletions(-) diff --git a/apps/demo-app/src/pages/DamageDisclosurePage/DamageDisclosurePage.tsx b/apps/demo-app/src/pages/DamageDisclosurePage/DamageDisclosurePage.tsx index b9913121a..327ac2e3b 100644 --- a/apps/demo-app/src/pages/DamageDisclosurePage/DamageDisclosurePage.tsx +++ b/apps/demo-app/src/pages/DamageDisclosurePage/DamageDisclosurePage.tsx @@ -2,14 +2,16 @@ import { useTranslation } from 'react-i18next'; import { useMonkAppState } from '@monkvision/common'; import { DamageDisclosure } from '@monkvision/inspection-capture-web'; import { useNavigate } from 'react-router-dom'; +import { CaptureWorkflow, VehicleType } from '@monkvision/types'; import styles from './DamageDisclosurePage.module.css'; import { Page } from '../pages'; export function DamageDisclosurePage() { const navigate = useNavigate(); const { i18n } = useTranslation(); - const { config, authToken, inspectionId } = useMonkAppState({ + const { config, authToken, inspectionId, vehicleType } = useMonkAppState({ requireInspection: true, + requireWorkflow: CaptureWorkflow.PHOTO, }); return ( @@ -24,6 +26,7 @@ export function DamageDisclosurePage() { inspectionId={inspectionId} onComplete={() => navigate(Page.PHOTO_CAPTURE)} lang={i18n.language} + vehicleType={vehicleType ?? VehicleType.SEDAN} /> ); diff --git a/apps/demo-app/src/pages/PhotoCapturePage/PhotoCapturePage.tsx b/apps/demo-app/src/pages/PhotoCapturePage/PhotoCapturePage.tsx index 10248471e..244df29b5 100644 --- a/apps/demo-app/src/pages/PhotoCapturePage/PhotoCapturePage.tsx +++ b/apps/demo-app/src/pages/PhotoCapturePage/PhotoCapturePage.tsx @@ -2,7 +2,7 @@ import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useMonkAppState } from '@monkvision/common'; import { PhotoCapture } from '@monkvision/inspection-capture-web'; -import { CaptureWorkflow } from '@monkvision/types'; +import { CaptureWorkflow, VehicleType } from '@monkvision/types'; import styles from './PhotoCapturePage.module.css'; import { createInspectionReportLink } from './inspectionReport'; @@ -36,6 +36,7 @@ export function PhotoCapturePage() { sights={currentSights} onComplete={handleComplete} lang={i18n.language} + vehicleType={vehicleType ?? VehicleType.SEDAN} /> ); diff --git a/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosure.tsx b/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosure.tsx index e6ffcf16d..4b22c8b32 100644 --- a/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosure.tsx +++ b/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosure.tsx @@ -11,12 +11,13 @@ import { MonkApiConfig } from '@monkvision/network'; import { AddDamage, CameraConfig, - CaptureAppConfig, + PhotoCaptureAppConfig, ComplianceOptions, CompressionOptions, DeviceOrientation, ImageType, MonkPicture, + VehicleType, } from '@monkvision/types'; import { useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -40,7 +41,7 @@ import { CaptureScreen } from '../types'; export interface DamageDisclosureProps extends Pick, 'resolution' | 'allowImageUpscaling'>, Pick< - CaptureAppConfig, + PhotoCaptureAppConfig, | keyof CameraConfig | 'maxUploadDurationWarning' | 'useAdaptiveImageQuality' @@ -60,6 +61,10 @@ export interface DamageDisclosureProps * one as the one that created the inspection provided in the `inspectionId` prop. */ apiConfig: MonkApiConfig; + /** + * The vehicle type of the inspection. + */ + vehicleType?: VehicleType; /** * Callback called when the user clicks on the Close button. If this callback is not provided, the button will not be * displayed on the screen. @@ -98,6 +103,7 @@ export function DamageDisclosure({ useAdaptiveImageQuality = true, lang, enforceOrientation, + vehicleType = VehicleType.SEDAN, ...initialCameraConfig }: DamageDisclosureProps) { useI18nSync(lang); @@ -174,6 +180,7 @@ export function DamageDisclosure({ images, addDamage, onValidateVehicleParts: addDamageHandle.handleValidateVehicleParts, + vehicleType, }; return ( diff --git a/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUD.tsx b/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUD.tsx index 211e20fc6..8c5373440 100644 --- a/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUD.tsx +++ b/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUD.tsx @@ -1,5 +1,12 @@ import { useMemo, useState } from 'react'; -import { CaptureAppConfig, Image, ImageStatus, ImageType, VehiclePart } from '@monkvision/types'; +import { + PhotoCaptureAppConfig, + Image, + ImageStatus, + ImageType, + VehiclePart, + VehicleType, +} from '@monkvision/types'; import { useTranslation } from 'react-i18next'; import { BackdropDialog } from '@monkvision/common-ui-web'; import { CameraHUDProps } from '@monkvision/camera-web'; @@ -16,7 +23,7 @@ import { HUDOverlay } from '../../components/HUDOverlay'; */ export interface DamageDisclosureHUDProps extends CameraHUDProps, - Pick { + Pick { /** * The inspection ID. */ @@ -70,6 +77,10 @@ export interface DamageDisclosureHUDProps * The current images taken by the user (ignoring retaken pictures etc.). */ images: Image[]; + /** + * The vehicle type of the inspection. + */ + vehicleType: VehicleType; } /** @@ -82,6 +93,7 @@ export function DamageDisclosureHUD({ lastPictureTakenUri, mode, vehicleParts, + addDamage, onAddDamage, onAddDamagePartsSelected, onValidateVehicleParts, @@ -94,6 +106,7 @@ export function DamageDisclosureHUD({ handle, cameraPreview, images, + vehicleType, }: DamageDisclosureHUDProps) { const { t } = useTranslation(); const [showCloseModal, setShowCloseModal] = useState(false); @@ -122,6 +135,7 @@ export function DamageDisclosureHUD({ { } diff --git a/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUDElements/DamageDisclosureHUDElements.tsx b/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUDElements/DamageDisclosureHUDElements.tsx index 19c78ee9c..d41b4b1b1 100644 --- a/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUDElements/DamageDisclosureHUDElements.tsx +++ b/packages/inspection-capture-web/src/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUDElements/DamageDisclosureHUDElements.tsx @@ -1,10 +1,15 @@ -import { CaptureAppConfig, PixelDimensions, VehiclePart } from '@monkvision/types'; +import { + PhotoCaptureAppConfig, + PixelDimensions, + VehiclePart, + VehicleType, +} from '@monkvision/types'; import { CaptureMode } from '../../../types'; import { CloseUpShot, PartSelection, ZoomOutShot } from '../../../components'; /** * Props of the DamageDisclosureHUDElements component. */ -export interface DamageDisclosureHUDElementsProps extends Pick { +export interface DamageDisclosureHUDElementsProps extends Pick { /** * The current mode of the component. */ @@ -41,6 +46,10 @@ export interface DamageDisclosureHUDElementsProps extends Pick {mode !== CaptureMode.ADD_DAMAGE_PART_SELECT && ( diff --git a/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.tsx b/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.tsx index 9cadc2689..11c2608d0 100644 --- a/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.tsx +++ b/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.tsx @@ -1,4 +1,11 @@ -import { CaptureAppConfig, Image, PixelDimensions, Sight, VehiclePart } from '@monkvision/types'; +import { + PhotoCaptureAppConfig, + Image, + PixelDimensions, + Sight, + VehiclePart, + VehicleType, +} from '@monkvision/types'; import { TutorialSteps } from '../../hooks'; import { PhotoCaptureHUDElementsSight } from '../PhotoCaptureHUDElementsSight'; import { CloseUpShot, ZoomOutShot, PartSelection } from '../../../components'; @@ -8,7 +15,7 @@ import { CaptureMode } from '../../../types'; * Props of the PhotoCaptureHUDElements component. */ export interface PhotoCaptureHUDElementsProps - extends Pick { + extends Pick { /** * The currently selected sight in the PhotoCapture component : the sight that the user needs to capture. */ @@ -73,6 +80,10 @@ export interface PhotoCaptureHUDElementsProps * The current images taken by the user (ignoring retaken pictures etc.). */ images: Image[]; + /** + * The vehicle type of the inspection. + */ + vehicleType: VehicleType; } /** @@ -118,6 +129,7 @@ export function PhotoCaptureHUDElements(params: PhotoCaptureHUDElementsProps) { diff --git a/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.tsx b/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.tsx index 4cac72042..0772c716d 100644 --- a/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.tsx +++ b/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import { Button } from '@monkvision/common-ui-web'; -import { AddDamage, CaptureAppConfig } from '@monkvision/types'; +import { AddDamage, PhotoCaptureAppConfig } from '@monkvision/types'; import { useTranslation } from 'react-i18next'; import { getLanguage } from '@monkvision/common'; import { styles } from './SightGuideline.styles'; @@ -10,7 +10,7 @@ import { useColorBackground } from '../../../../hooks'; * Props of the SightGuideline component. */ export interface SightGuidelineProps - extends Pick { + extends Pick { /** * The id of the sight. */ diff --git a/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/hooks.ts b/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/hooks.ts index 7e36d3889..cf4960f9a 100644 --- a/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/hooks.ts +++ b/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/hooks.ts @@ -8,7 +8,7 @@ import { TutorialSteps } from '../../hooks'; * Props of the PhotoCaptureHUDElementsSight component. */ export interface PhotoCaptureHUDElementsSightProps - extends Pick { + extends Pick { /** * The list of sights provided to the PhotoCapture component. */ diff --git a/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.tsx b/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.tsx index 090f75001..d10d97d23 100644 --- a/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.tsx +++ b/packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.tsx @@ -13,7 +13,7 @@ import { useColorBackground } from '../../../hooks'; * Props of the PhotoCaptureHUDTutorial component. */ export interface PhotoCaptureHUDTutorialProps - extends Pick { + extends Pick { /** * The id of the sight. */ diff --git a/packages/inspection-capture-web/src/PhotoCapture/hooks/index.ts b/packages/inspection-capture-web/src/PhotoCapture/hooks/index.ts index f0c83d6a0..11517f16a 100644 --- a/packages/inspection-capture-web/src/PhotoCapture/hooks/index.ts +++ b/packages/inspection-capture-web/src/PhotoCapture/hooks/index.ts @@ -1,4 +1,3 @@ export * from './usePhotoCaptureSightState'; -export * from './useStartTasksOnComplete'; export * from './useComplianceAnalytics'; export * from './usePhotoCaptureTutorial'; diff --git a/packages/inspection-capture-web/src/components/PartSelection/PartSelection.tsx b/packages/inspection-capture-web/src/components/PartSelection/PartSelection.tsx index ca10391ee..4907d0ee5 100644 --- a/packages/inspection-capture-web/src/components/PartSelection/PartSelection.tsx +++ b/packages/inspection-capture-web/src/components/PartSelection/PartSelection.tsx @@ -1,6 +1,6 @@ -import { useMonkAppState, useMonkTheme, vehiclePartLabels, getLanguage } from '@monkvision/common'; +import { useMonkTheme, vehiclePartLabels, getLanguage } from '@monkvision/common'; import { VehiclePartSelection, Button } from '@monkvision/common-ui-web'; -import { VehiclePart } from '@monkvision/types'; +import { VehiclePart, VehicleType } from '@monkvision/types'; import { useTranslation } from 'react-i18next'; import { styles } from './PartSelection.styles'; import { useColorBackground } from '../../hooks'; @@ -9,6 +9,10 @@ import { useColorBackground } from '../../hooks'; * Props of PartSelection component. */ export interface PartSelectionProps { + /** + * Vehicle type of the wireframe to display. + */ + vehicleType: VehicleType; /** * Current vehicle parts selected to take a picture of. */ @@ -40,6 +44,7 @@ export interface PartSelectionProps { * to select the parts of the vehicle that the user wants to take a picture of. */ export function PartSelection({ + vehicleType, vehicleParts, disabled = false, onCancel = () => {}, @@ -47,7 +52,6 @@ export function PartSelection({ onValidateVehicleParts = () => {}, maxSelectableParts = 1, }: PartSelectionProps) { - const { vehicleType } = useMonkAppState(); const { palette } = useMonkTheme(); const { i18n, t } = useTranslation(); const backgroundColor = useColorBackground(0.9); diff --git a/packages/inspection-capture-web/src/hooks/useAddDamageMode.ts b/packages/inspection-capture-web/src/hooks/useAddDamageMode.ts index d0d38b8a2..e876f104a 100644 --- a/packages/inspection-capture-web/src/hooks/useAddDamageMode.ts +++ b/packages/inspection-capture-web/src/hooks/useAddDamageMode.ts @@ -1,13 +1,13 @@ import { useCallback, useState } from 'react'; import { useObjectMemo } from '@monkvision/common'; import { useAnalytics } from '@monkvision/analytics'; -import { AddDamage, CaptureAppConfig, VehiclePart } from '@monkvision/types'; +import { AddDamage, PhotoCaptureAppConfig, VehiclePart } from '@monkvision/types'; import { CaptureMode, CaptureScreen } from '../types'; /** * Parameters of the useAddDamageMode hook. */ -export interface AddDamageModeParams extends Pick { +export interface AddDamageModeParams extends Pick { /** * The current screen of the Capture component. */ diff --git a/packages/inspection-capture-web/src/hooks/useUploadQueue.ts b/packages/inspection-capture-web/src/hooks/useUploadQueue.ts index 524866778..26a58d1d0 100644 --- a/packages/inspection-capture-web/src/hooks/useUploadQueue.ts +++ b/packages/inspection-capture-web/src/hooks/useUploadQueue.ts @@ -1,7 +1,7 @@ import { Queue, uniq, useQueue } from '@monkvision/common'; import { AddImageOptions, ImageUploadType, MonkApiConfig, useMonkApi } from '@monkvision/network'; import { - CaptureAppConfig, + PhotoCaptureAppConfig, ComplianceOptions, MonkPicture, TaskName, diff --git a/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosure.test.tsx b/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosure.test.tsx index 46ec966cd..6f3d3b073 100644 --- a/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosure.test.tsx +++ b/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosure.test.tsx @@ -5,6 +5,7 @@ import { CompressionFormat, ImageType, TaskName, + VehicleType, } from '@monkvision/types'; const { CaptureMode } = jest.requireActual('../../src/types'); @@ -91,6 +92,7 @@ function createProps(): DamageDisclosureProps { useAdaptiveImageQuality: false, addDamage: AddDamage.PART_SELECT, maxUploadDurationWarning: 456, + vehicleType: VehicleType.SEDAN, }; } @@ -272,6 +274,7 @@ describe('DamageDisclosure component', () => { addDamage: props.addDamage, onRetry: disclosureState.retryLoadingInspection, onValidateVehicleParts: addDamageHandle.handleValidateVehicleParts, + vehicleType: props.vehicleType, }, }); diff --git a/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUDElements.test.tsx b/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUDElements.test.tsx index 5a4fd8cea..1f0184879 100644 --- a/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUDElements.test.tsx +++ b/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosureHUD/DamageDisclosureHUDElements.test.tsx @@ -1,5 +1,3 @@ -import { AddDamage } from '@monkvision/types'; - jest.mock('../../../src/components', () => ({ ZoomOutShot: jest.fn(() => <>), CloseUpShot: jest.fn(() => <>), @@ -9,6 +7,7 @@ jest.mock('../../../src/components', () => ({ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import { expectPropsOnChildMock } from '@monkvision/test-utils'; +import { AddDamage, VehicleType } from '@monkvision/types'; import { CaptureMode } from '../../../src/types'; import { DamageDisclosureHUDElements, DamageDisclosureHUDElementsProps } from '../../../src'; import { ZoomOutShot, CloseUpShot, PartSelection } from '../../../src/components'; @@ -24,6 +23,7 @@ function createProps(): DamageDisclosureHUDElementsProps { onValidateVehicleParts: jest.fn(), vehicleParts: [], addDamage: AddDamage.PART_SELECT, + vehicleType: VehicleType.SEDAN, }; } diff --git a/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosureHUD/DamageDislosureHUD.test.tsx b/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosureHUD/DamageDislosureHUD.test.tsx index 43bcbd7ea..9ccfcf079 100644 --- a/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosureHUD/DamageDislosureHUD.test.tsx +++ b/packages/inspection-capture-web/test/DamageDisclosure/DamageDisclosureHUD/DamageDislosureHUD.test.tsx @@ -1,4 +1,4 @@ -import { Image, ImageStatus } from '@monkvision/types'; +import { Image, ImageStatus, VehicleType } from '@monkvision/types'; jest.mock('../../../src/components/HUDButtons', () => ({ HUDButtons: jest.fn(() => <>), @@ -45,6 +45,7 @@ function createProps(): DamageDisclosureHUDProps { images: [{ sightId: 'test-sight-1', status: ImageStatus.NOT_COMPLIANT }] as Image[], onValidateVehicleParts: jest.fn(), vehicleParts: [], + vehicleType: VehicleType.SEDAN, }; } diff --git a/packages/inspection-capture-web/test/PhotoCapture/PhotoCapture.test.tsx b/packages/inspection-capture-web/test/PhotoCapture/PhotoCapture.test.tsx index 8ff3dda0b..c92b23ac1 100644 --- a/packages/inspection-capture-web/test/PhotoCapture/PhotoCapture.test.tsx +++ b/packages/inspection-capture-web/test/PhotoCapture/PhotoCapture.test.tsx @@ -7,6 +7,7 @@ import { DeviceOrientation, PhotoCaptureTutorialOption, TaskName, + VehicleType, } from '@monkvision/types'; import { Camera } from '@monkvision/camera-web'; import { useI18nSync, useLoadingState, usePreventExit } from '@monkvision/common'; @@ -15,17 +16,16 @@ import { useMonitoring } from '@monkvision/monitoring'; import { expectPropsOnChildMock } from '@monkvision/test-utils'; import { act, render, waitFor } from '@testing-library/react'; import { PhotoCapture, PhotoCaptureHUD, PhotoCaptureProps } from '../../src'; +import { usePhotoCaptureSightState, usePhotoCaptureTutorial } from '../../src/PhotoCapture/hooks'; import { + useStartTasksOnComplete, useAdaptiveCameraConfig, useAddDamageMode, useBadConnectionWarning, usePhotoCaptureImages, - usePhotoCaptureSightState, - usePhotoCaptureTutorial, usePictureTaken, useUploadQueue, -} from '../../src/PhotoCapture/hooks'; -import { useStartTasksOnComplete } from '../../src/hooks'; +} from '../../src/hooks'; const { CaptureMode } = jest.requireActual('../../src/types'); @@ -39,7 +39,6 @@ jest.mock('../../src/PhotoCapture/hooks', () => ({ setLastPictureTakenUri: jest.fn(), retryLoadingInspection: jest.fn(), })), - useStartTasksOnComplete: jest.fn(() => jest.fn()), useComplianceAnalytics: jest.fn(() => ({ isInitialInspectionFetched: jest.fn(), })), @@ -51,6 +50,7 @@ jest.mock('../../src/PhotoCapture/hooks', () => ({ })); jest.mock('../../src/hooks', () => ({ + useStartTasksOnComplete: jest.fn(() => jest.fn()), useAddDamageMode: jest.fn(() => ({ mode: CaptureMode.SIGHT, handleAddDamage: jest.fn(), @@ -85,10 +85,6 @@ jest.mock('../../src/hooks', () => ({ useTracking: jest.fn(), })); -jest.mock('../../src/hooks', () => ({ - useStartTasksOnComplete: jest.fn(() => jest.fn()), -})); - function createProps(): PhotoCaptureProps { return { sights: [sights['test-sight-1'], sights['test-sight-2'], sights['test-sight-3']], @@ -135,6 +131,7 @@ function createProps(): PhotoCaptureProps { enableTutorial: PhotoCaptureTutorialOption.ENABLED, allowSkipTutorial: true, enableSightTutorial: true, + vehicleType: VehicleType.SEDAN, }; } @@ -353,6 +350,7 @@ describe('PhotoCapture component', () => { onCloseTutorial: tutorial.closeTutorial, allowSkipTutorial: props.allowSkipRetake, enforceOrientation: props.enforceOrientation, + vehicleType: props.vehicleType, }, }); diff --git a/packages/inspection-capture-web/test/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.test.tsx b/packages/inspection-capture-web/test/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.test.tsx index d40f6f479..9cf632914 100644 --- a/packages/inspection-capture-web/test/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.test.tsx +++ b/packages/inspection-capture-web/test/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.test.tsx @@ -1,21 +1,3 @@ -import { DeviceOrientation, Image, ImageStatus } from '@monkvision/types'; -import { useTranslation } from 'react-i18next'; -import { act, render, screen } from '@testing-library/react'; -import { sights } from '@monkvision/sights'; -import { LoadingState } from '@monkvision/common'; -import { CameraHandle } from '@monkvision/camera-web'; -import { expectPropsOnChildMock } from '@monkvision/test-utils'; -import { BackdropDialog } from '@monkvision/common-ui-web'; -import { - PhotoCaptureHUD, - PhotoCaptureHUDButtons, - PhotoCaptureHUDElements, - PhotoCaptureHUDOverlay, - PhotoCaptureHUDProps, -} from '../../../src'; -import { PhotoCaptureMode } from '../../../src/PhotoCapture/hooks'; -import { OrientationEnforcer } from '../../../src/components'; - jest.mock('../../../src/PhotoCapture/PhotoCaptureHUD/hooks', () => ({ ...jest.requireActual('../../../src/PhotoCapture/PhotoCaptureHUD/hooks'), useComplianceNotification: jest.fn(() => false), @@ -23,13 +5,11 @@ jest.mock('../../../src/PhotoCapture/PhotoCaptureHUD/hooks', () => ({ jest.mock('../../../src/components', () => ({ HUDButtons: jest.fn(() => <>), HUDOverlay: jest.fn(() => <>), + OrientationEnforcer: jest.fn(() => <>), })); jest.mock('../../../src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements', () => ({ PhotoCaptureHUDElements: jest.fn(() => <>), })); -jest.mock('../../../src/components', () => ({ - OrientationEnforcer: jest.fn(() => <>), -})); import { useTranslation } from 'react-i18next'; import { act, render, screen } from '@testing-library/react'; @@ -39,8 +19,9 @@ import { CameraHandle } from '@monkvision/camera-web'; import { expectPropsOnChildMock } from '@monkvision/test-utils'; import { BackdropDialog } from '@monkvision/common-ui-web'; import { PhotoCaptureHUD, PhotoCaptureHUDElements, PhotoCaptureHUDProps } from '../../../src'; -import { HUDButtons, HUDOverlay } from '../../../src/components'; +import { HUDButtons, HUDOverlay, OrientationEnforcer } from '../../../src/components'; import { CaptureMode } from '../../../src/types'; +import { ImageStatus, Image, DeviceOrientation, VehicleType } from '@monkvision/types'; const cameraTestId = 'camera-test-id'; @@ -81,6 +62,7 @@ function createProps(): PhotoCaptureHUDProps { enforceOrientation: DeviceOrientation.PORTRAIT, onValidateVehicleParts: jest.fn(), vehicleParts: [], + vehicleType: VehicleType.SEDAN, }; } diff --git a/packages/inspection-capture-web/test/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements.test.tsx b/packages/inspection-capture-web/test/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements.test.tsx index e23700a87..dbd196be7 100644 --- a/packages/inspection-capture-web/test/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements.test.tsx +++ b/packages/inspection-capture-web/test/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements.test.tsx @@ -1,4 +1,4 @@ -import { AddDamage, Image, ImageStatus } from '@monkvision/types'; +import { AddDamage, Image, ImageStatus, VehicleType } from '@monkvision/types'; jest.mock('../../../src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight', () => ({ PhotoCaptureHUDElementsSight: jest.fn(() => <>), @@ -41,6 +41,7 @@ function createProps(): PhotoCaptureHUDElementsProps { onValidateVehicleParts: jest.fn(), vehicleParts: [], addDamage: AddDamage.PART_SELECT, + vehicleType: VehicleType.SEDAN, }; } diff --git a/packages/network/src/api/image/requests.ts b/packages/network/src/api/image/requests.ts index 2cdc907c8..ab91e45bd 100644 --- a/packages/network/src/api/image/requests.ts +++ b/packages/network/src/api/image/requests.ts @@ -206,8 +206,8 @@ export type AddImageOptions = | AddBeautyShotImageOptions | Add2ShotCloseUpImageOptions | AddVideoFrameOptions - | AddVideoManualPhotoOptions; - | AddPartSelectCloseUpImageOptions + | AddVideoManualPhotoOptions + | AddPartSelectCloseUpImageOptions; interface AddImageData { filename: string; @@ -241,6 +241,8 @@ function getImageLabel(options: AddImageOptions): TranslationObject | undefined fr: `Photo Manuelle Vidéo`, de: `Foto Manuell Video`, nl: `Foto-handleiding Video`, + }; + } if (options.uploadType === ImageUploadType.PART_SELECT_SHOT) { const partsTranslation = options.vehicleParts.map((part) => vehiclePartLabels[part]); return {