generated from taylorbryant/gatsby-starter-tailwind
-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
viet nguyen
committed
Nov 30, 2023
1 parent
6709cd1
commit b653bfc
Showing
16 changed files
with
158 additions
and
69 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { NextRequest, NextResponse } from 'next/server' | ||
import { revalidatePath } from 'next/cache' | ||
import { validate } from 'uuid' | ||
|
||
export const dynamic = 'force-dynamic' | ||
export const fetchCache = 'force-no-store' | ||
|
||
/** | ||
* Endpoint: /api/updateAreaPage | ||
*/ | ||
export async function GET (request: NextRequest): Promise<any> { | ||
const uuid = request.nextUrl.searchParams.get('uuid') as string | ||
if (uuid == null || !validate(uuid)) { | ||
return NextResponse.json({ message: 'Missing uuid in query string' }) | ||
} else { | ||
revalidatePath(`/area/${uuid}`, 'page') | ||
revalidatePath(`/editArea/${uuid}`, 'layout') | ||
return NextResponse.json({ message: 'OK' }, { status: 200 }) | ||
} | ||
} |
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
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
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,19 @@ | ||
'use client' | ||
import { useEffect } from 'react' | ||
import { useSearchParams, redirect } from 'next/navigation' | ||
import { signIn, useSession } from 'next-auth/react' | ||
|
||
export default function Page (): any { | ||
const { status } = useSession() | ||
const searchParams = useSearchParams() | ||
useEffect(() => { | ||
if (status === 'authenticated') { | ||
const url = searchParams.get('callbackUrl') ?? '/' | ||
redirect(url) | ||
} | ||
if (status === 'unauthenticated') { | ||
void signIn('auth0') | ||
} | ||
}, [status]) | ||
return <div className='h-screen w-screen'><div className='m-6'>Loading...</div></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
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
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,22 +1,37 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import PhotoMontage from '../PhotoMontage' | ||
import type PhotoMontageType from '../PhotoMontage' | ||
import { mediaList } from './data' | ||
|
||
test('PhotoMontage can render 1 photo', async () => { | ||
render(<PhotoMontage photoList={mediaList.slice(0, 1)} isHero />) | ||
const elements: HTMLImageElement[] = await screen.findAllByRole('img') | ||
expect(elements.length).toBe(1) | ||
expect(elements[0].src).toContain(mediaList[0].mediaUrl) | ||
}) | ||
let PhotoMontage: typeof PhotoMontageType | ||
|
||
test('PhotoMontage always renders 2 photos when provided with a list of 2 to 4', async () => { | ||
render(<PhotoMontage photoList={mediaList.slice(0, 3)} isHero />) | ||
const elements: HTMLImageElement[] = await screen.findAllByRole('img') | ||
expect(elements.length).toBe(2) // should be 2 | ||
}) | ||
jest.mock('../../UploadPhotoTrigger', () => ({ | ||
__esModule: true, | ||
default: () => <div /> | ||
})) | ||
|
||
describe('PhotoMontage tests', () => { | ||
beforeAll(async () => { | ||
// why async import? see https://github.com/facebook/jest/issues/10025#issuecomment-716789840 | ||
const module = await import('../PhotoMontage') | ||
PhotoMontage = module.default | ||
}) | ||
|
||
test('PhotoMontage can render 1 photo', async () => { | ||
render(<PhotoMontage photoList={mediaList.slice(0, 1)} isHero />) | ||
const elements: HTMLImageElement[] = await screen.findAllByRole('img') | ||
expect(elements.length).toBe(1) | ||
expect(elements[0].src).toContain(mediaList[0].mediaUrl) | ||
}) | ||
|
||
test('PhotoMontage always renders 2 photos when provided with a list of 2 to 4', async () => { | ||
render(<PhotoMontage photoList={mediaList.slice(0, 3)} isHero />) | ||
const elements: HTMLImageElement[] = await screen.findAllByRole('img') | ||
expect(elements.length).toBe(2) // should be 2 | ||
}) | ||
|
||
test('PhotoMontage always renders 5 photos when provided with a list > 5', async () => { | ||
render(<PhotoMontage photoList={mediaList} isHero />) | ||
const elements: HTMLImageElement[] = await screen.findAllByRole('img') | ||
expect(elements.length).toBe(5) // should be 5 | ||
test('PhotoMontage always renders 5 photos when provided with a list > 5', async () => { | ||
render(<PhotoMontage photoList={mediaList} isHero />) | ||
const elements: HTMLImageElement[] = await screen.findAllByRole('img') | ||
expect(elements.length).toBe(5) // should be 5 | ||
}) | ||
}) |
Oops, something went wrong.