Skip to content

Commit

Permalink
fix: Account creation from the config modal is working
Browse files Browse the repository at this point in the history
We should not override the props.
  • Loading branch information
Crash-- committed May 19, 2023
1 parent d44b0fe commit 6be9633
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
@@ -1,6 +1,5 @@
import PropTypes from 'prop-types'
import React from 'react'
import { useNavigate } from 'react-router-dom'

import flag from 'cozy-flags'

Expand All @@ -13,7 +12,6 @@ import FlowProvider from '../FlowProvider'

export const KonnectorAccountWrapper = props => {
const { Component, ...rest } = props
const navigate = useNavigate()

return (
<FlowProvider
Expand All @@ -23,12 +21,7 @@ export const KonnectorAccountWrapper = props => {
{({ flow }) => {
if (flag('harvest.inappconnectors.enabled')) {
return (
<Component
{...rest}
trigger={rest.initialTrigger}
addAccount={() => navigate('new', { replace: true })}
flow={flow}
/>
<Component {...rest} trigger={rest.initialTrigger} flow={flow} />
)
}
return <KonnectorAccountTabs {...rest} flow={flow} />
Expand Down
Expand Up @@ -73,13 +73,14 @@ describe('KonnectorAccountWrapper', () => {
initialTrigger={trigger}
pushHistory={jest.fn()}
Component={ConfigurationTab}
showNewAccountButton={true}
/>
</VaultUnlockProvider>
</VaultProvider>
</MountPointProvider>
</AppLike>
)
return { root, onAccountDeleted }
return { root, onAccountDeleted, addAccount }
}

it('should render a configuration modal when harvest.inappconnectors.enabled flag is enabled and allow account disconnect', async () => {
Expand All @@ -94,4 +95,11 @@ describe('KonnectorAccountWrapper', () => {
await waitFor(() => expect(onAccountDeleted).toHaveBeenCalled())
})
})

it('should render a configuration modal when harvest.inappconnectors.enabled flag is enabled and allow account creation', async () => {
const { root, addAccount } = setup()
const button = root.getByText('Add an account')
fireEvent.click(button)
expect(addAccount).toHaveBeenCalled()
})
})

0 comments on commit 6be9633

Please sign in to comment.