From 18e009b6b544a3de46038762b79ec8b1d6f2e291 Mon Sep 17 00:00:00 2001 From: Come Grellard Date: Thu, 8 Aug 2024 18:49:01 +0200 Subject: [PATCH] support(llm): added redirection to manage key screen --- .../manageInstances.integration.test.tsx | 29 ++++++++++++++++++- .../ManageInstances/ManageInstancesDrawer.tsx | 6 ++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/apps/ledger-live-mobile/src/newArch/features/WalletSync/__integrations__/manageInstances.integration.test.tsx b/apps/ledger-live-mobile/src/newArch/features/WalletSync/__integrations__/manageInstances.integration.test.tsx index 3db0a22d70ea..7d8d014ae56f 100644 --- a/apps/ledger-live-mobile/src/newArch/features/WalletSync/__integrations__/manageInstances.integration.test.tsx +++ b/apps/ledger-live-mobile/src/newArch/features/WalletSync/__integrations__/manageInstances.integration.test.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { screen } from "@testing-library/react-native"; +import { screen, waitFor } from "@testing-library/react-native"; import { render } from "@tests/test-renderer"; import { WalletSyncSettingsNavigator } from "./shared"; import { State } from "~/reducers/types"; @@ -120,4 +120,31 @@ describe("ManageInstances", () => { const myInstance = screen.getByTestId("walletSync-manage-instance-2"); expect(myInstance).toBeDefined(); }); + it("Should redirect to the Manage Key screen", async () => { + const { user } = render(, { + overrideInitialState: (state: State) => ({ + ...state, + settings: { + ...state.settings, + readOnlyModeEnabled: false, + overriddenFeatureFlags: { llmWalletSync: { enabled: true } }, + }, + trustchain: { + ...state.trustchain, + trustchain, + memberCredentials: { + privatekey: "privatekey", + pubkey: "currentInstance", + }, + }, + }), + }); + + await user.press(await screen.findByText(/ledger sync/i)); + await user.press(await screen.findByText(/Manage now/i)); + await user.press(screen.getAllByText("Remove")[0]); + expect(screen.getByText(/You can’t remove the current instance/i)).toBeDefined(); + await user.press(await screen.findByText(/Delete my encryption key/i)); + await waitFor(() => screen.findByText(/Manage your key/i)); + }); }); diff --git a/apps/ledger-live-mobile/src/newArch/features/WalletSync/screens/ManageInstances/ManageInstancesDrawer.tsx b/apps/ledger-live-mobile/src/newArch/features/WalletSync/screens/ManageInstances/ManageInstancesDrawer.tsx index 0f175ce57ee1..f0a56a925c3e 100644 --- a/apps/ledger-live-mobile/src/newArch/features/WalletSync/screens/ManageInstances/ManageInstancesDrawer.tsx +++ b/apps/ledger-live-mobile/src/newArch/features/WalletSync/screens/ManageInstances/ManageInstancesDrawer.tsx @@ -12,8 +12,8 @@ import { useManageKeyDrawer } from "../ManageKey/useManageKeyDrawer"; import { AnalyticsButton, AnalyticsPage, - useWalletSyncAnalytics, -} from "../../hooks/useWalletSyncAnalytics"; + useLedgerSyncAnalytics, +} from "../../hooks/useLedgerSyncAnalytics"; const ManageInstancesDrawer = ({ isDrawerVisible, @@ -26,7 +26,7 @@ const ManageInstancesDrawer = ({ }: HookResult) => { const { error, isError, isLoading, data } = memberHook; const manageKeyHook = useManageKeyDrawer(); - const { onClickTrack } = useWalletSyncAnalytics(); + const { onClickTrack } = useLedgerSyncAnalytics(); const goToManageBackup = useCallback(() => { handleClose();