Skip to content

Commit

Permalink
feat: Wrap scanner feature behind mespapiers.features.v3 flag
Browse files Browse the repository at this point in the history
This feature must not be effective in the next version of the app (2.2),
we must surround it with a flag.
  • Loading branch information
Merkur39 committed May 23, 2023
1 parent eb6e09b commit e467977
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'
import React, { useState, useEffect } from 'react'

import { isFlagshipApp, isMobile } from 'cozy-device-helper'
import flag from 'cozy-flags'
import { useWebviewIntent } from 'cozy-intent'

import ScanDesktopActions from './ScanDesktopActions'
Expand All @@ -17,10 +18,14 @@ const ScanActionsWrapper = props => {
const isAvailable = await webviewIntent.call('isScannerAvailable')
setIsFlagshipScanAvailable(isAvailable)
}
webviewIntent && checkScanDocument()
flag('mespapiers.features.v3') && webviewIntent && checkScanDocument()
}, [webviewIntent])

if (isFlagshipApp() && isFlagshipScanAvailable) {
if (
flag('mespapiers.features.v3') &&
isFlagshipApp() &&
isFlagshipScanAvailable
) {
return <ScanFlagshipActions {...props} />
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { render, waitFor } from '@testing-library/react'
import React from 'react'

import { isMobile, isFlagshipApp } from 'cozy-device-helper'
import flag from 'cozy-flags'
import { useWebviewIntent } from 'cozy-intent'

import AppLike from '../../../../../test/components/AppLike'
Expand All @@ -21,6 +22,7 @@ const mockFormData = ({ metadata = {}, data = [], contacts = [] } = {}) => ({
data,
contacts
})
jest.mock('cozy-flags')
jest.mock('cozy-intent', () => ({
...jest.requireActual('cozy-intent'),
useWebviewIntent: jest.fn()
Expand Down Expand Up @@ -57,6 +59,7 @@ const setup = ({
isFlagshipAppMock = false,
isScannerAvailable = false
} = {}) => {
flag.mockReturnValue(true)
isMobile.mockReturnValue(isMobileMock || isFlagshipAppMock)
isFlagshipApp.mockReturnValue(isFlagshipAppMock)
useWebviewIntent.mockReturnValue({
Expand Down

0 comments on commit e467977

Please sign in to comment.