Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLM - Wallet Sync Manage Key redirection added #7562

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading