Skip to content

Commit

Permalink
support(llm): added redirection to manage key screen
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrellard-ledger committed Aug 8, 2024
1 parent 760ce85 commit 695a414
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-spies-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

LLM - Added navigation to the manage key screen
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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(<WalletSyncSettingsNavigator />, {
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));
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useCallback } from "react";
import QueuedDrawer from "LLM/components/QueuedDrawer";
import { TrackScreen } from "~/analytics";

Expand All @@ -8,6 +8,12 @@ import { ListInstances } from "../../components/ManageInstances/ListInstances";
import { DeletionError, ErrorReason } from "../../components/ManageInstances/DeletionError";

import { HookResult, Scene } from "./useManageInstanceDrawer";
import { useManageKeyDrawer } from "../ManageKey/useManageKeyDrawer";
import {
AnalyticsButton,
AnalyticsPage,
useLedgerSyncAnalytics,
} from "../../hooks/useLedgerSyncAnalytics";

const ManageInstancesDrawer = ({
isDrawerVisible,
Expand All @@ -19,6 +25,14 @@ const ManageInstancesDrawer = ({
onClickInstance,
}: HookResult) => {
const { error, isError, isLoading, data } = memberHook;
const manageKeyHook = useManageKeyDrawer();
const { onClickTrack } = useLedgerSyncAnalytics();

const goToManageBackup = useCallback(() => {
handleClose();
manageKeyHook.openDrawer();
onClickTrack({ button: AnalyticsButton.ManageKey, page: AnalyticsPage.AutoRemove });
}, [manageKeyHook, onClickTrack, handleClose]);

const getScene = () => {
if (isError) {
Expand Down Expand Up @@ -47,8 +61,7 @@ const ManageInstancesDrawer = ({
return (
<DeletionError
error={ErrorReason.AUTO_REMOVE}
// eslint-disable-next-line no-console
goToDelete={() => console.log("gotoDelete")}
goToDelete={goToManageBackup}
understood={() => changeScene(Scene.List)}
/>
);
Expand Down

0 comments on commit 695a414

Please sign in to comment.