-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7064 from LedgerHQ/feat/LIVE-12195
feat(llm): new add account drawer on assets screen with WS entrypoint
- Loading branch information
Showing
25 changed files
with
599 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"live-mobile": patch | ||
--- | ||
|
||
Create a new drawer component on add account. This new drawer has new UI and an entry point to walletSync. This entrypoint is hidden under a feature flag. Also update translations related to WS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from "react"; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
export class MockedExpoCamera extends React.Component<Props> { | ||
static useCameraPermissions = () => [ | ||
{ canAskAgain: false, expires: "never", granted: true, status: "granted" }, | ||
() => { | ||
return new Promise(resolve => { | ||
resolve(jest.fn()); | ||
}); | ||
}, | ||
() => { | ||
return new Promise(resolve => { | ||
resolve(jest.fn()); | ||
}); | ||
}, | ||
]; | ||
render() { | ||
return <>{this.props.children}</>; | ||
} | ||
} | ||
|
||
export const MockedCameraType = { | ||
back: "back", | ||
front: "front", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export default { | ||
DEVICE_PROXY_URL: null, | ||
MOCK: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
apps/ledger-live-mobile/src/newArch/components/ActionRow/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Flex, Text } from "@ledgerhq/native-ui"; | ||
import React from "react"; | ||
import Touchable from "~/components/Touchable"; | ||
import styled from "styled-components/native"; | ||
|
||
type ActionRowProps = { | ||
title: string; | ||
description?: string; | ||
icon: React.ReactNode; | ||
testID?: string; | ||
onPress?: () => void; | ||
}; | ||
const TouchableCard = styled(Touchable)` | ||
background-color: ${p => p.theme.colors.opacityDefault.c05}; | ||
border-radius: 8px; | ||
padding: 16px; | ||
align-items: center; | ||
gap: 12px; | ||
flex-direction: row; | ||
align-self: stretch; | ||
`; | ||
|
||
const CardTitle = styled(Text)` | ||
font-size: 16px; | ||
color: ${p => p.theme.colors.neutral.c100}; | ||
`; | ||
|
||
const CardDescription = styled(Text)` | ||
font-size: 14px; | ||
color: ${p => p.theme.colors.neutral.c70}; | ||
line-height: 18.2px; | ||
`; | ||
|
||
const ActionRow: React.FC<ActionRowProps> = ({ | ||
title, | ||
description, | ||
icon, | ||
testID, | ||
onPress, | ||
}: ActionRowProps) => { | ||
return ( | ||
<TouchableCard onPress={onPress} testID={testID}> | ||
{icon} | ||
<Flex flexDirection={"column"} rowGap={4} flex={1}> | ||
<CardTitle>{title}</CardTitle> | ||
{description && <CardDescription>{description}</CardDescription>} | ||
</Flex> | ||
</TouchableCard> | ||
); | ||
}; | ||
export default ActionRow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...ive-mobile/src/newArch/features/Accounts/__integrations__/addAccount.integration.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import React from "react"; | ||
import { screen } from "@testing-library/react-native"; | ||
import { render, act } from "@tests/test-renderer"; | ||
import { TestButtonPage } from "./shared"; | ||
import { State } from "~/reducers/types"; | ||
|
||
describe("AddAccount", () => { | ||
/**====== Import with ledger device test =======*/ | ||
it("Should open select add account method drawer with WS feature flag and navigate to import with your Ledger", async () => { | ||
const { user } = render(<TestButtonPage />, { | ||
overrideInitialState: (state: State) => ({ | ||
...state, | ||
settings: { | ||
...state.settings, | ||
readOnlyModeEnabled: false, | ||
overriddenFeatureFlags: { llmWalletSync: { enabled: true } }, | ||
}, | ||
}), | ||
}); | ||
|
||
const addAssetButton = await screen.findByText(/Add asset/i); | ||
|
||
// Check if the add asset button is visible | ||
await expect(addAssetButton).toBeVisible(); | ||
// Open drawer | ||
await act(async () => { | ||
await user.press(addAssetButton); | ||
}); | ||
// Wait for the drawer to open | ||
await expect(await screen.findByText(/add another account/i)); | ||
await expect(await screen.findByText(/add with your ledger/i)); | ||
await expect(await screen.findByText(/import via another ledger live app/i)); | ||
// On press add with another ledger live app | ||
await act(async () => { | ||
await user.press(await screen.getByText(/add with your ledger/i)); | ||
}); | ||
await expect(await screen.findByText(/crypto asset/i)).toBeVisible(); | ||
// On click back | ||
await act(async () => { | ||
await user.press(await screen.findByTestId(/navigation-header-back-button/i)); | ||
}); | ||
await expect(addAssetButton).toBeVisible(); | ||
}); | ||
|
||
/**====== Import with WS test =======*/ | ||
it("Should open select add account method drawer with WS feature flag and navigate to import with wallet sync", async () => { | ||
const { user } = render(<TestButtonPage />, { | ||
overrideInitialState: (state: State) => ({ | ||
...state, | ||
settings: { | ||
...state.settings, | ||
readOnlyModeEnabled: false, | ||
overriddenFeatureFlags: { llmWalletSync: { enabled: true } }, | ||
}, | ||
}), | ||
}); | ||
|
||
const addAssetButton = await screen.findByText(/Add asset/i); | ||
// Check if the add asset button is visible | ||
await expect(addAssetButton).toBeVisible(); | ||
// Open drawer | ||
await act(async () => { | ||
await user.press(addAssetButton); | ||
}); | ||
// Wait for the drawer to open | ||
await expect(await screen.findByText(/add another account/i)); | ||
await expect(await screen.findByText(/add with your ledger/i)); | ||
await expect(await screen.findByText(/import via another ledger live app/i)); | ||
// On press add with wallet sync | ||
await act(async () => { | ||
await user.press(await screen.getByText(/import via another ledger live app/i)); | ||
}); | ||
await expect(await screen.findByText(/dummy drawer/i)).toBeVisible(); | ||
}); | ||
|
||
/**====== Import from desktop Test =======*/ | ||
it("Should open select add account method drawer without WS feature flag and navigate to import from desktop", async () => { | ||
const { user } = render(<TestButtonPage />, { | ||
overrideInitialState: (state: State) => ({ | ||
...state, | ||
settings: { | ||
...state.settings, | ||
readOnlyModeEnabled: false, | ||
overriddenFeatureFlags: { llmWalletSync: { enabled: false } }, | ||
}, | ||
}), | ||
}); | ||
|
||
const addAssetButton = await screen.findByText(/add asset/i); | ||
// Check if the add asset button is visible | ||
await expect(addAssetButton).toBeVisible(); | ||
// Open drawer | ||
await user.press(addAssetButton); | ||
// Wait for the drawer to open | ||
await expect(await screen.findByText(/add another account/i)); | ||
await expect(await screen.findByText(/add with your ledger/i)); | ||
await expect(await screen.findByText(/import from desktop/i)); | ||
// On press add from desktop | ||
await user.press(await screen.getByText(/import from desktop/i)); | ||
await expect( | ||
await screen.findByText(/Scan and import your accounts from Ledger Live desktop/i), | ||
); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
apps/ledger-live-mobile/src/newArch/features/Accounts/__integrations__/shared.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import * as React from "react"; | ||
import { createStackNavigator } from "@react-navigation/stack"; | ||
import { NavigatorName, ScreenName } from "~/const"; | ||
import { Button, IconsLegacy } from "@ledgerhq/native-ui"; | ||
import { useTranslation } from "react-i18next"; | ||
import AddAccountDrawer from "LLM/features/Accounts/screens/AddAccount"; | ||
import { BaseNavigatorStackParamList } from "~/components/RootNavigator/types/BaseNavigator"; | ||
import AddAccountsNavigator from "~/components/RootNavigator/AddAccountsNavigator"; | ||
import ImportAccountsNavigator from "~/components/RootNavigator/ImportAccountsNavigator"; | ||
|
||
const MockComponent = () => { | ||
const { t } = useTranslation(); | ||
const [isAddModalOpened, setAddModalOpened] = React.useState<boolean>(false); | ||
|
||
const openAddModal = () => setAddModalOpened(true); | ||
const closeAddModal = () => setAddModalOpened(false); | ||
const reopenAddModal = () => setAddModalOpened(true); | ||
|
||
return ( | ||
<> | ||
<Button | ||
type="shade" | ||
size="large" | ||
outline | ||
mt={6} | ||
mb={8} | ||
iconPosition="left" | ||
Icon={IconsLegacy.PlusMedium} | ||
onPress={openAddModal} | ||
> | ||
{t("portfolio.emptyState.buttons.import")} | ||
</Button> | ||
<AddAccountDrawer | ||
isOpened={isAddModalOpened} | ||
onClose={closeAddModal} | ||
reopenDrawer={reopenAddModal} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
const Stack = createStackNavigator<BaseNavigatorStackParamList>(); | ||
|
||
export function TestButtonPage() { | ||
return ( | ||
<Stack.Navigator initialRouteName={ScreenName.MockedAddAssetButton}> | ||
<Stack.Screen name={ScreenName.MockedAddAssetButton} component={MockComponent} /> | ||
<Stack.Screen name={NavigatorName.AddAccounts} component={AddAccountsNavigator} /> | ||
<Stack.Screen name={NavigatorName.ImportAccounts} component={ImportAccountsNavigator} /> | ||
</Stack.Navigator> | ||
); | ||
} |
Oops, something went wrong.
93de715
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Evm on Staging 💰 3 miss funds ($0.00) ⏲ 16.3s
Please increase the account target to at least 4 accounts
Please increase the account target to at least 4 accounts
Details of the 0 mutations
Spec Ethereum (failed)
Spec Ethereum Sepolia (10)
Spec Ethereum Holesky (failed)
Details of the 9 uncovered mutations
Spec Ethereum (3)
Spec Ethereum Sepolia (3)
Spec Ethereum Holesky (3)
Portfolio ($0.00) – Details of the 3 currencies
0x8a6Af0dD602db0A78EaD07cE9e2595815383FD5D
0x8a6Af0dD602db0A78EaD07cE9e2595815383FD5D
0x8a6Af0dD602db0A78EaD07cE9e2595815383FD5D
Performance ⏲ 16.3s
Time spent for each spec: (total across mutations)
93de715
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Bot] Bitcoin on Staging ✅ 26 txs 💰 5 miss funds ($53.22) ⏲ 3min 50s
6 critical spec errors
Spec Bitcoin failed!
Spec Peercoin failed!
Spec PivX failed!
Spec Vertcoin failed!
Spec Viacoin failed!
Spec Horizen failed!
Please increase the account target to at least 6 accounts
Please increase the account target to at least 6 accounts
Please increase the account target to at least 6 accounts
Details of the 26 mutations
Spec Bitcoin (failed)
Spec Bitcoin Testnet (11)
Spec Bitcoin Cash (7)
Spec Bitcoin Gold (6)
Spec Dash (7)
Spec Digibyte (9)
Spec DogeCoin (7)
Spec Komodo (5)
Spec Litecoin (9)
Spec Peercoin (failed)
Spec PivX (failed)
Spec Qtum (6)
Spec Vertcoin (failed)
Spec Viacoin (failed)
Spec ZCash (5)
Spec Horizen (failed)
Spec Decred (failed)
Details of the 59 uncovered mutations
Spec Bitcoin (5)
Spec Bitcoin Testnet (5)
Spec Bitcoin Cash (5)
Spec Bitcoin Gold (2)
Spec Komodo (1)
Spec Litecoin (1)
Spec Peercoin (5)
Spec PivX (5)
Spec Qtum (5)
Spec Vertcoin (5)
Spec Viacoin (5)
Spec ZCash (5)
Spec Horizen (5)
Spec Decred (5)
Portfolio ($53.22) – Details of the 17 currencies
tb1qufuqle89w3z4mvzrht4wf7a8ppl3tzuaxp722u
bitcoincash:qzn85g7msq5rj2eu73dqhkez4dmwn2q6vuhpm8pdx2
AVVV2BoNVC5PNfKDrX2V4re2sWJ3h17jPU
XiqBdf7AfWM23CY4U5k8e2oug7jW2MbLZs
dgb1q3z083k6qev6fl9kt0pwmvh3aljz7phwqnzmpgl
DL2iUcwqrKJ8UaNybPuJa8uaX4ujiEcB4Z
REXP7WTd9qsmRG7ebAJoXGJdUexBNxivmx
ltc1quml8nt8srfnal9k8y63a4rrdqfng6ww6fwnd9k
MVYo3tWmufMkw8y12XoyFbx4dSyKYt5p94
t1W1vCEVTr16Tw1J6qV9M89dUbrfRsNUwAH
DshyFLDNm9kX5EL6DtkATQieLH2ZCL72UUj
Performance ⏲ 3min 50s
Time spent for each spec: (total across mutations)