diff --git a/frontend/__tests__/unit/components/ModeToggle.test.tsx b/frontend/__tests__/unit/components/ModeToggle.test.tsx index 6156d3a63a..11cf4375c7 100644 --- a/frontend/__tests__/unit/components/ModeToggle.test.tsx +++ b/frontend/__tests__/unit/components/ModeToggle.test.tsx @@ -52,7 +52,7 @@ describe('ModeToggle Component', () => { const button = screen.getByRole('button', { name: /enable light mode/i }) expect(button).toBeInTheDocument() - const icon = document.querySelector('[data-icon="sun"]') + const icon = document.querySelector('[data-icon="lightbulb"]') expect(icon).toBeInTheDocument() }) diff --git a/frontend/__tests__/unit/pages/Home.test.tsx b/frontend/__tests__/unit/pages/Home.test.tsx index a7cc4e785c..94e26deb09 100644 --- a/frontend/__tests__/unit/pages/Home.test.tsx +++ b/frontend/__tests__/unit/pages/Home.test.tsx @@ -275,13 +275,18 @@ describe('Home', () => { for (const header of headers) { expect(screen.getByText(header)).toBeInTheDocument() } - // Wait for 2 seconds - setTimeout(() => { + }) + + // Wait for animated counters to complete (2 seconds animation) + // Note: The "+" is rendered separately from the number, so we check for the number only + await waitFor( + () => { for (const value of Object.values(stats)) { - expect(screen.getByText(`${millify(value)}+`)).toBeInTheDocument() + expect(screen.getByText(millify(value), { exact: false })).toBeInTheDocument() } - }, 2000) - }) + }, + { timeout: 3000 } + ) }) test('renders event details including date range and location', async () => { diff --git a/frontend/__tests__/unit/pages/Snapshots.test.tsx b/frontend/__tests__/unit/pages/Snapshots.test.tsx index f93f1c3f3d..f4f45c3285 100644 --- a/frontend/__tests__/unit/pages/Snapshots.test.tsx +++ b/frontend/__tests__/unit/pages/Snapshots.test.tsx @@ -59,8 +59,8 @@ describe('SnapshotsPage', () => { render() await waitFor(() => { - const loadingSpinners = screen.getAllByAltText('Loading indicator') - expect(loadingSpinners.length).toBe(2) + const loadingSkeletons = screen.getAllByRole('status') + expect(loadingSkeletons.length).toBeGreaterThan(0) }) }) diff --git a/frontend/src/app/snapshots/page.tsx b/frontend/src/app/snapshots/page.tsx index 724397e543..6b4eca84e0 100644 --- a/frontend/src/app/snapshots/page.tsx +++ b/frontend/src/app/snapshots/page.tsx @@ -6,7 +6,7 @@ import React, { useState, useEffect } from 'react' import FontAwesomeIconWrapper from 'wrappers/FontAwesomeIconWrapper' import { GetCommunitySnapshotsDocument } from 'types/__generated__/snapshotQueries.generated' import type { Snapshot } from 'types/snapshot' -import LoadingSpinner from 'components/LoadingSpinner' +import SnapshotSkeleton from 'components/skeletons/SnapshotSkeleton' import SnapshotCard from 'components/SnapshotCard' const SnapshotsPage: React.FC = () => { @@ -41,7 +41,7 @@ const SnapshotsPage: React.FC = () => { const renderSnapshotCard = (snapshot: Snapshot) => { const SubmitButton = { - label: 'View Details', + label: 'View Snapshot', icon: , onclick: () => handleButtonClick(snapshot), } @@ -57,22 +57,26 @@ const SnapshotsPage: React.FC = () => { ) } - if (isLoading) { - return - } - return (
-
- {!snapshots?.length ? ( -
No Snapshots found
- ) : ( - snapshots.map((snapshot: Snapshot) => ( -
{renderSnapshotCard(snapshot)}
- )) - )} -
+ {isLoading ? ( +
+ {Array.from({ length: 12 }).map((_, index) => ( + + ))} +
+ ) : ( +
+ {!snapshots?.length ? ( +
No Snapshots found
+ ) : ( + snapshots.map((snapshot: Snapshot) => ( +
{renderSnapshotCard(snapshot)}
+ )) + )} +
+ )}
) diff --git a/frontend/src/components/ModeToggle.tsx b/frontend/src/components/ModeToggle.tsx index 65965c56e0..50b5ce566e 100644 --- a/frontend/src/components/ModeToggle.tsx +++ b/frontend/src/components/ModeToggle.tsx @@ -1,4 +1,4 @@ -import { faMoon, faSun } from '@fortawesome/free-regular-svg-icons' +import { faMoon, faLightbulb } from '@fortawesome/free-regular-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { Button } from '@heroui/button' import { Tooltip } from '@heroui/tooltip' @@ -28,7 +28,7 @@ export default function ModeToggle() { >
diff --git a/frontend/src/components/SkeletonsBase.tsx b/frontend/src/components/SkeletonsBase.tsx index b542712128..327823e911 100644 --- a/frontend/src/components/SkeletonsBase.tsx +++ b/frontend/src/components/SkeletonsBase.tsx @@ -1,6 +1,7 @@ import { Skeleton } from '@heroui/skeleton' import LoadingSpinner from 'components/LoadingSpinner' import CardSkeleton from 'components/skeletons/Card' +import SnapshotSkeleton from 'components/skeletons/SnapshotSkeleton' import UserCardSkeleton from 'components/skeletons/UserCard' function userCardRender() { @@ -8,12 +9,24 @@ function userCardRender() { return (
{Array.from({ length: cardCount }).map((_, index) => ( - + ))}
) } +function snapshotCardRender() { + const cardCount = 12 + return ( +
+ {Array.from({ length: cardCount }).map((_, index) => ( + + ))} +
+ ) +} + + const SkeletonBase = ({ indexName, loadingImageUrl, @@ -49,6 +62,12 @@ const SkeletonBase = ({ break case 'users': return userCardRender() + + case 'organizations': + return userCardRender() + case 'snapshots': + return snapshotCardRender() + default: return }