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
33 changes: 30 additions & 3 deletions apps/web/app/(onboarding)/student/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,14 @@ export default function StudentOnboardingPage() {
{/* Step 2: Education */}
<div
className="flex flex-col items-center gap-1.5 cursor-pointer group shrink-0"
onClick={() => step > 1 && setStep(2)}
onClick={async () => {
if (step > 1) {
setStep(2)
} else {
const isValid = await trigger(['fullName', 'headline'])
if (isValid) setStep(2)
}
}}
>
<div
className={`w-[34px] h-[34px] rounded-full flex items-center justify-center text-xs font-bold transition-all duration-300 ${
Expand Down Expand Up @@ -505,7 +512,16 @@ export default function StudentOnboardingPage() {
{/* Step 3: Skills & Exp */}
<div
className="flex flex-col items-center gap-1.5 cursor-pointer group shrink-0"
onClick={() => step > 2 && setStep(3)}
onClick={async () => {
if (step > 2) {
setStep(3)
} else {
const valid1 = await trigger(['fullName', 'headline'])
if (!valid1) return
const valid2 = await trigger(['school', 'degree', 'graduationYear'])
if (valid2) setStep(3)
}
}}
>
<div
className={`w-[34px] h-[34px] rounded-full flex items-center justify-center text-xs font-bold transition-all duration-300 ${
Expand Down Expand Up @@ -542,7 +558,18 @@ export default function StudentOnboardingPage() {
{/* Step 4: Links & Finish */}
<div
className="flex flex-col items-center gap-1.5 cursor-pointer group shrink-0"
onClick={() => step > 3 && setStep(4)}
onClick={async () => {
if (step > 3) {
setStep(4)
} else {
const valid1 = await trigger(['fullName', 'headline'])
if (!valid1) return
const valid2 = await trigger(['school', 'degree', 'graduationYear'])
if (!valid2) return
const valid3 = await trigger(['skills'])
if (valid3 && skills.length > 0) setStep(4)
}
}}
>
<div
className={`w-[34px] h-[34px] rounded-full flex items-center justify-center text-xs font-bold transition-all duration-300 ${
Expand Down
83 changes: 83 additions & 0 deletions apps/web/app/(onboarding)/student/schema.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { describe, expect, it } from 'vitest'
import {
studentCompleteOnboardingSchema,
studentStep1Schema,
studentStep2Schema,
studentStep3Schema,
studentStep4Schema,
} from '@/lib/schemas/student-onboarding.schema'

describe('studentCompleteOnboardingSchema', () => {
const validData = {
fullName: 'Alex Chen',
headline: 'CS Student | Full-Stack Developer',
bio: 'Enthusiastic developer looking for opportunities.',
school: 'Stanford University',
degree: 'B.S. Computer Science',
graduationYear: '2026',
gpa: '3.9',
specialization: 'AI / Machine Learning',
skills: ['React', 'TypeScript', 'Next.js'],
experienceRole: 'Frontend Intern',
experienceCompany: 'DK24 Labs',
experienceSummary: 'Built key UI components',
githubUrl: 'https://github.com/alexchen',
linkedinUrl: 'https://linkedin.com/in/alexchen',
portfolioUrl: 'https://alexchen.dev',
resumeUrl: 'https://drive.google.com/resume.pdf',
}

it('validates a valid student onboarding data object', () => {
const result = studentCompleteOnboardingSchema.safeParse(validData)
expect(result.success).toBe(true)
})

it('fails validation when fullName is too short or empty', () => {
const resultEmpty = studentStep1Schema.safeParse({ fullName: '' })
expect(resultEmpty.success).toBe(false)

const resultShort = studentStep1Schema.safeParse({ fullName: 'A' })
expect(resultShort.success).toBe(false)
})

it('fails validation when school or degree is empty', () => {
const invalidSchool = studentStep2Schema.safeParse({
school: '',
degree: 'B.S.',
graduationYear: '2026',
})
expect(invalidSchool.success).toBe(false)

const invalidDegree = studentStep2Schema.safeParse({
school: 'Stanford',
degree: '',
graduationYear: '2026',
})
expect(invalidDegree.success).toBe(false)
})

it('fails validation when skills array is empty', () => {
const invalidSkills = studentStep3Schema.safeParse({
skills: [],
})
expect(invalidSkills.success).toBe(false)
})

it('validates optional URLs correctly', () => {
const validUrls = studentStep4Schema.safeParse({
githubUrl: '',
linkedinUrl: 'https://linkedin.com/in/alexchen',
portfolioUrl: '',
resumeUrl: '',
})
expect(validUrls.success).toBe(true)

const invalidUrl = studentStep4Schema.safeParse({
githubUrl: 'not-a-valid-url',
linkedinUrl: '',
portfolioUrl: '',
resumeUrl: '',
})
expect(invalidUrl.success).toBe(false)
})
})
Loading