From adaf70d4737b9abaf83f8f3dd16c0cf224309fac Mon Sep 17 00:00:00 2001 From: Leonardo Zizzamia Date: Thu, 15 Aug 2024 15:07:26 -0700 Subject: [PATCH 1/3] fix: default accountChain for Identity component --- src/identity/components/Avatar.test.tsx | 23 ----------------------- src/identity/components/Avatar.tsx | 2 +- src/identity/components/Identity.tsx | 9 +++------ vitest.config.ts | 4 ++-- 4 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/identity/components/Avatar.test.tsx b/src/identity/components/Avatar.test.tsx index 17df296637..8d53570e97 100644 --- a/src/identity/components/Avatar.test.tsx +++ b/src/identity/components/Avatar.test.tsx @@ -69,9 +69,7 @@ describe('Avatar Component', () => { useIdentityContextMock.mockReturnValue({ address: null }); useAvatarMock.mockReturnValue({ data: null, isLoading: true }); useNameMock.mockReturnValue({ data: null, isLoading: true }); - render(); - await waitFor(() => { const svgElement = screen.getByTestId('ockAvatarLoadingSvg'); expect(svgElement).toBeInTheDocument(); @@ -82,9 +80,7 @@ describe('Avatar Component', () => { useIdentityContextMock.mockReturnValue({ address: null }); useAvatarMock.mockReturnValue({ data: null, isLoading: false }); useNameMock.mockReturnValue({ data: null, isLoading: false }); - render(); - await waitFor(() => { const defaultAvatarElement = screen.getByTestId('ockAvatarDefaultSvg'); expect(defaultAvatarElement).toBeInTheDocument(); @@ -101,11 +97,9 @@ describe('Avatar Component', () => { data: 'ens_name', isLoading: false, }); - render( , ); - await waitFor(() => { const imgElement = screen.getByTestId('ockAvatar_Image'); expect(imgElement).toHaveAttribute('src', 'avatar_url'); @@ -119,18 +113,15 @@ describe('Avatar Component', () => { useIdentityContextMock.mockReturnValue({ address: null }); useAvatarMock.mockReturnValue({ data: null, isLoading: true }); useNameMock.mockReturnValue({ data: null, isLoading: true }); - const CustomLoadingComponent = (
Loading...
); - render( , ); - const customLoadingElement = screen.getByTestId('ockAvatarCustomLoading'); expect(customLoadingElement).toBeInTheDocument(); expect(customLoadingElement).toHaveTextContent('Loading...'); @@ -140,18 +131,15 @@ describe('Avatar Component', () => { useIdentityContextMock.mockReturnValue({ address: null }); useAvatarMock.mockReturnValue({ data: null, isLoading: false }); useNameMock.mockReturnValue({ data: null, isLoading: false }); - const CustomDefaultComponent = (
Default Avatar
); - render( , ); - const customDefaultElement = screen.getByTestId('ockAvatarCustomDefault'); expect(customDefaultElement).toBeInTheDocument(); expect(customDefaultElement).toHaveTextContent('Default Avatar'); @@ -172,13 +160,11 @@ describe('Avatar Component', () => { data: 'ens_name', isLoading: false, }); - render( , ); - await waitFor(() => { const inner = screen.getByTestId('ockAvatar_BadgeContainer'); expect(inner).toBeInTheDocument(); @@ -191,9 +177,7 @@ describe('Avatar Component', () => { useIdentityContextMock.mockReturnValue({ address: testIdentityProviderAddress, }); - render(); - expect(useNameMock).toHaveBeenCalledWith({ address: testIdentityProviderAddress, }); @@ -203,9 +187,7 @@ describe('Avatar Component', () => { useIdentityContextMock.mockReturnValue({ address: testIdentityProviderAddress, }); - render(); - expect(useNameMock).toHaveBeenCalledWith({ address: testAvatarComponentAddress, }); @@ -216,9 +198,7 @@ describe('Avatar Component', () => { chain: optimism, address: testIdentityProviderAddress, }); - render(); - expect(useNameMock).toHaveBeenCalledWith({ address: testIdentityProviderAddress, chain: optimism, @@ -230,14 +210,11 @@ describe('Avatar Component', () => { chain: optimism, address: testIdentityProviderAddress, }); - useNameMock.mockReturnValue({ data: 'ens_name', isLoading: false, }); - render(); - expect(useNameMock).toHaveBeenCalledWith({ address: testIdentityProviderAddress, chain: baseSepolia, diff --git a/src/identity/components/Avatar.tsx b/src/identity/components/Avatar.tsx index 555a7ac2c0..68af8ef2ba 100644 --- a/src/identity/components/Avatar.tsx +++ b/src/identity/components/Avatar.tsx @@ -89,7 +89,7 @@ export function Avatar({ )} {badge && ( - +
{ if (!address) { @@ -30,7 +28,6 @@ export function Identity({ } }, [address]); - // istanbul ignore next const onClick = hasCopyAddressOnClick ? handleCopy : undefined; return ( diff --git a/vitest.config.ts b/vitest.config.ts index 838e112fea..bd0212ef7b 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -23,13 +23,13 @@ export default defineConfig({ reportOnFailure: true, thresholds: { statements: 99.58, - branches: 99.25, + branches: 99.35, functions: 97.89, lines: 99.58, }, }, environment: 'jsdom', - exclude: ['**/node_modules/**', 'playground/**', 'site/**'], + exclude: ['**/node_modules/**', 'framegear/**', 'playground/**', 'site/**'], setupFiles: ['./vitest.setup.ts'], globals: true, }, From 794a966fa7efab6c991c76258e45f59a05ce5d36 Mon Sep 17 00:00:00 2001 From: Leonardo Zizzamia Date: Thu, 15 Aug 2024 15:08:51 -0700 Subject: [PATCH 2/3] dope --- .changeset/shaggy-pumpkins-rule.md | 5 +++++ src/version.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/shaggy-pumpkins-rule.md diff --git a/.changeset/shaggy-pumpkins-rule.md b/.changeset/shaggy-pumpkins-rule.md new file mode 100644 index 0000000000..01788b0283 --- /dev/null +++ b/.changeset/shaggy-pumpkins-rule.md @@ -0,0 +1,5 @@ +--- +"@coinbase/onchainkit": patch +--- + +- **fix**: default accountChain for `Identity` component. By @zizzamia #1071 diff --git a/src/version.ts b/src/version.ts index b1d8e39bb2..9f30f583ee 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const version = '0.29.0'; +export const version = '0.29.1'; From 8af32c397fd82c784eeccdc0a3b55767eca4775e Mon Sep 17 00:00:00 2001 From: Leonardo Zizzamia Date: Thu, 15 Aug 2024 15:11:56 -0700 Subject: [PATCH 3/3] ok --- playground/nextjs-app-router/next.config.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/playground/nextjs-app-router/next.config.mjs b/playground/nextjs-app-router/next.config.mjs index c0340b428b..6cf837e0a9 100644 --- a/playground/nextjs-app-router/next.config.mjs +++ b/playground/nextjs-app-router/next.config.mjs @@ -1,5 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + basePath: '/playground', typescript: { ignoreBuildErrors: true, }