From 77c13b4d992b03d025d6eb240fbef56789fa7b75 Mon Sep 17 00:00:00 2001 From: Na'aman Hirschfeld Date: Mon, 22 Jan 2024 09:41:38 +0100 Subject: [PATCH] chore: fix docs link --- .pre-commit-config.yaml | 2 +- frontend/package.json | 2 +- frontend/src/app/[locale]/sign-in/page.tsx | 1 + .../src/components/static-site/footer.tsx | 4 +- .../src/components/static-site/header.tsx | 4 +- .../static-site/nav-auction-icons.spec.tsx | 42 ------------- .../components/static-site/nav-icons.spec.tsx | 37 +++++++++++ .../{nav-auction-icons.tsx => nav-icons.tsx} | 18 +++--- go.mod | 13 ++-- go.sum | 26 ++++---- go.work.sum | 5 +- pnpm-lock.yaml | 61 ++++++------------- 12 files changed, 97 insertions(+), 118 deletions(-) delete mode 100644 frontend/src/components/static-site/nav-auction-icons.spec.tsx create mode 100644 frontend/src/components/static-site/nav-icons.spec.tsx rename frontend/src/components/static-site/{nav-auction-icons.tsx => nav-icons.tsx} (79%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d46dc546..d0e8ab43 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,7 +41,7 @@ repos: args: ['--timeout', '3m0s'] exclude: 'gen/go' - repo: https://github.com/segmentio/golines - rev: 'v0.11.0' + rev: 'v0.12.1' hooks: - id: golines - repo: https://github.com/bufbuild/buf diff --git a/frontend/package.json b/frontend/package.json index 1cdfd6b0..f89a6aaf 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -49,7 +49,7 @@ "@vitejs/plugin-react": "^4.2.1", "autoprefixer": "^10.4.17", "daisyui": "^4.6.0", - "jsdom": "^23.2.0", + "jsdom": "^24.0.0", "mock-socket": "^9.3.1", "postcss": "8.4.33", "sass": "^1.70.0", diff --git a/frontend/src/app/[locale]/sign-in/page.tsx b/frontend/src/app/[locale]/sign-in/page.tsx index 4dfcad5f..d5dd93f7 100644 --- a/frontend/src/app/[locale]/sign-in/page.tsx +++ b/frontend/src/app/[locale]/sign-in/page.tsx @@ -15,6 +15,7 @@ export default function SignIn() { const user = useUser(); const router = useRouter(); const { initialized, page, identify } = useAnalytics(); + const [isLoading, setIsLoading] = useState(false); useEffect(() => { diff --git a/frontend/src/components/static-site/footer.tsx b/frontend/src/components/static-site/footer.tsx index e6f95366..13003786 100644 --- a/frontend/src/components/static-site/footer.tsx +++ b/frontend/src/components/static-site/footer.tsx @@ -4,7 +4,7 @@ import Link from 'next/link'; import { useTranslations } from 'next-intl'; import { Logo } from '@/components/logo'; -import { NavAuctionIcons } from '@/components/static-site/nav-auction-icons'; +import { NavIcons } from '@/components/static-site/nav-icons'; import { Navigation } from '@/constants'; export const FooterLinks = [ @@ -39,7 +39,7 @@ export function Footer() { ))} - + ); } diff --git a/frontend/src/components/static-site/header.tsx b/frontend/src/components/static-site/header.tsx index 17b5f211..3cbdd841 100644 --- a/frontend/src/components/static-site/header.tsx +++ b/frontend/src/components/static-site/header.tsx @@ -3,7 +3,7 @@ import { useTranslations } from 'next-intl'; import { ChevronRight } from 'react-bootstrap-icons'; import { Logo } from '@/components/logo'; -import { NavAuctionIcons } from '@/components/static-site/nav-auction-icons'; +import { NavIcons } from '@/components/static-site/nav-icons'; import { Navigation } from '@/constants'; export function StaticPageHeader() { @@ -21,7 +21,7 @@ export function StaticPageHeader() {
- +
diff --git a/frontend/src/components/static-site/nav-auction-icons.spec.tsx b/frontend/src/components/static-site/nav-auction-icons.spec.tsx deleted file mode 100644 index 3f6d96d5..00000000 --- a/frontend/src/components/static-site/nav-auction-icons.spec.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { mockTrack } from 'tests/mocks'; -import { render, screen, waitFor } from 'tests/test-utils'; - -import { - NavAuctionIcons, - NavAuctionIconsList, -} from '@/components/static-site/nav-auction-icons'; - -describe('NavAuctionIcons Tests', () => { - global.open = vi.fn(); - it('should render a list of icons', () => { - render(); - for (const iconData of NavAuctionIconsList) { - const icon = screen.getByTestId(`${iconData.name}-btn`); - expect(icon).toBeInTheDocument(); - } - }); - - it('should call track analytics when an icon is clicked', async () => { - render(); - const icon = screen.getByTestId(`${NavAuctionIconsList[0].name}-btn`); - icon.click(); - await waitFor(() => { - expect(mockTrack).toHaveBeenCalledWith( - `${NavAuctionIconsList[0].name.charAt(0).toUpperCase() + NavAuctionIconsList[0].name.split('-')[0].slice(1)} Clicked`, - expect.any(Object), - expect.any(Object), - ); - }); - }); - - it('should call window open on click', async () => { - render(); - const icon = screen.getByTestId(`${NavAuctionIconsList[0].name}-btn`); - icon.click(); - await waitFor(() => { - expect(window.open).toHaveBeenCalledWith( - NavAuctionIconsList[0].url, - ); - }); - }); -}); diff --git a/frontend/src/components/static-site/nav-icons.spec.tsx b/frontend/src/components/static-site/nav-icons.spec.tsx new file mode 100644 index 00000000..9c1aefc3 --- /dev/null +++ b/frontend/src/components/static-site/nav-icons.spec.tsx @@ -0,0 +1,37 @@ +import { mockTrack } from 'tests/mocks'; +import { render, screen, waitFor } from 'tests/test-utils'; + +import { NavIcons, NavigationTabs } from '@/components/static-site/nav-icons'; + +describe('NavIcons Tests', () => { + global.open = vi.fn(); + it('should render a list of icons', () => { + render(); + for (const iconData of NavigationTabs) { + const icon = screen.getByTestId(`${iconData.name}-btn`); + expect(icon).toBeInTheDocument(); + } + }); + + it('should call track analytics when an icon is clicked', async () => { + render(); + const icon = screen.getByTestId(`${NavigationTabs[0].name}-btn`); + icon.click(); + await waitFor(() => { + expect(mockTrack).toHaveBeenCalledWith( + `${NavigationTabs[0].name.charAt(0).toUpperCase() + NavigationTabs[0].name.split('-')[0].slice(1)} Clicked`, + expect.any(Object), + expect.any(Object), + ); + }); + }); + + it('should call window open on click', async () => { + render(); + const icon = screen.getByTestId(`${NavigationTabs[0].name}-btn`); + icon.click(); + await waitFor(() => { + expect(window.open).toHaveBeenCalledWith(NavigationTabs[0].url); + }); + }); +}); diff --git a/frontend/src/components/static-site/nav-auction-icons.tsx b/frontend/src/components/static-site/nav-icons.tsx similarity index 79% rename from frontend/src/components/static-site/nav-auction-icons.tsx rename to frontend/src/components/static-site/nav-icons.tsx index 0d3c798f..31a3f5ba 100644 --- a/frontend/src/components/static-site/nav-auction-icons.tsx +++ b/frontend/src/components/static-site/nav-icons.tsx @@ -1,13 +1,13 @@ 'use client'; -import { Discord, Github, Telephone } from 'react-bootstrap-icons'; +import { Book, Discord, Github, Telephone } from 'react-bootstrap-icons'; import { ExternalNavigation } from '@/constants'; import { TrackEvents } from '@/constants/analytics'; import { useAnalytics } from '@/hooks/use-analytics'; import { getEnv } from '@/utils/env'; -export const NavAuctionIconsList = [ +export const NavigationTabs = [ { icon: , name: 'discord-button', @@ -18,18 +18,18 @@ export const NavAuctionIconsList = [ name: 'github-button', url: ExternalNavigation.Github, }, - // { - // icon: , - // name: 'docs-button', - // url: ExternalNavigation.Docs, - // }, + { + icon: , + name: 'docs-button', + url: ExternalNavigation.Docs, + }, { icon: , name: 'schedule-meeting-button', url: getEnv().NEXT_PUBLIC_SCHEDULE_MEETING_URL, }, ]; -export function NavAuctionIcons() { +export function NavIcons() { const { initialized, track } = useAnalytics(); function handleIconClick(event: string, url: string) { @@ -41,7 +41,7 @@ export function NavAuctionIcons() { return (