Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…n-survivor into danielle/482-notifications-needs-a-way-to-exit-the-modal
  • Loading branch information
Danielle254 committed Oct 16, 2024
2 parents deb61d1 + 068997a commit 7453829
Show file tree
Hide file tree
Showing 20 changed files with 561 additions and 22 deletions.
4 changes: 0 additions & 4 deletions .env.example

This file was deleted.

2 changes: 2 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { StorybookConfig } from '@storybook/nextjs';

const config: StorybookConfig = {
stories: [
'../stories/*.mdx',
'../stories/**/*.mdx',
'../components/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
Expand All @@ -12,6 +13,7 @@ const config: StorybookConfig = {
'@storybook/addon-essentials',
'@chromatic-com/storybook',
'@storybook/addon-interactions',
'@storybook/manager-api',
],
framework: {
name: '@storybook/nextjs',
Expand Down
8 changes: 8 additions & 0 deletions .storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { addons } from '@storybook/manager-api';

addons.setConfig({
sidebar: {
showRoots: true,
collapsedRoots: ['about', 'technical-planning-documents'],
},
});
9 changes: 2 additions & 7 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Preview } from '@storybook/react';
import '../app/globals.css';
import '../stories/styles.css';

const preview: Preview = {
parameters: {
Expand All @@ -9,13 +10,7 @@ const preview: Preview = {
date: /Date$/i,
},
},
backgrounds: {
default: 'dark',
values: [
{ name: 'dark', value: '#09090B' },
{ name: 'light', value: '#fff' },
],
},
layout: 'centered',
},
};

Expand Down
39 changes: 39 additions & 0 deletions components/Nav/Nav.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import Nav from './Nav';
import Login from '@/app/(main)/login/page';
import { useDataStore } from '@/store/dataStore';
import { getUserLeagues } from '@/utils/utils';

const mockPush = jest.fn();
const mockUsePathname = jest.fn();
Expand Down Expand Up @@ -32,6 +34,10 @@ jest.mock('../../context/AuthContextProvider', () => ({
},
}));

jest.mock('@/store/dataStore', () => ({
useDataStore: jest.fn(() => ({ user: { id: '123', leagues: [] } })),
}));

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
Expand All @@ -47,10 +53,25 @@ Object.defineProperty(window, 'matchMedia', {
});

describe('Nav', () => {
const mockUseDataStore = useDataStore as unknown as jest.Mock;
const mockGetUserLeagues = getUserLeagues as jest.Mock;

beforeEach(() => {
jest.clearAllMocks();
});

it('renders link to /league/all', async () => {
render(<Nav />);

const drawTrigger = screen.getByTestId('drawer-trigger');
fireEvent.click(drawTrigger);

let linkNav: HTMLElement;
linkNav = await screen.getByTestId('league-link');
expect(linkNav).toBeInTheDocument();
expect(linkNav).toHaveAttribute('href', '/league/all');
});

it('it should render the default component state', () => {
mockUsePathname.mockImplementation(() => '/weeklyPicks');

Expand Down Expand Up @@ -163,4 +184,22 @@ describe('Nav', () => {
expect(drawerTrigger.getAttribute('data-state')).toBe('closed');
});
});

it('it should close the drawer when the leagues link is clicked', async () => {
mockUsePathname.mockImplementation(() => '/league/all');

render(<Nav />);

const drawerTrigger = screen.getByTestId('drawer-trigger');

fireEvent.click(drawerTrigger);

const linkNav = screen.getByTestId('league-link');

fireEvent.click(linkNav);

await waitFor(() => {
expect(drawerTrigger.getAttribute('data-state')).toBe('closed');
});
});
});
15 changes: 14 additions & 1 deletion components/Nav/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React, { JSX } from 'react';
import LogoNav from '../LogoNav/LogoNav';
import { Menu } from 'lucide-react';
import { Button } from '../Button/Button';
import Link from 'next/link';
import {
Drawer,
DrawerContent,
Expand Down Expand Up @@ -68,9 +69,21 @@ export const Nav = (): JSX.Element => {
<DrawerTitle data-testid="title">Gridiron Survivor</DrawerTitle>
</DrawerHeader>
<ul className="m-0 flex flex-col gap-4 p-0">
<li>
<Link
data-testid="league-link"
href="/league/all"
className={cn(
'underline underline-offset-4 hover:text-primary-muted transition-colors',
)}
onClick={() => setOpen(false)}
>
Leagues
</Link>
</li>
<li>
<Button
className="p-0 text-base font-normal text-muted-foreground"
className="p-0 text-base font-normal text-primary-foreground"
variant="link"
label="Sign Out"
onClick={() => {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
"clsx": "^2.1.0",
"geist": "^1.2.2",
"immer": "^10.1.1",
"lucide-react": "^0.312.0",
"lucide-react": "^0.447.0",
"next": "^14.1.1",
"node-appwrite": "^13.0.0",
"postcss": "8.4.29",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.51.3",
"react-hot-toast": "^2.4.1",
"react-icons": "^5.3.0",
"tailwind-merge": "^2.2.2",
"tailwindcss": "3.3.3",
"tailwindcss-animate": "^1.0.7",
Expand Down
24 changes: 18 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions public/assets/appwriteLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 85 additions & 0 deletions public/assets/blogRecorderLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/fonts/Geist[wght].ttf
Binary file not shown.
6 changes: 6 additions & 0 deletions public/assets/frontendMentorLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7453829

Please sign in to comment.