diff --git a/web/src/components/FafsaModuleTour.tsx b/web/src/components/FafsaModuleTour.tsx index 128777b..d498e36 100644 --- a/web/src/components/FafsaModuleTour.tsx +++ b/web/src/components/FafsaModuleTour.tsx @@ -12,7 +12,7 @@ import { MODULE_COLORS } from '../lib/designTokens' export type TourTabId = | 'overview' - | 'scholarships-101' + | 'financial-aid-101' | 'scholarships' | 'scholarship-search' @@ -41,11 +41,11 @@ const STEPS: TourStep[] = [ }, { - selector: '[data-tour="tab-scholarships-101"]', + selector: '[data-tour="tab-financial-aid-101"]', pad: 6, - title: 'Scholarships 101', - desc: 'Articles, quizzes, and tasks on scholarships, the kinds of aid, the FAFSA, and net price calculators.', - switchTab: 'scholarships-101', + title: 'Financial Aid 101', + desc: 'Articles, quizzes, and tasks on the kinds of aid, scholarships, the FAFSA, and net price calculators.', + switchTab: 'financial-aid-101', keepClear: ['sidebar', 'content'], }, { @@ -53,7 +53,7 @@ const STEPS: TourStep[] = [ pad: 8, title: 'Your Progress', desc: 'Track how far along you are. Items update automatically as you complete them.', - switchTab: 'scholarships-101', + switchTab: 'financial-aid-101', keepClear: ['content'], }, { @@ -61,7 +61,7 @@ const STEPS: TourStep[] = [ pad: 10, title: 'Checklist', desc: 'Click any item to open its content — articles, quizzes, and action items. Check them off as you go.', - switchTab: 'scholarships-101', + switchTab: 'financial-aid-101', keepClear: ['content'], }, diff --git a/web/src/components/FinancialAidModule.test.tsx b/web/src/components/FinancialAidModule.test.tsx index f7a7316..e3bee26 100644 --- a/web/src/components/FinancialAidModule.test.tsx +++ b/web/src/components/FinancialAidModule.test.tsx @@ -1,8 +1,8 @@ import { useState } from 'react' import { describe, it, expect, vi } from 'vitest' -import { render, screen } from '@testing-library/react' +import { render, screen, within } from '@testing-library/react' import userEvent from '@testing-library/user-event' -import { AidForms, Scholarships101Tab } from './FinancialAidModule' +import { AidForms, FinancialAid101Tab } from './FinancialAidModule' import { ContentBlockRenderer } from './contentBlocks' import type { AidCollege } from '../lib/aidColleges' @@ -39,6 +39,20 @@ describe('AidForms', () => { expect(screen.getByText('Not usually')).toBeInTheDocument() }) + it('shows its first schools before it opens, and the rest once it does', async () => { + const dated = (name: string, day: number) => school(name, { financialAidDeadlines: { fafsaPriority: `Jan ${day}, 2027`, cssProfile: null, aidNotification: null } }) + render() + const fafsa = screen.getByRole('button', { name: /^FAFSA/ }).parentElement! + // Soonest first, three of them, and a toggle that says how many there are. + expect(within(fafsa).getAllByText(/^Jan \d, 2027$/).map((d) => d.textContent)).toEqual(['Jan 1, 2027', 'Jan 2, 2027', 'Jan 3, 2027']) + expect(within(fafsa).queryByText(/studentaid\.gov/)).not.toBeInTheDocument() + await userEvent.click(within(fafsa).getByRole('button', { name: 'Show all 5 schools' })) + expect(within(fafsa).getAllByText(/^Jan \d, 2027$/)).toHaveLength(5) + expect(within(fafsa).getByText(/studentaid\.gov/)).toBeInTheDocument() + await userEvent.click(within(fafsa).getByRole('button', { name: 'Show less' })) + expect(within(fafsa).getAllByText(/^Jan \d, 2027$/)).toHaveLength(3) + }) + it('goes to Aid Tracker instead of opening on Overview', async () => { const onSeeSchools = vi.fn() render() @@ -56,9 +70,10 @@ describe('AidForms', () => { // Elon's own date is the earliest, so it leads. expect(screen.getByText('Your earliest school date: Jan 5, 2027 (Elon)')).toBeInTheDocument() - await userEvent.click(screen.getByRole('button', { name: /^FAFSA/ })) + const fafsa = screen.getByRole('button', { name: /^FAFSA/ }) + await userEvent.click(fafsa) // Duke and UNC have dates on file: nothing to add there. - expect(screen.queryAllByRole('button', { name: /Add a due date/ })).toHaveLength(0) + expect(within(fafsa.parentElement!).queryAllByRole('button', { name: /Add a due date/ })).toHaveLength(0) expect(screen.getByRole('button', { name: /Change the due date for Elon’s FAFSA priority date/ })).toBeInTheDocument() await userEvent.click(screen.getByRole('button', { name: /^CSS Profile/ })) @@ -76,37 +91,42 @@ describe('AidForms', () => { }) }) -describe('Scholarships 101', () => { - it('starts with the six scholarship steps and opens each one', async () => { +describe('Financial Aid 101', () => { + it('starts with the kinds of aid, then the six scholarship steps, and opens each one', async () => { const onToggle = vi.fn() // The open article belongs to the module now, so stand in for it. const Harness = () => { const [activeId, setActiveId] = useState(null) - return + return } render() expect(screen.getByText('1/18 completed')).toBeInTheDocument() - await userEvent.click(screen.getByText('Understanding scholarships: types, eligibility, and how they work')) - expect(onToggle).toHaveBeenCalledWith('sr-5') + await userEvent.click(screen.getByText('Grants vs. loans vs. work-study')) + expect(onToggle).toHaveBeenCalledWith('at-1') expect(screen.getByText('1 of 18')).toBeInTheDocument() + expect(screen.getByRole('heading', { name: 'The Three Pillars of Financial Aid' })).toBeInTheDocument() + expect(screen.getByRole('button', { name: /Back to Financial Aid 101/ })).toBeInTheDocument() + // The scholarship steps follow the four aid-type items, and each has its article. + await userEvent.click(screen.getByRole('button', { name: /Back to Financial Aid 101/ })) + await userEvent.click(screen.getByText('Understanding scholarships: types, eligibility, and how they work')) + expect(screen.getByText('5 of 18')).toBeInTheDocument() expect(screen.getByRole('heading', { name: 'What Is a Scholarship?' })).toBeInTheDocument() - expect(screen.getByRole('button', { name: /Back to Scholarships 101/ })).toBeInTheDocument() - // Last step's article is there too, and the "next" button stops at it. - await userEvent.click(screen.getByRole('button', { name: /Back to Scholarships 101/ })) + await userEvent.click(screen.getByRole('button', { name: /Back to Financial Aid 101/ })) await userEvent.click(screen.getByText('Identify 10 scholarships to apply to senior year')) - expect(screen.getByText('6 of 18')).toBeInTheDocument() + expect(screen.getByText('10 of 18')).toBeInTheDocument() expect(screen.queryByText('Content not found for this item.')).not.toBeInTheDocument() }) - it('holds the rest of the checklist, and opens an article to read without starting it', () => { + it('holds the rest of the checklist in order, and opens an article to read without starting it', () => { const onToggle = vi.fn() - const { unmount } = render() - for (const section of ['Scholarships', 'Understanding Aid Types', 'FAFSA Preparation', 'Net Price Calculators']) { - expect(screen.getByRole('button', { name: new RegExp(`^${section}`) })).toBeInTheDocument() - } + const { unmount } = render() + const sections = screen.getAllByRole('button', { expanded: true }).map((b) => b.textContent) + const order = ['Understanding Aid Types', 'Scholarships', 'FAFSA Preparation', 'Net Price Calculators'] + expect(sections).toHaveLength(order.length) + order.forEach((title, i) => expect(sections[i]).toMatch(new RegExp(`^${title}`))) unmount() // Opened straight onto by the module (Overview's "Start FAFSA prep"). - render() + render() expect(screen.getByText('What is FAFSA and why every student should file', { exact: false })).toBeInTheDocument() expect(onToggle).not.toHaveBeenCalled() }) diff --git a/web/src/components/FinancialAidModule.tsx b/web/src/components/FinancialAidModule.tsx index b574fb7..a007c5d 100644 --- a/web/src/components/FinancialAidModule.tsx +++ b/web/src/components/FinancialAidModule.tsx @@ -89,11 +89,21 @@ interface ChecklistSection { items: ChecklistItem[] } -/** Everything Scholarships 101 teaches, in its order. The scholarship steps - * come first, in the content team's reading order; they were Overview's - * "Scholarship Research" section, as the rest was the rest of Overview, so - * every item keeps its id and the progress a student already has on it. */ +/** Everything Financial Aid 101 teaches, in its order: the kinds of aid + * first, then the scholarship steps in the content team's reading order. + * The scholarship steps were Overview's "Scholarship Research" section, as + * the rest was the rest of Overview, so every item keeps its id and the + * progress a student already has on it. */ const CHECKLIST_SECTIONS: ChecklistSection[] = [ + { + title: 'Understanding Aid Types', + items: [ + { id: 'at-1', label: 'Grants vs. loans vs. work-study', type: 'article' }, + { id: 'at-2', label: 'Federal vs. institutional vs. private aid', type: 'article' }, + { id: 'at-3', label: 'How the Student Aid Index (SAI) is calculated', type: 'article' }, + { id: 'at-4', label: 'Quiz: Financial aid fundamentals', type: 'quiz' }, + ], + }, { title: 'Scholarships', items: [ @@ -105,15 +115,6 @@ const CHECKLIST_SECTIONS: ChecklistSection[] = [ { id: 'sr-4', label: 'Identify 10 scholarships to apply to senior year', type: 'task' }, ], }, - { - title: 'Understanding Aid Types', - items: [ - { id: 'at-1', label: 'Grants vs. loans vs. work-study', type: 'article' }, - { id: 'at-2', label: 'Federal vs. institutional vs. private aid', type: 'article' }, - { id: 'at-3', label: 'How the Student Aid Index (SAI) is calculated', type: 'article' }, - { id: 'at-4', label: 'Quiz: Financial aid fundamentals', type: 'quiz' }, - ], - }, { title: 'FAFSA Preparation', items: [ @@ -261,18 +262,18 @@ const Ring = ({ status, color }: { status: ChecklistItemStatus; color: string }) ═══════════════════════════════════════════════════════════════ */ // Aid Compare moved to Application Tracking, where it compares that list, and // Deadlines' FAFSA and CSS Profile dates to the top of Aid Tracker. -type TabId = 'overview' | 'scholarships-101' | 'scholarships' | 'scholarship-search' +type TabId = 'overview' | 'financial-aid-101' | 'scholarships' | 'scholarship-search' const FA_TABS: Array<{ id: TabId; label: string; icon: ReactNode }> = [ { id: 'overview', label: 'Overview', icon: I.overview }, - { id: 'scholarships-101', label: 'Scholarships 101', icon: I.article }, + { id: 'financial-aid-101', label: 'Financial Aid 101', icon: I.article }, { id: 'scholarship-search', label: 'Scholarship Engine', icon: I.sparkle }, { id: 'scholarships', label: 'Aid Tracker', icon: I.star }, ] const FA_TAB_IDS = FA_TABS.map((t) => t.id) /* ═══════════════════════════════════════════════════════════════ - CHECKLIST ITEMS — shared by Overview and Scholarships 101 + CHECKLIST ITEMS — shared by Overview and Financial Aid 101 ═══════════════════════════════════════════════════════════════ */ /** The item open for reading, and the status moves that come with it: * opening one starts it, and its button walks it to complete and back. */ @@ -324,9 +325,9 @@ const ChecklistProgress = ({ done, total, tour }: { done: number; total: number; ) /* ═══════════════════════════════════════════════════════════════ - TAB: SCHOLARSHIPS 101 + TAB: FINANCIAL AID 101 ═══════════════════════════════════════════════════════════════ */ -export const Scholarships101Tab = ({ progress, onToggle, activeId, onOpenContent }: { +export const FinancialAid101Tab = ({ progress, onToggle, activeId, onOpenContent }: { progress: ChecklistProgressMap onToggle: (itemId: string) => void /** The article being read, owned by the module so the sidebar can leave it. */ @@ -343,7 +344,7 @@ export const Scholarships101Tab = ({ progress, onToggle, activeId, onOpenContent contentMap={CHECKLIST_CONTENT_MAP} allIds={CHECKLIST_ALL_IDS} accentColor={MC} - backLabel="Back to Scholarships 101" + backLabel="Back to Financial Aid 101" onBack={() => reader.setActiveId(null)} onMarkComplete={reader.markComplete} onNavigate={(id) => reader.open(id, { replace: true })} @@ -353,9 +354,9 @@ export const Scholarships101Tab = ({ progress, onToggle, activeId, onOpenContent const done = CHECKLIST_ALL_IDS.filter((id) => reader.statusOf(id) === 'completed').length return (
-

Scholarships 101

+

Financial Aid 101

- Articles, quizzes and tasks on paying for college: how scholarships work and how to win them, the kinds of aid, the FAFSA, and net price calculators. + Articles, quizzes and tasks on paying for college: the kinds of aid, how scholarships work and how to win them, the FAFSA, and net price calculators.

@@ -391,7 +392,7 @@ interface OverviewTabProps { homeState: string | null aid: AidCollegesState onGoToTab: (tab: TabId) => void - /** Open one of Scholarships 101's items, to read. */ + /** Open one of Financial Aid 101's items, to read. */ onRead: (itemId: string) => void ownDates: OwnAidDates /** The student's grade, 9–12. */ @@ -1972,6 +1973,9 @@ const SchoolLine = ({ c, value, color, edit }: {
) +/** How many of a box's schools Aid Tracker shows before it's opened. */ +const PREVIEW_SCHOOLS = 3 + const FormNote = ({ children }: { children: ReactNode }) => (

{children}

) @@ -2046,42 +2050,50 @@ export function AidForms({ aid, gradeStartIdx, onSeeSchools, ownDates }: { : <>{aid.unresolved.length > 0 &&
}{rows} // On Overview the boxes don't open: they go to Aid Tracker, where they do. - const box = (id: 'fafsa' | 'css', color: string, title: string, dates: string, summary: string, body: ReactNode) => ( - setOpen(open === id ? null : id))}> - {body} - - ) + // There each shows its first few schools (soonest date, or most in need of + // the CSS Profile, first) and opens onto the rest and the notes. + const box = (id: 'fafsa' | 'css', color: string, title: string, dates: string, summary: string, rows: ReactNode[], note: ReactNode) => { + const opens = !onSeeSchools + return ( + setOpen(open === id ? null : id))} + preview={opens && !listState ? rows.slice(0, PREVIEW_SCHOOLS) : undefined} + more={opens ? (!listState && rows.length > PREVIEW_SCHOOLS ? `Show all ${rows.length} schools` : 'Show details') : undefined} + > + {schoolsBody(rows)} + {note} + + ) + } return (
{box('fafsa', FAFSA_TINT, 'FAFSA', `${fafsa.date <= now ? 'Opened' : fafsa.known ? 'Opens' : 'Opens by'} ${formatCollegeDate(fafsa.date)} · Closes ${formatCollegeDate(fafsaFederalDeadline(seniorFall))}`, fafsaSummary, - <> - {schoolsBody(byPriority.map((c) => ))} - - File by each school’s priority date to be first in line for its aid; the federal deadline comes much later. No date on file? Add it from the school’s aid page, or file as soon as the FAFSA opens to be safe.{' '} - studentaid.gov ↗ - - )} + byPriority.map((c) => ), + + File by each school’s priority date to be first in line for its aid; the federal deadline comes much later. No date on file? Add it from the school’s aid page, or file as soon as the FAFSA opens to be safe.{' '} + studentaid.gov ↗ + )} {box('css', CSS_TINT, 'CSS Profile', `${cssOpens <= now ? 'Open now' : `Opens by ${formatCollegeDate(cssOpens)}`} · Each school sets its own due date`, cssSummary, - <> - {schoolsBody(byCss.map(({ c, need }) => ( - - )))} - - Mostly private colleges use it to award their own aid. Unlike the FAFSA it charges a fee per school, which College Board waives for many lower-income families. A due date you add goes on your calendar.{' '} - College Board ↗ - - )} + byCss.map(({ c, need }) => ( + + )), + + Mostly private colleges use it to award their own aid. Unlike the FAFSA it charges a fee per school, which College Board waives for many lower-income families. A due date you add goes on your calendar.{' '} + College Board ↗ + )}
) } @@ -2128,9 +2140,9 @@ export default function FinancialAidModule({ open, onClose, year = 11, aside }: const [tab, setTab, routedPage, setPage] = useRoutedTab('Financial Aid', open, FA_TAB_IDS, 'overview') // Only an id the rendering tab owns: routedItem validates the tab but not // the item, so a stale or hand-edited URL could otherwise put an Overview - // id in Scholarships 101's reader, where indexOf is -1, the header reads + // id in Financial Aid 101's reader, where indexOf is -1, the header reads // "0 of 6" and both prev and next vanish. Articles all live here since #89. - const article = tab === 'scholarships-101' && routedPage && CHECKLIST_ALL_IDS.includes(routedPage) ? routedPage : null + const article = tab === 'financial-aid-101' && routedPage && CHECKLIST_ALL_IDS.includes(routedPage) ? routedPage : null // Aid Tracker's open scholarship is routed too. Unlike the Engine's scored // object it is a bare id resolved against the tracked list, so the URL can // rebuild it — which buys it the same exits the articles have and leaves the @@ -2412,7 +2424,7 @@ export default function FinancialAidModule({ open, onClose, year = 11, aside }: ? tracker.find((i) => i.id === scholarship)?.name : undefined // Routed, so the article it opens has the same exits as any other. - const read101 = (id: string) => { setTab('scholarships-101'); setPage(id) } + const read101 = (id: string) => { setTab('financial-aid-101'); setPage(id) } const saveAidPrefsOrSay = async (p: AidPrefs) => { if (!(await saveAidPrefs(p))) toast.error('Could not save your preferences — try again') } @@ -2421,7 +2433,7 @@ export default function FinancialAidModule({ open, onClose, year = 11, aside }: const content = tab === 'overview' ? : - tab === 'scholarships-101' ? : + tab === 'financial-aid-101' ? : tab === 'scholarships' ? switchTab('scholarship-search')} /> : void saveAidPrefsOrSay(p)} dismissals={dismissals} onOpenTracked={openTracked} year={year} /> diff --git a/web/src/components/moduleUI.tsx b/web/src/components/moduleUI.tsx index 005c2e1..79cad99 100644 --- a/web/src/components/moduleUI.tsx +++ b/web/src/components/moduleUI.tsx @@ -132,9 +132,11 @@ export const Callout = ({ icon, title, body, color, bg }: { icon: ReactNode; tit /** * A box of key dates: Financial Aid's FAFSA and CSS Profile, Application * Tracking's rounds. With `open` it expands onto `children`; without, it - * doesn't, and the click goes wherever those details live. + * doesn't, and the click goes wherever those details live. `preview` shows + * while it's closed, and `more` labels a toggle under it, so a box that opens + * looks like one. */ -export const DateBox = ({ color, title, dates, summary, open, onClick, children }: { +export const DateBox = ({ color, title, dates, summary, open, onClick, children, preview, more }: { color: string title: string dates: string @@ -142,22 +144,32 @@ export const DateBox = ({ color, title, dates, summary, open, onClick, children open?: boolean onClick: () => void children?: ReactNode + preview?: ReactNode + more?: string }) => ( // Longhands only, as in GuideRow: the shorthand would wipe the colored edge.
- {open &&
{children}
} + {open ?
{children}
+ : preview &&
{preview}
} + {more && open !== undefined && ( + + )}
) diff --git a/web/src/data/checklistContent.ts b/web/src/data/checklistContent.ts index f90c184..644623c 100644 --- a/web/src/data/checklistContent.ts +++ b/web/src/data/checklistContent.ts @@ -583,7 +583,7 @@ export const CHECKLIST_CONTENT: ChecklistContent[] = [ }, /* ───────────────────────────────────────────────────────────── - SECTION 3: Scholarships 101 — its own tab, in the content team's + SECTION 3: Scholarships — second in Financial Aid 101, in the content team's reading order (Edvifi Content, 2026-10-30) ───────────────────────────────────────────────────────────── */ { diff --git a/web/src/lib/hashRoute.test.ts b/web/src/lib/hashRoute.test.ts index b6a78a6..aab55da 100644 --- a/web/src/lib/hashRoute.test.ts +++ b/web/src/lib/hashRoute.test.ts @@ -107,7 +107,7 @@ describe('useRoutedTab', () => { }) it('keeps an item set in the same tick as the tab it belongs to', () => { // Financial Aid's Overview links into an article with - // `setTab('scholarships-101'); setPage(id)`. setTab clears the item, so + // `setTab('financial-aid-101'); setPage(id)`. setTab clears the item, so // this only works if the later setItem wins within the batch — if it did // not, every link from Overview would land on the tab and drop the // article it was meant to open.