-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from uug-ai/feature-navigation
Feature navigation
- Loading branch information
Showing
9 changed files
with
162 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
// SignOutButton.test.js (or .test.tsx if using TypeScript) | ||
// __tests__/SignOut.test.js | ||
import { render, screen } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
import userEvent from "@testing-library/user-event"; | ||
import SignOutButton from "../src/components/SignOutButton"; | ||
import { signOut } from "next-auth/react"; | ||
|
||
// Mock next-auth/react's signOut function | ||
// Mock next-auth/react | ||
jest.mock("next-auth/react", () => ({ | ||
signOut: jest.fn(), | ||
})); | ||
|
||
describe("SignOutButton", () => { | ||
it('renders "Sign out" button', () => { | ||
// Render the SignOutButton component | ||
render(<SignOutButton />); | ||
const signOutButton = screen.getByRole("button", { name: /sign out/i }); | ||
expect(signOutButton).toBeInTheDocument(); | ||
}); | ||
|
||
it("calls signOut when button is clicked", async () => { | ||
render(<SignOutButton />); | ||
const signOutButton = screen.getByRole("button", { name: /sign out/i }); | ||
|
||
// Get the button element | ||
const buttonElement = screen.getByRole("button", { name: /Sign out/i }); | ||
await userEvent.click(signOutButton); | ||
|
||
// Check if the button is in the document | ||
expect(buttonElement).toBeInTheDocument(); | ||
expect(signOut).toHaveBeenCalledWith({ | ||
callbackUrl: "/signin", | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import "@testing-library/jest-dom"; | ||
import "next-router-mock/dynamic-routes"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,15 @@ | ||
import SignOutButton from "@/components/SignOutButton"; | ||
import { Row, Stack } from "@/components/ui"; | ||
import { authOptions } from "@/utils/auth"; | ||
import { getServerSession } from "next-auth"; | ||
import Navigation from "@/components/Navigation"; | ||
import { Row } from "@/components/ui"; | ||
|
||
export default async function DashboardLayout({ | ||
children, // will be a page or nested layout | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
const session = await getServerSession(authOptions); | ||
return ( | ||
<section> | ||
<Row> | ||
{/* Mock navigation element with session info */} | ||
<Stack className="w-60 bg-gray-200"> | ||
<div className="w-60 truncate"> | ||
<p>NAVIGATION</p> | ||
<pre>{JSON.stringify(session, null, 2)}</pre> | ||
</div> | ||
<SignOutButton /> | ||
</Stack> | ||
<main className="grow">{children}</main> | ||
</Row> | ||
</section> | ||
<Row> | ||
<Navigation /> | ||
<main className="grow">{children}</main> | ||
</Row> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import SignOutButton from "./SignOutButton"; | ||
import { | ||
Box, | ||
Icon, | ||
Row, | ||
NavigationHeader, | ||
NavItem, | ||
NavigationSocials, | ||
NavigationFooter, | ||
} from "./ui"; | ||
import React from "react"; | ||
|
||
const Navigation = () => { | ||
return ( | ||
<Box className="h-screen flex flex-col"> | ||
<NavigationHeader /> | ||
|
||
{/* Navigation Main (add new content here) */} | ||
<Box className="flex-grow bg-slate-100 overflow-auto"> | ||
<Row> | ||
<NavItem type="dashboard" title="Dashboard" /> | ||
<Icon type="notification" className="text-red-500 self-end mr-2" /> | ||
</Row> | ||
<NavItem type="history" title="History" href="#" /> | ||
<NavItem type="cameraswap" title="Camera" href="#" /> | ||
<NavItem type="insights" title="Insights" href="#" /> | ||
</Box> | ||
{/* end of Navigation main */} | ||
|
||
<NavigationSocials /> | ||
<SignOutButton /> | ||
<NavigationFooter /> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default Navigation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2877,10 +2877,10 @@ | |
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406" | ||
integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ== | ||
|
||
"@uug-ai/[email protected].35": | ||
version "1.0.35" | ||
resolved "https://registry.yarnpkg.com/@uug-ai/ui/-/ui-1.0.35.tgz#3daab5491ac3d3a2d33d9b47af1f3d07b9aec2e8" | ||
integrity sha512-/ZNHGNt1NWsYk1XTKmUlLSsSqelWXuo3UiIOCxwE2DNeTTfvboB8/OpXOCgKYpTKtoay5Zs85g+WyE6rrLFkbg== | ||
"@uug-ai/ui@^1.0.36": | ||
version "1.0.36" | ||
resolved "https://registry.yarnpkg.com/@uug-ai/ui/-/ui-1.0.36.tgz#d52b7d7be7de9183f4f225d46348c77de4792cb7" | ||
integrity sha512-wWm7tCiObTGk6jZYGUohEDozRz3Q6O/w3abw3hlPvb3vckem1n9ODSI8HoAm7Wn9mM7TdZTasNxSFqB9GlvOuQ== | ||
dependencies: | ||
"@storybook/addon-essentials" "^8.0.9" | ||
"@storybook/addon-interactions" "^8.0.9" | ||
|
@@ -2891,6 +2891,7 @@ | |
class-variance-authority "^0.7.0" | ||
clsx "^2.0.0" | ||
next "^14.2.3" | ||
pigeon-maps "^0.21.6" | ||
react "^18" | ||
react-dom "^18" | ||
react-webcam "^7.2.0" | ||
|
@@ -7336,6 +7337,11 @@ pify@^4.0.1: | |
resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" | ||
integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== | ||
|
||
pigeon-maps@^0.21.6: | ||
version "0.21.6" | ||
resolved "https://registry.yarnpkg.com/pigeon-maps/-/pigeon-maps-0.21.6.tgz#e9b89e614fa46a94c7e86984cf8e6794a1eccc0e" | ||
integrity sha512-6io58lhpbtVT/DUKDoOqsjeAFW46Nfe+gr4PX/kmD1dyJxfb8WaT4hcgwcmM8dJdkyfibgLHo59Uo2o2/xscaQ== | ||
|
||
pirates@^4.0.1, pirates@^4.0.4, pirates@^4.0.6: | ||
version "4.0.6" | ||
resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.6.tgz#3018ae32ecfcff6c29ba2267cbf21166ac1f36b9" | ||
|