forked from tryyang2001/CS3213-Frontend-Management-System
-
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 tryyang2001#35 from tryyang2001/tryyang/fix_fronte…
…nd_build_error Fix frontend build error existing in the master branch
- Loading branch information
Showing
10 changed files
with
451 additions
and
539 deletions.
There are no files selected for viewing
281 changes: 23 additions & 258 deletions
281
frontend/src/app/__tests__/__snapshots__/pages.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
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,68 +1,67 @@ | ||
import LandingPage from '../login/page' | ||
import LoginPage from '../login/page' | ||
import SignUpPage from '../sign-up/page' | ||
import UserPage from '../user/page' | ||
import AssignmentPage from '../(pages)/assignments/[id]/page' | ||
import AssignmentService from '@/helpers/assignment-service/api-wrapper' | ||
import LandingPage from "../login/page"; | ||
import LoginPage from "../login/page"; | ||
import SignUpPage from "../sign-up/page"; | ||
import UserPage from "../user/page"; | ||
import AssignmentPage from "../assignments/[id]/page"; | ||
import AssignmentService from "@/helpers/assignment-service/api-wrapper"; | ||
|
||
import {render} from '@testing-library/react' | ||
import { render } from "@testing-library/react"; | ||
|
||
// Place all page's Snapshot tests here | ||
|
||
jest.mock('next/navigation', () => { | ||
jest.mock("next/navigation", () => { | ||
return { | ||
__esModule: true, | ||
useRouter: () => ({ | ||
replace: jest.fn(), | ||
prefetch: jest.fn() | ||
prefetch: jest.fn(), | ||
}), | ||
useSearchParams: () => ({ | ||
get: () => {} | ||
get: () => {}, | ||
}), | ||
notFound: () => ({ | ||
notFound: () => ({}), | ||
}; | ||
}); | ||
|
||
}) | ||
} | ||
}) | ||
|
||
jest.mock('@tanstack/react-query', () => { | ||
jest.mock("@tanstack/react-query", () => { | ||
return { | ||
__esModule: true, | ||
useQuery: () => { | ||
const assignment = AssignmentService.getAssignmentById({assignmentId: "1"}) | ||
const assignment = AssignmentService.getAssignmentById({ | ||
assignmentId: "1", | ||
}); | ||
return { | ||
data: assignment, | ||
isLoading: assignment.then(() => false) | ||
} | ||
} | ||
} | ||
}) | ||
isLoading: assignment.then(() => false), | ||
}; | ||
}, | ||
}; | ||
}); | ||
|
||
describe('Page Snapshot tests', () => { | ||
it('Landing Page Snapshot test', () => { | ||
const { container } = render(<LandingPage />) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
describe("Page Snapshot tests", () => { | ||
it("Landing Page Snapshot test", () => { | ||
const { container } = render(<LandingPage />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('Login Snapshot test', () => { | ||
const { container } = render(<LoginPage />) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
it("Login Snapshot test", () => { | ||
const { container } = render(<LoginPage />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('Sign-up Snapshot test', () => { | ||
const { container } = render(<SignUpPage />) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
it("Sign-up Snapshot test", () => { | ||
const { container } = render(<SignUpPage />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('User Page Snapshot test', async () => { | ||
const Page = await UserPage() | ||
const { container } = render(Page) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
it("User Page Snapshot test", async () => { | ||
const { container } = render(<UserPage />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('Loading Assignment Page Snapshot test', () => { | ||
const id = "1" | ||
const { container } = render(<AssignmentPage id={id} />) | ||
expect(container).toMatchSnapshot() | ||
}) | ||
}) | ||
it("Loading Assignment Page Snapshot test", () => { | ||
const id = "1"; | ||
const { container } = render(<AssignmentPage params={{ id: id }} />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,26 +1,43 @@ | ||
import { ReadOnlyFullUserCard, UserInfo } from "../../components/common/ReadOnlyUserCard"; | ||
"use client"; | ||
|
||
import { UserInfo } from "../../components/common/ReadOnlyUserCard"; | ||
import ProfileEditor from "../../components/forms/ProfileEditor"; | ||
import AccountEditor from "../../components/forms/AccountEditor"; | ||
import { useEffect, useState } from "react"; | ||
import LogoLoading from "@/components/common/LogoLoading"; | ||
|
||
export default function Page() { | ||
const [userInfo, setUserInfo] = useState<UserInfo>({} as UserInfo); | ||
const [isLoading, setIsLoading] = useState<boolean>(true); | ||
|
||
const getUserData = async () => { | ||
const res = await fetch("https://jsonplaceholder.typicode.com/users/1"); | ||
const userInfo: UserInfo = await res.json(); | ||
|
||
export default async function Home() { | ||
const userInfo = await getUserData(); | ||
setUserInfo(userInfo); | ||
setIsLoading(false); | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-col items-center p-12"> | ||
<div className="flex w-full justify-around gap-12 pt-10"> | ||
useEffect(() => { | ||
getUserData(); | ||
}, []); | ||
|
||
return ( | ||
<div className="flex flex-col items-center p-2"> | ||
{isLoading ? ( | ||
<LogoLoading /> | ||
) : ( | ||
<div className="w-full"> | ||
<div className="flex w-full justify-around gap-12 pt-10"> | ||
<div> Your Account </div> | ||
<ProfileEditor userInfo={userInfo} /> | ||
</div> | ||
<div className="flex w-full justify-around gap-12 pt-10"> | ||
<ProfileEditor userInfo={userInfo} /> | ||
</div> | ||
<div className="flex w-full justify-around gap-12 pt-10"> | ||
<div> Your Profile </div> | ||
<AccountEditor userInfo={userInfo} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export const getUserData = async () => { | ||
const res = await fetch("https://jsonplaceholder.typicode.com/users/1"); | ||
const userInfo: UserInfo = await res.json(); | ||
return userInfo | ||
}; | ||
)} | ||
</div> | ||
); | ||
} |
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
Oops, something went wrong.