Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions app/routes/_auth+/auth.$provider.callback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,25 @@ import { server } from '#tests/mocks/index.ts'
import { createUser } from '#tests/models/user-test-setup.ts'
import { consoleError } from '#tests/setup/setup-test-env.ts'
import { BASE_URL, convertSetCookieToCookie } from '#tests/utils.ts'
import { type Route } from './+types/auth.$provider.callback.ts'
import { loader } from './auth.$provider.callback.ts'

const ROUTE_PATH = '/auth/github/callback'
const PARAMS = { provider: 'github' }
const LOADER_ARGS_BASE = {
params: PARAMS,
context: {},
url: new URL(ROUTE_PATH, BASE_URL),
pattern: ROUTE_PATH,
} satisfies Omit<Route.LoaderArgs, 'request'>

afterEach(async () => {
await deleteGitHubUsers()
})

test('a new user goes to onboarding', async () => {
const request = await setupRequest()
const response = await loader({ request, params: PARAMS, context: {} }).catch(
const response = await loader({ request, ...LOADER_ARGS_BASE }).catch(
(e) => e,
)
expect(response).toHaveRedirect('/onboarding/github')
Expand All @@ -39,7 +46,7 @@ test('when auth fails, send the user to login with a toast', async () => {
}),
)
const request = await setupRequest()
const response = await loader({ request, params: PARAMS, context: {} }).catch(
const response = await loader({ request, ...LOADER_ARGS_BASE }).catch(
(e) => e,
)
invariant(response instanceof Response, 'response should be a Response')
Expand All @@ -60,7 +67,7 @@ test('when a user is logged in, it creates the connection', async () => {
sessionId: session.id,
code: githubUser.code,
})
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({ request, ...LOADER_ARGS_BASE })
expect(response).toHaveRedirect('/settings/profile/connections')
await expect(response).toSendToast(
expect.objectContaining({
Expand Down Expand Up @@ -96,7 +103,7 @@ test(`when a user is logged in and has already connected, it doesn't do anything
sessionId: session.id,
code: githubUser.code,
})
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({ request, ...LOADER_ARGS_BASE })
expect(response).toHaveRedirect('/settings/profile/connections')
await expect(response).toSendToast(
expect.objectContaining({
Expand All @@ -111,7 +118,7 @@ test('when a user exists with the same email, create connection and make session
const email = githubUser.primaryEmail.toLowerCase()
const { userId } = await setupUser({ ...createUser(), email })
const request = await setupRequest({ code: githubUser.code })
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({ request, ...LOADER_ARGS_BASE })

expect(response).toHaveRedirect('/')

Expand Down Expand Up @@ -155,7 +162,7 @@ test('gives an error if the account is already connected to another user', async
sessionId: session.id,
code: githubUser.code,
})
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({ request, ...LOADER_ARGS_BASE })
expect(response).toHaveRedirect('/settings/profile/connections')
await expect(response).toSendToast(
expect.objectContaining({
Expand All @@ -178,7 +185,7 @@ test('if a user is not logged in, but the connection exists, make a session', as
},
})
const request = await setupRequest({ code: githubUser.code })
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({ request, ...LOADER_ARGS_BASE })
expect(response).toHaveRedirect('/')
await expect(response).toHaveSessionForUser(userId)
})
Expand All @@ -202,7 +209,7 @@ test('if a user is not logged in, but the connection exists and they have enable
},
})
const request = await setupRequest({ code: githubUser.code })
const response = await loader({ request, params: PARAMS, context: {} })
const response = await loader({ request, ...LOADER_ARGS_BASE })
const searchParams = new URLSearchParams({
type: twoFAVerificationType,
target: userId,
Expand Down
14 changes: 7 additions & 7 deletions app/routes/_marketing+/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { SkillBadge } from '#app/components/skill-badge.tsx'
import { CardContent, CardFooter } from '#app/components/ui/card.tsx'
import { useFadeInOnScroll } from '#app/hooks/use-fade-in-on-scroll.ts'
import { prisma } from '#app/utils/db.server.ts'
import { type Info, type Route } from './+types/index.ts'
import { type Route } from './+types/index.ts'

export const meta: Route.MetaFunction = () => [{ title: 'Pat N | Web Dev' }]

Expand Down Expand Up @@ -167,8 +167,8 @@ function AboutSection({
professionalAboutMe,
personalAboutMe,
}: {
professionalAboutMe: Info['loaderData']['professionalAboutMe']
personalAboutMe: Info['loaderData']['personalAboutMe']
professionalAboutMe: Route.ComponentProps['loaderData']['professionalAboutMe']
personalAboutMe: Route.ComponentProps['loaderData']['personalAboutMe']
}) {
return (
<MarketingSection
Expand All @@ -195,7 +195,7 @@ function AboutSection({
function SkillCard({
category,
}: {
category: Info['loaderData']['skillCategories'][number]
category: Route.ComponentProps['loaderData']['skillCategories'][number]
}) {
return (
<MarketingCard title={category.name} className="text-left">
Expand All @@ -211,7 +211,7 @@ function SkillCard({
function SkillsSection({
skillCategories,
}: {
skillCategories: Info['loaderData']['skillCategories']
skillCategories: Route.ComponentProps['loaderData']['skillCategories']
}) {
return (
<MarketingSection sectionId="skills">
Expand Down Expand Up @@ -239,7 +239,7 @@ function SkillsSection({
function ProjectCard({
project,
}: {
project: Info['loaderData']['projects'][number]
project: Route.ComponentProps['loaderData']['projects'][number]
}) {
const { title, description, skills, liveDemoUrl, sourceCodeUrl, comments } =
project
Expand Down Expand Up @@ -287,7 +287,7 @@ function ProjectCard({
function ProjectsSection({
projects,
}: {
projects: Info['loaderData']['projects']
projects: Route.ComponentProps['loaderData']['projects']
}) {
return (
<MarketingSection sectionId="projects">
Expand Down
8 changes: 4 additions & 4 deletions app/routes/dashboard+/__about-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
CheckboxFieldSchema,
StringMinMaxLengthSchema,
} from '#app/utils/zod-helpers.tsx'
import { type Info } from './+types/about.$aboutId_.edit.ts'
import { type Route } from './+types/about.$aboutId_.edit.ts'
import { DashboardAboutIntent } from './about.index.tsx'

export const AboutEditorSchema = z.object({
Expand All @@ -42,9 +42,9 @@ export function AboutEditor({
categories,
actionData,
}: {
aboutMe?: Info['loaderData']['aboutMe']
categories: Info['loaderData']['categories']
actionData?: Info['actionData']
aboutMe?: Route.ComponentProps['loaderData']['aboutMe']
categories: Route.ComponentProps['loaderData']['categories']
actionData?: Route.ComponentProps['actionData']
}) {
const isPending = useIsPending()

Expand Down
6 changes: 3 additions & 3 deletions app/routes/dashboard+/__contact-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
CheckboxFieldSchema,
StringMinMaxLengthSchema,
} from '#app/utils/zod-helpers.tsx'
import { type Info } from './+types/contacts.$contactId_.edit.ts'
import { type Route } from './+types/contacts.$contactId_.edit.ts'
import { DashboardContactIntent } from './contacts.index'

export const ContactEditorSchema = z.object({
Expand All @@ -34,8 +34,8 @@ export function ContactEditor({
contact,
actionData,
}: {
contact?: Info['loaderData']['contact']
actionData?: Info['actionData']
contact?: Route.ComponentProps['loaderData']['contact']
actionData?: Route.ComponentProps['actionData']
}) {
const isPending = useIsPending()

Expand Down
6 changes: 3 additions & 3 deletions app/routes/dashboard+/__layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ import {
import { useRootLoaderData } from '#app/root.tsx'
import { ThemeSwitch } from '#app/routes/resources+/theme-switch.tsx'
import { useRequestInfo } from '#app/utils/request-info.ts'
import { type Info as userInfo } from './+types/route.ts'
import { type Route as UserRoute } from './+types/route.ts'

export function DashboardLayout({
user,
children,
}: {
user: userInfo['loaderData']['user']
user: UserRoute.ComponentProps['loaderData']['user']
children: React.ReactNode
}) {
const requestInfo = useRequestInfo()
Expand Down Expand Up @@ -156,7 +156,7 @@ export function DashboardSidebar({
user,
...props
}: React.ComponentProps<typeof Sidebar> & {
user: userInfo['loaderData']['user']
user: UserRoute.ComponentProps['loaderData']['user']
}) {
return (
<Sidebar collapsible="icon" {...props}>
Expand Down
6 changes: 3 additions & 3 deletions app/routes/dashboard+/__project-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
CheckboxFieldSchema,
StringMinMaxLengthSchema,
} from '#app/utils/zod-helpers.tsx'
import { type Info } from './+types/projects.$projectId_.edit.ts'
import { type Route } from './+types/projects.$projectId_.edit.ts'
import { DashboardProjectIntent } from './projects.index'

export const ProjectEditorSchema = z.object({
Expand All @@ -41,8 +41,8 @@ export function ProjectEditor({
project,
actionData,
}: {
project?: Info['loaderData']['project']
actionData?: Info['actionData']
project?: Route.ComponentProps['loaderData']['project']
actionData?: Route.ComponentProps['actionData']
}) {
const isPending = useIsPending()

Expand Down
6 changes: 3 additions & 3 deletions app/routes/dashboard+/__project-skills-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '#app/components/ui/card.tsx'
import { Icon } from '#app/components/ui/icon.tsx'
import { useIsPending } from '#app/utils/misc.tsx'
import { type Info } from './+types/projects.$projectId.tsx'
import { type Route } from './+types/projects.$projectId.ts'

export const ProjectSkillActionIntent = {
SKILL_ADD: 'skill-add',
Expand All @@ -31,8 +31,8 @@ export function ProjectSkillsEditor({
project,
userSkills,
}: {
project: Info['loaderData']['project']
userSkills: Info['loaderData']['userSkills']
project: Route.ComponentProps['loaderData']['project']
userSkills: Route.ComponentProps['loaderData']['userSkills']
}) {
const fetcher = useFetcher()
const isPending = useIsPending()
Expand Down
8 changes: 4 additions & 4 deletions app/routes/dashboard+/__skill-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
CheckboxFieldSchema,
StringMinMaxLengthSchema,
} from '#app/utils/zod-helpers.tsx'
import { type Info } from './+types/skills.$skillId_.edit.ts'
import { type Route } from './+types/skills.$skillId_.edit.ts'
import { DashboardSkillsIntent } from './skills.index'

export const SkillEditorSchema = z.object({
Expand All @@ -39,9 +39,9 @@ export function SkillEditor({
categories,
actionData,
}: {
skill?: Info['loaderData']['skill']
categories: Info['loaderData']['categories']
actionData?: Info['actionData']
skill?: Route.ComponentProps['loaderData']['skill']
categories: Route.ComponentProps['loaderData']['categories']
actionData?: Route.ComponentProps['actionData']
}) {
const isPending = useIsPending()

Expand Down
7 changes: 4 additions & 3 deletions app/routes/dashboard+/about.index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
createToastHeaders,
redirectWithToast,
} from '#app/utils/toast.server.ts'
import { type Route, type Info } from './+types/about.index.ts'
import { type Route } from './+types/about.index.ts'
import { handleCategoryAction } from './__about-category-editor.server.tsx'
import { AboutCategoryEditor } from './__about-category-editor.tsx'

Expand Down Expand Up @@ -91,8 +91,9 @@ export async function loader({ request }: LoaderFunctionArgs) {
return { aboutMeData, aboutMeCategoryData }
}

type AboutMeDataItem = Info['loaderData']['aboutMeData'][number]
type AboutMeCategoryDataItem = Info['loaderData']['aboutMeCategoryData'][number]
type AboutMeDataItem = Route.ComponentProps['loaderData']['aboutMeData'][number]
type AboutMeCategoryDataItem =
Route.ComponentProps['loaderData']['aboutMeCategoryData'][number]

export const DashboardAboutIntent = {
ABOUT_ME_DELETE: 'about-me-delete',
Expand Down
4 changes: 2 additions & 2 deletions app/routes/dashboard+/contacts.index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
createToastHeaders,
redirectWithToast,
} from '#app/utils/toast.server.ts'
import { type Route, type Info } from './+types/contacts.index.ts'
import { type Route } from './+types/contacts.index.ts'

export const handle: SEOHandle = {
getSitemapEntries: () => null,
Expand All @@ -67,7 +67,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
return data({ contactsData })
}

type ContactDataItem = Info['loaderData']['contactsData'][number]
type ContactDataItem = Route.ComponentProps['loaderData']['contactsData'][number]

export const DashboardContactIntent = {
CONTACT_CREATE: 'contact-create',
Expand Down
4 changes: 2 additions & 2 deletions app/routes/dashboard+/projects.index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
createToastHeaders,
redirectWithToast,
} from '#app/utils/toast.server.ts'
import { type Route, type Info } from './+types/projects.index.ts'
import { type Route } from './+types/projects.index.ts'

export const handle: SEOHandle = {
getSitemapEntries: () => null,
Expand Down Expand Up @@ -73,7 +73,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
return data({ projectsData })
}

type ProjectDataItem = Info['loaderData']['projectsData'][number]
type ProjectDataItem = Route.ComponentProps['loaderData']['projectsData'][number]

export const DashboardProjectIntent = {
PROJECT_CREATE: 'project-create',
Expand Down
7 changes: 4 additions & 3 deletions app/routes/dashboard+/skills.index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
createToastHeaders,
redirectWithToast,
} from '#app/utils/toast.server.ts'
import { type Route, type Info } from './+types/skills.index.ts'
import { type Route } from './+types/skills.index.ts'
import { handleCategoryAction } from './__skill-category-editor.server.tsx'
import { SkillCategoryEditor } from './__skill-category-editor.tsx'

Expand Down Expand Up @@ -90,8 +90,9 @@ export async function loader({ request }: LoaderFunctionArgs) {
return data({ skillsData, skillCategoryData })
}

type SkillDataItem = Info['loaderData']['skillsData'][number]
type SkillCategoryDataItem = Info['loaderData']['skillCategoryData'][number]
type SkillDataItem = Route.ComponentProps['loaderData']['skillsData'][number]
type SkillCategoryDataItem =
Route.ComponentProps['loaderData']['skillCategoryData'][number]

export const DashboardSkillsIntent = {
SKILL_CREATE: 'skill-create',
Expand Down
4 changes: 2 additions & 2 deletions app/routes/settings+/profile.connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { prisma } from '#app/utils/db.server.ts'
import { pipeHeaders } from '#app/utils/headers.server.js'
import { makeTimings } from '#app/utils/timing.server.ts'
import { createToastHeaders } from '#app/utils/toast.server.ts'
import { type Info, type Route } from './+types/profile.connections.ts'
import { type Route } from './+types/profile.connections.ts'
import { type BreadcrumbHandle } from './profile.tsx'

export const handle: BreadcrumbHandle & SEOHandle = {
Expand Down Expand Up @@ -150,7 +150,7 @@ function Connection({
connection,
canDelete,
}: {
connection: Info['loaderData']['connections'][number]
connection: Route.ComponentProps['loaderData']['connections'][number]
canDelete: boolean
}) {
const deleteFetcher = useFetcher<typeof action>()
Expand Down
Loading
Loading