Skip to content

Commit

Permalink
[SDK] React test coverage (#5825)
Browse files Browse the repository at this point in the history
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on significant updates to wallet support, increasing the number of supported wallets from 350+ to 500+. It also includes various code deletions, modifications, and new features across multiple components and files.

### Detailed summary
- Increased wallet support from 350+ to 500+ across various components.
- Updated `version` in `package.json` files.
- Modified `ChainIcon` component to use a fallback icon.
- Added `ModalPreview` for connect modal examples.
- Updated descriptions in documentation and UI elements.
- Refactored several components for better code clarity and functionality.
- Deleted multiple unused assets and components.

> The following files were skipped due to too many changes: `apps/dashboard/src/components/icons/ChainIcon.tsx`, `packages/thirdweb/src/react/core/utils/structuralSharing.test.ts`, `packages/thirdweb/src/contract/deployment/utils/bootstrap.ts`, `packages/thirdweb/src/react/web/utils/resolveMimeType.test.ts`, `apps/portal/src/app/connect/wallet/sign-in-methods/external-wallets/page.mdx`, `apps/dashboard/src/hooks/useCsvUpload.ts`, `apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx`, `packages/thirdweb/src/react/web/ui/MediaRenderer/mime/mime.test.ts`, `apps/portal/src/app/connect/account-abstraction/erc-20-paymaster/page.mdx`, `apps/dashboard/src/app/(dashboard)/(chain)/components/server/chain-icon.tsx`, `packages/thirdweb/src/contract/deployment/utils/create-2-factory.ts`, `packages/thirdweb/src/react/web/ui/MediaRenderer/icons.test.tsx`, `packages/thirdweb/src/react/web/ui/hooks/useShowMore.test.tsx`, `packages/thirdweb/src/react/web/ui/hooks/useDebouncedValue.test.tsx`, `apps/portal/src/app/connect/page.mdx`, `apps/portal/src/app/connect/wallet/sign-in-methods/configure/page.mdx`, `packages/thirdweb/src/react/core/utils/walletIcon.ts`, `apps/portal/src/app/typescript/v5/adapters/page.mdx`, `apps/portal/src/app/connect/wallet/get-started/page.mdx`, `apps/portal/src/app/react/v5/adapters/page.mdx`, `packages/thirdweb/src/react/web/ui/MediaRenderer/MediaRenderer.test.tsx`, `apps/portal/src/app/nebula/api-reference/page.mdx`, `packages/thirdweb/src/react/core/utils/walletIcon.test.ts`, `apps/dashboard/src/app/team/[team_slug]/[project_slug]/insight/[blueprint_slug]/blueprint-playground.stories.tsx`, `apps/dashboard/src/app/team/[team_slug]/[project_slug]/insight/[blueprint_slug]/blueprint-playground.client.tsx`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/snapshot-upload.tsx`, `pnpm-lock.yaml`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
kien-ngo committed Dec 21, 2024
1 parent 3718020 commit 1b103d7
Show file tree
Hide file tree
Showing 21 changed files with 1,118 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { describe, expect, it } from "vitest";
import { renderHook } from "~test/react-render.js";
import { useConnectionManager } from "./connection-manager.js";

describe("useConnectionManager", () => {
it("throws an error when used outside of ThirdwebProvider", () => {
expect(() => {
renderHook(() => useConnectionManager());
}).toThrow("useConnectionManager must be used within <ThirdwebProvider>");
});
});
19 changes: 19 additions & 0 deletions packages/thirdweb/src/react/core/utils/isSmartWallet.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, it } from "vitest";
import { ANVIL_CHAIN } from "~test/chains.js";
import { createWallet } from "../../../wallets/create-wallet.js";
import { hasSmartAccount } from "./isSmartWallet.js";

describe("isSmartWallet", () => {
it("should work if id is inApp and has smartAccount in wallet config", () => {
const wallet = createWallet("inApp", {
smartAccount: {
chain: ANVIL_CHAIN,
sponsorGas: true,
overrides: {
bundlerUrl: "your-bundler-url",
},
},
});
expect(hasSmartAccount(wallet)).toBe(true);
});
});
57 changes: 57 additions & 0 deletions packages/thirdweb/src/react/core/utils/storage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { AsyncStorage } from "../../../utils/storage/AsyncStorage.js";
import type { AuthArgsType } from "../../../wallets/in-app/core/authentication/types.js";
import {
LAST_AUTH_PROVIDER_STORAGE_KEY,
getLastAuthProvider,
setLastAuthProvider,
} from "./storage.js";

describe("Auth Provider Storage", () => {
let mockStorage: AsyncStorage;

beforeEach(() => {
mockStorage = {
getItem: vi.fn(),
setItem: vi.fn(),
removeItem: vi.fn(),
};
});

describe("setLastAuthProvider", () => {
it("should store the auth provider in storage", async () => {
const authProvider: AuthArgsType["strategy"] = "email";
await setLastAuthProvider(authProvider, mockStorage);

expect(mockStorage.setItem).toHaveBeenCalledWith(
LAST_AUTH_PROVIDER_STORAGE_KEY,
authProvider,
);
});
});

describe("getLastAuthProvider", () => {
it("should retrieve the last auth provider from storage", async () => {
const mockAuthProvider: AuthArgsType["strategy"] = "google";
vi.mocked(mockStorage.getItem).mockResolvedValue(mockAuthProvider);

const result = await getLastAuthProvider(mockStorage);

expect(mockStorage.getItem).toHaveBeenCalledWith(
LAST_AUTH_PROVIDER_STORAGE_KEY,
);
expect(result).toBe(mockAuthProvider);
});

it("should return null if no auth provider is stored", async () => {
vi.mocked(mockStorage.getItem).mockResolvedValue(null);

const result = await getLastAuthProvider(mockStorage);

expect(mockStorage.getItem).toHaveBeenCalledWith(
LAST_AUTH_PROVIDER_STORAGE_KEY,
);
expect(result).toBeNull();
});
});
});
55 changes: 55 additions & 0 deletions packages/thirdweb/src/react/core/utils/structuralSharing.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { describe, expect, it } from "vitest";
import { structuralSharing } from "./structuralSharing.js";

describe("structuralSharing", () => {
it("should return the old data if it is deeply equal to the new data", () => {
const oldData = { a: 1, b: { c: 2 } };
const newData = { a: 1, b: { c: 2 } };
const result = structuralSharing(oldData, newData);
expect(result).toBe(oldData);
});

it("should return a new object with shared structure for equal parts", () => {
const oldData = { a: 1, b: { c: 2 }, d: 3 };
const newData = { a: 1, b: { c: 2 }, d: 4 };
const result = structuralSharing(oldData, newData);
expect(result).not.toBe(oldData);
expect(result).not.toBe(newData);
expect(result.a).toBe(oldData.a);
expect(result.b).toBe(oldData.b);
expect(result.d).toBe(newData.d);
});

it("should handle arrays correctly", () => {
const oldData = [1, 2, [3, 4]];
const newData = [1, 2, [3, 5]];
const result = structuralSharing(oldData, newData);
expect(result).not.toBe(oldData);
expect(result).not.toBe(newData);
expect(result[0]).toBe(oldData[0]);
expect(result[1]).toBe(oldData[1]);
expect(result[2]).not.toBe(oldData[2]);
});

it("should handle undefined oldData", () => {
const oldData = undefined;
const newData = { a: 1 };
const result = structuralSharing(oldData, newData);
expect(result).toBe(newData);
});

it("should handle NaN values correctly", () => {
const oldData = { a: Number.NaN };
const newData = { a: Number.NaN };
const result = structuralSharing(oldData, newData);
expect(result).toBe(oldData);
});

it("should handle objects with different constructors", () => {
class CustomClass {}
const oldData = new CustomClass();
const newData = { a: 1 };
const result = structuralSharing(oldData, newData);
expect(result).toBe(newData);
});
});
81 changes: 81 additions & 0 deletions packages/thirdweb/src/react/core/utils/walletIcon.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { describe, expect, it } from "vitest";
import { genericWalletIcon, getSocialIcon, socialIcons } from "./walletIcon.js";

const emailIcon =
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEzLjMzMzUgMi42NjY1SDIuNjY2ODNDMS45MzA0NSAyLjY2NjUgMS4zMzM1IDMuMjYzNDYgMS4zMzM1IDMuOTk5ODRWMTEuOTk5OEMxLjMzMzUgMTIuNzM2MiAxLjkzMDQ1IDEzLjMzMzIgMi42NjY4MyAxMy4zMzMySDEzLjMzMzVDMTQuMDY5OSAxMy4zMzMyIDE0LjY2NjggMTIuNzM2MiAxNC42NjY4IDExLjk5OThWMy45OTk4NEMxNC42NjY4IDMuMjYz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yNjggNi4wNjcwOSAxMy43ODY4IDYuMTQ3MDkgMTMuMzMzNSIgc3Ryb2tlPSIjMzM4NUZGIiBzdHJva2Utd2lkdGg9IjEuMjU0OSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+CjxwYXRoIGQ9Ik02IDQuNTMzNDZDNi42MDgyNyA0LjE4MjI4IDcuMjk4MjggMy45OTc0NSA4LjAwMDY0IDMuOTk3NTZDOC43MDMwMSAzLjk5NzY3IDkuMzkyOTYgNC4xODI3MiAxMC4wMDExIDQuNTM0MUMxMC42MDkzIDQuODg1NDggMTEuMTE0MiA1LjM5MDc5IDExLjQ2NTEgNS45OTkyM0MxMS44MTYgNi42MDc2NiAxMi4wMDA1IDcuMjk3NzYgMTIgOC4wMDAxMlY5LjMzMzQ2IiBzdHJva2U9IiMzMzg1RkYiIHN0cm9rZS13aWR0aD0iMS4yNTQ5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF81NjM5XzMyIj4KPHJlY3Qgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJ3aGl0ZSIvPgo8L2NsaXBQYXRoPgo8L2RlZnM+Cjwvc3ZnPgo=";

describe("walletIcon", () => {
it("should return google icon", () => {
expect(getSocialIcon("google")).toBe(socialIcons.google);
});

it("should return coinbase icon", () => {
expect(getSocialIcon("coinbase")).toBe(socialIcons.coinbase);
});

it("should return apple icon", () => {
expect(getSocialIcon("apple")).toBe(socialIcons.apple);
});

it("should return facebook icon", () => {
expect(getSocialIcon("facebook")).toBe(socialIcons.facebook);
});

it("should return phone icon", () => {
expect(getSocialIcon("phone")).toBe(phoneIcon);
});

it("should return email icon", () => {
expect(getSocialIcon("email")).toBe(emailIcon);
});

it("should return passkey icon", () => {
expect(getSocialIcon("passkey")).toBe(passkeyIcon);
});

it("should return discord icon", () => {
expect(getSocialIcon("discord")).toBe(socialIcons.discord);
});

it("should return line icon", () => {
expect(getSocialIcon("line")).toBe(socialIcons.line);
});

it("should return x icon", () => {
expect(getSocialIcon("x")).toBe(socialIcons.x);
});

it("should return farcaster icon", () => {
expect(getSocialIcon("farcaster")).toBe(socialIcons.farcaster);
});

it("should return telegram icon", () => {
expect(getSocialIcon("telegram")).toBe(socialIcons.telegram);
});

it("should return twitch icon", () => {
expect(getSocialIcon("twitch")).toBe(socialIcons.twitch);
});

it("should return github icon", () => {
expect(getSocialIcon("github")).toBe(socialIcons.github);
});

it("should return steam icon", () => {
expect(getSocialIcon("steam")).toBe(socialIcons.steam);
});

it("should return guest icon", () => {
expect(getSocialIcon("guest")).toBe(guestIcon);
});

it("should return generic wallet icon for unknown provider", () => {
expect(getSocialIcon("unknown")).toBe(genericWalletIcon);
});
});
3 changes: 3 additions & 0 deletions packages/thirdweb/src/react/core/utils/walletIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const genericWalletIcon =
const passkeyIcon =
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzU2MzlfMzIpIj4KPHBhdGggZD0iTTcuOTk5NTkgNi42NjY1QzcuNjQ1OTYgNi42NjY1IDcuMzA2ODMgNi44MDY5OCA3LjA1Njc4IDcuMDU3MDNDNi44MDY3MyA3LjMwNzA4IDYuNjY2MjUgNy42NDYyMiA2LjY2NjI1IDcuOTk5ODRDNi42NjYyNSA4LjY3OTg0IDYuNTk5NTkgOS42NzMxNyA2LjQ5MjkyIDEwLjY2NjUiIHN0cm9rZT0iIzMzODVGRiIgc3Ryb2tlLXdpZHRoPSIxLjI1NDkiIHN0cm9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cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF81NjM5XzMyIj4KPHJlY3Qgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJ3aGl0ZSIvPgo8L2NsaXBQYXRoPgo8L2RlZnM+Cjwvc3ZnPgo=";

/**
* @internal
*/
export const socialIcons = {
google: googleIconUri,
apple: appleIconUri,
Expand Down
Loading

0 comments on commit 1b103d7

Please sign in to comment.