{
expect(btn).toBeDefined()
})
+ describe('Submit', () => {
+ it('should submit button must exist if this is the last step.', async () => {
+ const { findByTestId } = setup({
+ currentFile: mockFile({ name: 'test.pdf' }),
+ isLastStep: jest.fn(() => true)
+ })
+ const btn = await findByTestId('ButtonSave')
+ expect(btn).toBeDefined()
+ })
+ })
+
describe('setCurrentFile', () => {
it('should setCurrentFile must be called once with null when restarting the file selection', async () => {
const mockSetCurrentFile = jest.fn()
@@ -245,7 +256,7 @@ describe('AcquisitionResult component:', () => {
const { getByTestId } = setup({
currentFile: mockFile({ name: 'test.pdf' }),
mockIsFlagshipOCRAvailable: true,
- isLastStep: jest.fn(() => true),
+ isLastStep: jest.fn(() => false),
currentDefinition: { ocrAttributes: [] },
allCurrentSteps: [{ isDisplayed: 'ocr' }]
})
@@ -262,7 +273,7 @@ describe('AcquisitionResult component:', () => {
const { findByTestId } = setup({
currentFile: mockFile({ name: FLAGSHIP_SCAN_TEMP_FILENAME }),
mockIsFlagshipOCRAvailable: true,
- isLastStep: jest.fn(() => true),
+ isLastStep: jest.fn(() => false),
mockGetAttributesFromOcr,
currentDefinition: { ocrAttributes: [] },
allCurrentSteps: [{ isDisplayed: 'ocr' }]
diff --git a/src/components/ModelSteps/ScanResult/ScanResultTitle.jsx b/src/components/ModelSteps/ScanResult/ScanResultTitle.jsx
index 0f369541..d6a24338 100644
--- a/src/components/ModelSteps/ScanResult/ScanResultTitle.jsx
+++ b/src/components/ModelSteps/ScanResult/ScanResultTitle.jsx
@@ -1,8 +1,8 @@
import React from 'react'
+import { isPDFFile } from 'src/components/ModelSteps/helpers'
import Icon from 'cozy-ui/transpiled/react/Icon'
import Typography from 'cozy-ui/transpiled/react/Typography'
-import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { makeStyles } from 'cozy-ui/transpiled/react/styles'
@@ -13,12 +13,13 @@ const useStyles = makeStyles(() => ({
}
}))
-const ScanResultTitle = () => {
+const ScanResultTitle = ({ currentFile }) => {
const styles = useStyles()
const { t } = useI18n()
- const { isDesktop } = useBreakpoints()
- const device = isDesktop ? 'desktop' : 'mobile'
+ const title = t(
+ `Acquisition.${isPDFFile(currentFile) ? 'pdf' : 'image'}.success`
+ )
return (
@@ -28,7 +29,7 @@ const ScanResultTitle = () => {
aria-hidden="true"
/>
- {t(`Acquisition.${device}.success`)}
+ {title}
)
diff --git a/src/components/ModelSteps/helpers.js b/src/components/ModelSteps/helpers.js
index 94a58386..682e4eab 100644
--- a/src/components/ModelSteps/helpers.js
+++ b/src/components/ModelSteps/helpers.js
@@ -432,3 +432,10 @@ export const normalizeFormdataMetadata = ({
return merge({}, formData, metadataNormalized)
}
+
+/**
+ * Check if a file is a PDF file
+ * @param {File} file - File object
+ * @returns {boolean}
+ */
+export const isPDFFile = file => file.type === 'application/pdf'
diff --git a/src/components/Views/Edit.jsx b/src/components/Views/Edit.jsx
index c357a741..392ec2f4 100644
--- a/src/components/Views/Edit.jsx
+++ b/src/components/Views/Edit.jsx
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
-import { useNavigate, useParams } from 'react-router-dom'
+import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
import { FormDataProvider } from 'src/components/Contexts/FormDataProvider'
import { useFormData } from 'src/components/Contexts/FormDataProvider'
import { StepperDialogProvider } from 'src/components/Contexts/StepperDialogProvider'
@@ -51,7 +51,14 @@ const EditPaperModal = ({ ioCozyFile, contacts, onClose, onSubmit }) => {
return
}
-export const EditLoader = ({ onClose, onSubmit }) => {
+/**
+ * Also used with the intent
+ * @param {object} props
+ * @param {Function} props.onClose
+ * @param {Function} props.onSubmit
+ * @param {Function} props.stepFilterFn
+ */
+export const EditLoader = ({ onClose, onSubmit, stepFilterFn }) => {
const { fileId } = useParams()
const buildedFilesQuery = buildFileQueryById(fileId)
@@ -61,11 +68,12 @@ export const EditLoader = ({ onClose, onSubmit }) => {
)
const { contacts, isLoadingContacts } = useReferencedContact(files || [])
- if (isQueryLoading(filesQueryResult) || isLoadingContacts)
+ if (isQueryLoading(filesQueryResult) || isLoadingContacts) {
return
+ }
return (
-
+
{
const EditWrapper = () => {
const navigate = useNavigate()
+ const [searchParams] = useSearchParams()
+ const stepModel = searchParams.get('model')
+
+ const stepFilterFn = step => {
+ if (!stepModel) {
+ return true
+ }
+ return step.model === stepModel
+ }
return (
navigate('..')}
onSubmit={() => navigate('..')}
+ stepFilterFn={stepFilterFn}
/>
)
}
diff --git a/src/helpers/filterSteps.js b/src/helpers/filterSteps.js
index 5acd3a0b..66cd16aa 100644
--- a/src/helpers/filterSteps.js
+++ b/src/helpers/filterSteps.js
@@ -5,13 +5,16 @@ import { isSomePaperStepsCompliantWithOCR } from 'src/helpers/isSomePaperStepsCo
* Filter a list of step with OCR contraint
* @param {object[]} steps list of step
* @param {Object} [webviewIntent] - The webview intent service to interact with the native environment.
- * @param {function} webviewIntent.call - A function to call native methods, expecting the method name and its arguments.
+ * @param {boolean} [isEdit] - True if the current view is an edit view
+ * @param {Function} [stepFilterFn] - The filter function to apply on the steps
+ * @param {boolean} [fromFlagshipUpload] - True if the current view is from the flagship upload
* @returns {Promise