From a5181a7fbfe225c25be4b21a8f7c1fb9ffbe69ca Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Wed, 20 Dec 2023 13:39:37 +0200 Subject: [PATCH] chore: remove topup tip (#2950) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: remove topup tip * fix: test --------- Co-authored-by: Renรฉ Aaron --- src/app/components/Tips/index.test.tsx | 1 - src/app/components/Tips/index.tsx | 9 ---- src/app/hooks/useTips.test.ts | 65 -------------------------- src/app/hooks/useTips.ts | 25 ++-------- src/common/constants.ts | 1 - 5 files changed, 3 insertions(+), 98 deletions(-) delete mode 100644 src/app/hooks/useTips.test.ts diff --git a/src/app/components/Tips/index.test.tsx b/src/app/components/Tips/index.test.tsx index db9735d12e..7c3ad24e94 100644 --- a/src/app/components/Tips/index.test.tsx +++ b/src/app/components/Tips/index.test.tsx @@ -21,7 +21,6 @@ describe("Tips", () => { ); - expect(await screen.findByText("Buy Bitcoin")).toBeInTheDocument(); expect(await screen.findByText("Alby Demo")).toBeInTheDocument(); expect(await screen.findByText("Nostr")).toBeInTheDocument(); }); diff --git a/src/app/components/Tips/index.tsx b/src/app/components/Tips/index.tsx index cc45b50c7c..7c4dc70727 100644 --- a/src/app/components/Tips/index.tsx +++ b/src/app/components/Tips/index.tsx @@ -5,7 +5,6 @@ import { Link } from "react-router-dom"; import TipCard from "~/app/components/TipCard"; import { useAccount } from "~/app/context/AccountContext"; import { useTips } from "~/app/hooks/useTips"; -import BuyBitcoinTipCardIcon from "~/app/icons/BuyBitcoinTipCardIcon"; import DemoTipCardIcon from "~/app/icons/DemoTipCardIcon"; import MnemonicTipCardIcon from "~/app/icons/MnemonicTipCardIcon"; import { classNames } from "~/app/utils"; @@ -21,14 +20,6 @@ export default function Tips() { const tipCardConfigs = useMemo( () => ({ - [TIPS.TOP_UP_WALLET]: { - background: - "bg-white dark:bg-surface-02dp hover:bg-orange-50 dark:hover:bg-orange-900", - border: "border-orange-500", - arrow: "text-orange-500", - backgroundIcon: , - link: "https://getalby.com/topup", - }, [TIPS.DEMO]: { background: "bg-white dark:bg-surface-02dp hover:bg-yellow-50 dark:hover:bg-yellow-900", diff --git a/src/app/hooks/useTips.test.ts b/src/app/hooks/useTips.test.ts deleted file mode 100644 index 1b4fb2c623..0000000000 --- a/src/app/hooks/useTips.test.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { settingsFixture as mockSettings } from "~/../tests/fixtures/settings"; -import { useTips } from "~/app/hooks/useTips"; -import { TIPS } from "~/common/constants"; - -jest.mock("~/app/context/SettingsContext", () => ({ - useSettings: () => ({ - settings: mockSettings, - isLoading: false, - updateSetting: jest.fn(), - getFormattedFiat: jest.fn(), - getFormattedNumber: jest.fn(), - getFormattedSats: jest.fn(), - }), -})); - -let tmpAccount = { id: "1", name: "LND account", connectorType: "", alias: "" }; - -jest.mock("~/app/context/AccountContext", () => ({ - useAccount: () => ({ - account: tmpAccount, - loading: false, - unlock: jest.fn(), - lock: jest.fn(), - setAccountId: jest.fn(), - fetchAccountInfo: jest.fn(), - balancesDecorated: { - fiatBalance: "", - satsBalance: "", - }, - }), -})); - -describe("useTips", () => { - test("should not have top up wallet tip when using a non-alby account", async () => { - tmpAccount = { id: "1", name: "LND account", connectorType: "", alias: "" }; - const { tips } = useTips(); - expect(tips.length).toBe(1); // mnemonic - const hasTopUpWallet = tips.some((tip) => tip === TIPS.TOP_UP_WALLET); - expect(hasTopUpWallet).toBe(false); - }); - test("should have top up wallet tip when having alby oauth account", async () => { - tmpAccount = { - id: "2", - name: "Alby", - connectorType: "alby", - alias: "๐Ÿ getalby.com", - }; - const { tips } = useTips(); - expect(tips.length).toBe(2); // mnemonic + top up - const hasTopUpWallet = tips.some((tip) => tip === TIPS.TOP_UP_WALLET); - expect(hasTopUpWallet).toBe(true); - }); - test("should have top up wallet tip when having legacy lndhub alby account", async () => { - tmpAccount = { - id: "2", - name: "Alby", - alias: "๐Ÿ getalby.com", - connectorType: "lndhub", - }; - const { tips } = useTips(); - expect(tips.length).toBe(2); // mnemonic + top up - const hasTopUpWallet = tips.some((tip) => tip === TIPS.TOP_UP_WALLET); - expect(hasTopUpWallet).toBe(true); - }); -}); diff --git a/src/app/hooks/useTips.ts b/src/app/hooks/useTips.ts index e3c5e2a2a7..96f33c38e2 100644 --- a/src/app/hooks/useTips.ts +++ b/src/app/hooks/useTips.ts @@ -1,38 +1,19 @@ -import { useAccount } from "~/app/context/AccountContext"; import { useSettings } from "~/app/context/SettingsContext"; -import { isAlbyLNDHubAccount, isAlbyOAuthAccount } from "~/app/utils"; import { TIPS } from "~/common/constants"; -const DEFAULT_TIPS = [TIPS.TOP_UP_WALLET, TIPS.MNEMONIC]; +const DEFAULT_TIPS = [TIPS.MNEMONIC]; -export const filterTips = ( - closedTips: TIPS[], - isAlbyOAuthAccount: boolean, - isAlbyLNDHubAccount: boolean -) => { +export const filterTips = (closedTips: TIPS[]) => { return DEFAULT_TIPS.filter((tip: TIPS) => { if (closedTips.includes(tip)) return false; - if ( - tip === TIPS.TOP_UP_WALLET && - !isAlbyOAuthAccount && - !isAlbyLNDHubAccount - ) - return false; - return true; }); }; export const useTips = () => { const { settings, updateSetting } = useSettings(); - const { account } = useAccount(); - - const tips = filterTips( - settings.closedTips, - isAlbyOAuthAccount(account?.connectorType), - isAlbyLNDHubAccount(account?.alias, account?.connectorType) - ); + const tips = filterTips(settings.closedTips); const closeTip = (tip: TIPS) => { updateSetting({ diff --git a/src/common/constants.ts b/src/common/constants.ts index dc72e04f4a..ae48b747ba 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -164,7 +164,6 @@ export enum CURRENCIES { } export enum TIPS { - TOP_UP_WALLET = "top_up_wallet", DEMO = "demo", MNEMONIC = "mnemonic", }