Skip to content

Commit

Permalink
feat(ui): remove add connection modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Vu Van Duc authored and Vu Van Duc committed May 9, 2024
1 parent 1a23141 commit a6adc85
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 470 deletions.
150 changes: 0 additions & 150 deletions src/ui/pages/Menu/components/ConnectWallet/ConnectWallet.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,6 @@ describe("Wallet connect: empty history", () => {
expect(
getByText(EN_TRANSLATIONS.connectwallet.sections.connectbtn)
).toBeVisible();
act(() => {
fireEvent.click(
getByText(EN_TRANSLATIONS.connectwallet.sections.connectbtn)
);
});

await waitFor(() => {
expect(
getByText(EN_TRANSLATIONS.connectwallet.connectwalletmodal.header)
).toBeVisible();
});
});

test("Connect wallet modal: scan QR", async () => {
Expand Down Expand Up @@ -158,97 +147,13 @@ describe("Wallet connect: empty history", () => {
);
});

await waitFor(() => {
expect(
getByText(EN_TRANSLATIONS.connectwallet.connectwalletmodal.header)
).toBeVisible();
});

act(() => {
fireEvent.click(getByTestId("scanqr-btn"));
});

await waitFor(() => {
expect(dispatchMock).toBeCalledWith(
setCurrentOperation(OperationType.SCAN_WALLET_CONNECTION)
);
});
});

test("Connect wallet modal: paste Pid", async () => {
const initialState = {
stateCache: {
routes: [TabsRoutePath.IDENTIFIERS],
authentication: {
loggedIn: true,
time: Date.now(),
passcodeIsSet: true,
passwordIsSet: true,
},
},
walletConnectionsCache: {
walletConnections: [],
},
identifiersCache: {
identifiers: [...identifierFix],
},
};

const storeMocked = {
...mockStore(initialState),
dispatch: dispatchMock,
};

const { getByText, getByTestId, getAllByTestId } = render(
<MemoryRouter>
<Provider store={storeMocked}>
<ConnectWallet />
</Provider>
</MemoryRouter>
);

expect(
getByText(EN_TRANSLATIONS.connectwallet.sections.connectbtn)
).toBeVisible();

act(() => {
fireEvent.click(
getByText(EN_TRANSLATIONS.connectwallet.sections.connectbtn)
);
});

await waitFor(() => {
expect(
getByText(EN_TRANSLATIONS.connectwallet.connectwalletmodal.header)
).toBeVisible();
});

act(() => {
fireEvent.click(
getByText(EN_TRANSLATIONS.connectwallet.connectwalletmodal.pastePID)
);
});

await waitFor(() => {
expect(
getByText(EN_TRANSLATIONS.connectwallet.inputpidmodal.header)
).toBeVisible();
});

act(() => {
fireEvent.change(getByTestId("input-pid"), {
target: { value: "11111" },
});
fireEvent.click(getAllByTestId("action-button")[1]);
});

await waitFor(() => {
expect(dispatchMock).toBeCalledWith(
setToastMsg(ToastMsgType.PEER_ID_SUCCESS)
);
});
});

test("Connect wallet modal: alert identifier missing when create new connect", async () => {
const initialState = {
stateCache: {
Expand Down Expand Up @@ -291,18 +196,6 @@ describe("Wallet connect: empty history", () => {
);
});

await waitFor(() => {
expect(
getByText(EN_TRANSLATIONS.connectwallet.connectwalletmodal.header)
).toBeVisible();
});

act(() => {
fireEvent.click(
getByText(EN_TRANSLATIONS.connectwallet.connectwalletmodal.pastePID)
);
});

await waitFor(() => {
expect(
getByText(
Expand All @@ -311,49 +204,6 @@ describe("Wallet connect: empty history", () => {
)
).toBeVisible();
});

act(() => {
fireEvent.click(
getByText(
EN_TRANSLATIONS.connectwallet.connectionhistory.missingidentifieralert
.confirm
)
);
});

await waitFor(() => {
expect(dispatchMock).toBeCalledWith(
setCurrentOperation(OperationType.CREATE_IDENTIFIER_CONNECT_WALLET)
);
});

act(() => {
fireEvent.click(getByTestId("scanqr-btn"));
});

await waitFor(() => {
expect(
getByText(
EN_TRANSLATIONS.connectwallet.connectionhistory.missingidentifieralert
.message
)
).toBeVisible();
});

act(() => {
fireEvent.click(
getByText(
EN_TRANSLATIONS.connectwallet.connectionhistory.missingidentifieralert
.confirm
)
);
});

await waitFor(() => {
expect(dispatchMock).toBeCalledWith(
setCurrentOperation(OperationType.CREATE_IDENTIFIER_CONNECT_WALLET)
);
});
});
});

Expand Down
16 changes: 2 additions & 14 deletions src/ui/pages/Menu/components/ConnectWallet/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import { i18n } from "../../../../../i18n";
import { CardsPlaceholder } from "../../../../components/CardsPlaceholder";
import "./ConnectWallet.scss";
import { ConnectWalletActions } from "../ConnectWalletActions";
import {
ActionInfo,
ActionType,
Expand Down Expand Up @@ -56,7 +55,6 @@ const ConnectWallet = forwardRef<ConnectWalletOptionRef, object>(
type: ActionType.None,
});

const [openConnectWallet, setOpenConnectWallet] = useState(false);
const [openDeleteAlert, setOpenDeleteAlert] = useState<boolean>(false);
const [openConfirmConnectModal, setOpenConfirmConnectModal] =
useState<boolean>(false);
Expand All @@ -83,13 +81,9 @@ const ConnectWallet = forwardRef<ConnectWalletOptionRef, object>(
}, [currentOperation]);

useImperativeHandle(ref, () => ({
openConnectWallet: handleAddConnect,
openConnectWallet: handleScanQR,
}));

const handleAddConnect = () => {
setOpenConnectWallet(true);
};

const handleOpenVerify = () => {
if (
!stateCache?.authentication.passwordIsSkipped &&
Expand Down Expand Up @@ -268,18 +262,12 @@ const ConnectWallet = forwardRef<ConnectWalletOptionRef, object>(
<div className="placeholder-container">
<CardsPlaceholder
buttonLabel={i18n.t("connectwallet.sections.connectbtn")}
buttonAction={handleAddConnect}
buttonAction={handleScanQR}
testId={pageId}
/>
</div>
)}
</div>
<ConnectWalletActions
openModal={openConnectWallet}
closeModal={() => setOpenConnectWallet(false)}
onInputPid={handleOpenInputPid}
onQRScan={handleScanQR}
/>
<ConfirmConnectModal
isConnectModal={actionInfo.current.data?.id !== connectedWallet?.id}
openModal={openConfirmConnectModal}
Expand Down

0 comments on commit a6adc85

Please sign in to comment.