From 0aee26158df195b27a8ec9cda2ca4f51cdaa7443 Mon Sep 17 00:00:00 2001 From: Danial Beg Date: Fri, 30 Oct 2026 19:37:46 -0700 Subject: [PATCH] Move the college list to Overview and open Status on a summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The student's list, with its map and cost box, sat at the top of Discover, which answered the wrong question there: Discover is for finding schools that are not on the list yet, so the list itself belongs on the module's front page. It moves to Overview, above the checklist, and its main link now goes to Discover to add more rather than back to Application Status. "+N more" still goes to the full list, since that is a different place to want to be. The Overview checklist is now titled Applications 101; the section inside it keeps the name Application Strategy, which would read oddly as a peer of Submission Workflow otherwise. Application Status opened straight into every school's row. It now opens on a summary — where each application stands, what is due next, the season's timeline, and the tasks shared across the list — with the rows one level in behind "See all N schools". A status chip on the summary opens the list already filtered by it. The list reuses the item slot in the URL that a school's page already used, under the id "all", so it gets a Back step and survives a refresh without any new routing. Two things fell out of that. The school page's Back went to the tab root, which is now the summary, so opening a school from the list and going back skipped past the list it came from; its own label already promised "All applications", so it points there. And the strip needed the ZIP geocode and effective profile that Discover had been keeping to itself, so those move into useCollegePrefs, where both callers share them — getSettings already dedupes the in-flight read and geocodeZip caches, so the second caller costs no request. The strip's own tests move with it, rendering the component directly rather than reaching it through Discover's feed. Discover's saved-list boost tests counted the strip's fetch as well as the boost's; only the boost fetches there now. --- .../components/ApplicationStatusTab.test.tsx | 45 +++++++-- web/src/components/ApplicationStatusTab.tsx | 55 +++++++++-- .../components/ApplicationTrackingModule.tsx | 13 ++- web/src/components/ApplicationsModuleTour.tsx | 8 +- .../components/CollegeDiscoverTab.test.tsx | 54 ++-------- web/src/components/CollegeDiscoverTab.tsx | 49 +++------- web/src/components/CollegeListMap.tsx | 2 +- web/src/components/ModuleOverviewTab.tsx | 6 ++ web/src/components/YourListStrip.test.tsx | 98 +++++++++++++++++++ web/src/components/YourListStrip.tsx | 31 +++--- web/src/lib/useCollegePrefs.ts | 33 ++++++- 11 files changed, 273 insertions(+), 121 deletions(-) create mode 100644 web/src/components/YourListStrip.test.tsx diff --git a/web/src/components/ApplicationStatusTab.test.tsx b/web/src/components/ApplicationStatusTab.test.tsx index 36efcf0..f9c823c 100644 --- a/web/src/components/ApplicationStatusTab.test.tsx +++ b/web/src/components/ApplicationStatusTab.test.tsx @@ -2,7 +2,7 @@ import { useState } from 'react' import { describe, it, expect, vi } from 'vitest' import { render, screen, within, fireEvent } from '@testing-library/react' import userEvent from '@testing-library/user-event' -import ApplicationStatusTab from './ApplicationStatusTab' +import ApplicationStatusTab, { ALL_SCHOOLS } from './ApplicationStatusTab' import { setSharedTask, tasksForEntry } from '../data/applicationTasks' import type { ApplicationEntry } from '../data/applicationsChecklist' @@ -24,7 +24,10 @@ const APPS = [ /** A school's row in the list (the timeline has its own button per school). */ const schoolRow = (name: string) => - screen.getAllByRole('button', { name: new RegExp(name) }).find((b) => b.classList.contains('ast-row'))! + screen.queryAllByRole('button', { name: new RegExp(name) }).find((b) => b.classList.contains('ast-row'))! + +/** The rows sit one level in from the landing summary. */ +const goToList = () => userEvent.click(screen.getByRole('button', { name: /See all \d+ schools?/ })) // A task with no date shows an "Add date" button, not an empty input: an // empty date box is a blank square that says nothing about what it is for. @@ -53,15 +56,24 @@ const renderTab = (apps = APPS, initialOpenId: string | null = null) => { } describe('ApplicationStatusTab', () => { - it('shows a summary, the shared tasks and one row per school', () => { + it('lands on a summary: status, next up and the shared tasks', () => { renderTab() expect(screen.getByRole('heading', { level: 2 })).toHaveTextContent('Your applications') expect(screen.getByRole('button', { name: /1 to submit/ })).toBeInTheDocument() expect(screen.getByText('Shared across your list')).toBeInTheDocument() expect(screen.getByText('Request teacher recommendations')).toBeInTheDocument() + expect(screen.getByRole('button', { name: /^Next up: Alpha College/ })).toBeInTheDocument() + // The rows themselves are one level in. + expect(schoolRow('Alpha College')).toBeUndefined() + expect(screen.getByRole('button', { name: /See all 2 schools/ })).toBeInTheDocument() + }) + + it('shows one row per school once the list is opened', async () => { + renderTab() + await goToList() + expect(screen.getByRole('heading', { level: 2 })).toHaveTextContent('Your schools') expect(schoolRow('Alpha College')).toBeInTheDocument() expect(schoolRow('Beta University')).toBeInTheDocument() - expect(screen.getByRole('button', { name: /^Next up: Alpha College/ })).toBeInTheDocument() // Per-school tasks stay on the school page. expect(screen.queryByText('Draft the supplemental essay(s)')).not.toBeInTheDocument() }) @@ -74,16 +86,18 @@ describe('ApplicationStatusTab', () => { it('opens a school page with its own checklist, and goes back', async () => { renderTab() + await goToList() await userEvent.click(schoolRow('Alpha College')) expect(screen.getByRole('heading', { name: 'Alpha College' })).toBeInTheDocument() expect(screen.getByText('Draft the supplemental essay(s)')).toBeInTheDocument() expect(screen.getAllByText('Shared with 1 other school').length).toBeGreaterThan(0) await userEvent.click(screen.getByText('← All applications')) - expect(screen.getByText('Shared across your list')).toBeInTheDocument() + expect(schoolRow('Alpha College')).toBeInTheDocument() }) it('routes a shared task ticked on a school page to every school', async () => { const { onSetShared, onUpdate } = renderTab() + await goToList() await userEvent.click(schoolRow('Alpha College')) const row = screen.getByText('Request teacher recommendations').parentElement! await userEvent.click(row.querySelector('button')!) @@ -111,6 +125,7 @@ describe('ApplicationStatusTab', () => { it('filters the school list from the status strip', async () => { renderTab([app('sc-1', 'Alpha College'), app('sc-2', 'Beta University', { status: 'accepted' })]) + await goToList() await userEvent.click(screen.getByRole('button', { name: /1 accepted/ })) expect(schoolRow('Beta University')).toBeInTheDocument() expect(schoolRow('Alpha College')).toBeUndefined() @@ -118,6 +133,14 @@ describe('ApplicationStatusTab', () => { expect(schoolRow('Alpha College')).toBeInTheDocument() }) + it('opens straight onto the full list when routed there', () => { + // What the module passes for "See all", and what a refresh on + // #/dashboard/application-tracking/status/all restores. + renderTab(APPS, ALL_SCHOOLS) + expect(screen.getByRole('heading', { level: 2 })).toHaveTextContent('Your schools') + expect(schoolRow('Alpha College')).toBeInTheDocument() + }) + it('opens straight onto a school when asked to', () => { renderTab(APPS, 'sc-2') expect(screen.getByRole('heading', { name: 'Beta University' })).toBeInTheDocument() @@ -125,6 +148,7 @@ describe('ApplicationStatusTab', () => { it('edits category and round from the school page', async () => { const { onUpdate } = renderTab() + await goToList() await userEvent.click(schoolRow('Alpha College')) await userEvent.selectOptions(screen.getByRole('combobox', { name: 'Reach, target or likely' }), 'reach') expect(onUpdate).toHaveBeenCalledWith('sc-1', { category: 'reach' }) @@ -134,6 +158,7 @@ describe('ApplicationStatusTab', () => { it('removes a school only after confirming', async () => { const { onRemove } = renderTab() + await goToList() await userEvent.click(schoolRow('Alpha College')) await userEvent.click(screen.getByText('Remove from my list')) expect(onRemove).not.toHaveBeenCalled() @@ -141,8 +166,9 @@ describe('ApplicationStatusTab', () => { expect(onRemove).toHaveBeenCalledWith('sc-1') }) - it('sorts schools still to submit ahead of decided ones', () => { + it('sorts schools still to submit ahead of decided ones', async () => { renderTab([app('sc-2', 'Beta University', { status: 'accepted' }), app('sc-1', 'Alpha College')]) + await goToList() const rows = screen.getAllByRole('button', { name: /Alpha College|Beta University/ }).filter((b) => b.classList.contains('ast-row')) expect(rows.map((r) => r.textContent?.match(/Alpha College|Beta University/)?.[0])).toEqual(['Alpha College', 'Beta University']) }) @@ -159,6 +185,7 @@ describe('ApplicationStatusTab', () => { const saved = app('sc-1', 'Alpha College', { deadlineType: 'RD' }) const withTasks = { ...saved, tasks: tasksForEntry(saved) } const { onUpdate } = renderTab([withTasks]) + await goToList() await userEvent.click(schoolRow('Alpha College')) await userEvent.selectOptions(screen.getByRole('combobox', { name: 'Application round' }), 'ED') const fields = onUpdate.mock.calls.at(-1)![1] @@ -168,6 +195,7 @@ describe('ApplicationStatusTab', () => { it('dates a per-school task on that school, and a shared task on every school', async () => { const { onUpdate, onSetSharedDue } = renderTab() + await goToList() await userEvent.click(schoolRow('Alpha College')) const essayBox = await openDateBox('Draft the supplemental essay(s)') fireEvent.focus(essayBox) @@ -192,6 +220,7 @@ describe('ApplicationStatusTab', () => { it('saves the date box once typing settles, not each in-between value', async () => { const { onUpdate } = renderTab() + await goToList() await userEvent.click(schoolRow('Alpha College')) const box = await openDateBox('Draft the supplemental essay(s)') onUpdate.mockClear() @@ -211,6 +240,7 @@ describe('ApplicationStatusTab', () => { const saved = app('sc-1', 'Alpha College') const withDue = { ...saved, tasks: tasksForEntry(saved).map((t) => (t.id === 'essays' ? { ...t, due: '2026-10-12' } : t)) } const { onUpdate } = renderTab([withDue]) + await goToList() await userEvent.click(schoolRow('Alpha College')) const box = await openSavedDate('Draft the supplemental essay(s)') fireEvent.focus(box) @@ -222,6 +252,7 @@ describe('ApplicationStatusTab', () => { it('saves the student\'s own deadline from the school page, and clears it when the round changes', async () => { const { onUpdate } = renderTab() + await goToList() await userEvent.click(schoolRow('Alpha College')) await userEvent.click(screen.getByRole('button', { name: "Add a due date for this school's deadline" })) const box = screen.getByLabelText("Due date for this school's deadline") @@ -239,6 +270,7 @@ describe('ApplicationStatusTab', () => { app('sc-2', 'Beta University', { category: 'reach' }), app('sc-3', 'Gamma Institute', { category: 'reach' }), ]) + await goToList() await userEvent.click(screen.getByRole('button', { name: 'Category' })) // Group headings (bold), not the category label inside each row. const headings = screen.getAllByText(/^(Reach|Target|Likely|No category)$/).filter((el) => el.tagName === 'B').map((el) => el.textContent) @@ -251,6 +283,7 @@ describe('ApplicationStatusTab', () => { const saved = app('sc-1', 'Alpha College') const withDue = { ...saved, tasks: tasksForEntry(saved).map((t) => (t.id === 'essays' ? { ...t, due: '2026-10-12' } : t)) } const { onUpdate } = renderTab([withDue]) + await goToList() await userEvent.click(schoolRow('Alpha College')) const box = await openSavedDate('Draft the supplemental essay(s)') fireEvent.focus(box) diff --git a/web/src/components/ApplicationStatusTab.tsx b/web/src/components/ApplicationStatusTab.tsx index ab767e6..444327b 100644 --- a/web/src/components/ApplicationStatusTab.tsx +++ b/web/src/components/ApplicationStatusTab.tsx @@ -54,6 +54,12 @@ const STAGES: Array<{ key: StageKey; label: string; color: string; statuses: App { key: 'withdrawn', label: 'withdrawn', color: '#7A6D5C', statuses: ['withdrawn'] }, ] +/** The open-item id that means "the whole school list" rather than one school. + * It shares the slot a collegeId uses, so the list gets URL state and a Back + * step for free. Ids are `sc-` or a slug and the school lookup + * runs first, so only a school whose slug is literally "all" could shadow it. */ +export const ALL_SCHOOLS = 'all' + const MS_PER_DAY = 86400000 const daysUntil = (d: Date, now: Date) => Math.ceil((d.getTime() - now.getTime()) / MS_PER_DAY) @@ -258,7 +264,7 @@ export default function ApplicationStatusTab({ deadline={deadlineFor.get(openApp.collegeId) ?? null} daysLeft={daysFor(openApp)} sharedCounts={sharedCounts} - onBack={() => onOpen(null)} + onBack={() => onOpen(ALL_SCHOOLS)} onStatus={(s) => setStatus(openApp, s)} onCategory={(category) => onUpdate(openApp.collegeId, { category })} onDeadlineType={(deadlineType) => { @@ -279,6 +285,10 @@ export default function ApplicationStatusTab({ } + // openId is null on the landing summary, ALL_SCHOOLS on the full list, and + // a collegeId on one school's page (handled above). + const showList = openId === ALL_SCHOOLS + const stages = STAGES.map((st) => ({ ...st, n: apps.filter((a) => st.statuses.includes(a.status)).length })).filter((st) => st.n > 0) const activeFilter = stages.find((st) => st.key === filter) ?? null @@ -313,10 +323,18 @@ export default function ApplicationStatusTab({ return ( + {showList && ( + + )}

- Your applications + {showList ? 'Your schools' : 'Your applications'}

{/* status strip — each count filters the school list below */} {stages.length > 0 && ( @@ -326,7 +344,7 @@ export default function ApplicationStatusTab({ return (
- {next && nextApp && nextDays != null && ( + {!showList && next && nextApp && nextDays != null && (
- {timeline.length > 0 && ( + {!showList && timeline.length > 0 && (
)} {/* shared tasks */} - {shared.length > 0 && ( + {!showList && shared.length > 0 && (
Shared across your list @@ -385,13 +403,18 @@ export default function ApplicationStatusTab({
)} - {/* schools */} + {/* schools — one level in from the landing summary */} + {showList && (
+ {/* The heading above already says "Your schools", so this line only + earns its place when a filter is narrowing what is below it. */} - {activeFilter ? `Your schools · ${activeFilter.label}` : 'Your schools'} {activeFilter && ( - + <> + {activeFilter.label} + + )}
@@ -478,6 +501,20 @@ export default function ApplicationStatusTab({
))}
+ )} + + {!showList && ( + + )} {confetti}
diff --git a/web/src/components/ApplicationTrackingModule.tsx b/web/src/components/ApplicationTrackingModule.tsx index 7b2d51e..5d6ca65 100644 --- a/web/src/components/ApplicationTrackingModule.tsx +++ b/web/src/components/ApplicationTrackingModule.tsx @@ -36,11 +36,12 @@ import { collegeSubtitle, fetchSavedColleges } from '../lib/collegeSearch' import ApplicationsModuleTour, { type ApplicationsTabId } from './ApplicationsModuleTour' import ModuleTabNav from './ModuleTabNav' import ModuleOverviewTab from './ModuleOverviewTab' +import YourListStrip from './YourListStrip' import ModuleShell from './ModuleShell' import CollegeDiscoverTab from './CollegeDiscoverTab' import AidCompare from './AidCompare' import { FEATURES } from '../lib/features' -import ApplicationStatusTab from './ApplicationStatusTab' +import ApplicationStatusTab, { ALL_SCHOOLS } from './ApplicationStatusTab' import FeeWaiverNotice from './FeeWaiverNotice' import { feeWaiverEligibility, shouldShowFeeWaiverNotice, FEE_WAIVER_NOTICE_KEY } from '../lib/feeWaivers' import { initialTasksFor, isTwoYearOrTrade, setSharedTask, updateSharedTask } from '../data/applicationTasks' @@ -49,6 +50,7 @@ import { projectToMap } from '../lib/mapProjection' import { domainOf } from '../lib/collegeLogo' import { schoolDisplay } from '../lib/schoolDisplay' import { routedItem, routedTab, useRoutedTab } from '../lib/hashRoute' +import { useCollegePrefs } from '../lib/useCollegePrefs' const MC = MODULE_COLORS.applications const MODULE_NAME = 'applications' @@ -112,12 +114,15 @@ export default function ApplicationTrackingModule({ open, onClose, onEditIncome, // A tab named in the URL (back/forward, or a refresh) wins over the default. if (open) { setTab(routedTab('Application Tracking', TAB_IDS) ?? 'status'); setSchool(routedItem('Application Tracking', TAB_IDS)) } } - // From Discover's list strip: a school's page, or the list itself. + // From the Overview list strip: a school's page, or the whole list. const openInStatus = useCallback((collegeId: string | null) => { setTab('status'); setSchool(collegeId) }, [setTab, setSchool]) // Dismissal persists via mark_intro_seen, but that round-trips through a // profile refresh; track it locally so the banner goes away on the click. const [feeWaiverDismissed, setFeeWaiverDismissed] = useState(false) const { progress, handleToggle, handleMarkComplete } = useModuleChecklist(MODULE_NAME, open) + // Shared with Discover, which calls the same hook; getSettings dedupes the + // in-flight read, so the second caller costs no extra request. + const { origin, effectiveProfile } = useCollegePrefs(open) const toast = useToast() // Shared with the dashboard and the deadline panels rather than loaded // again here: the list persists as one whole array, so a second copy meant @@ -221,9 +226,9 @@ export default function ApplicationTrackingModule({ open, onClose, onEditIncome, && shouldShowFeeWaiverNotice(incomeLevel, profile?.settings?.intros_seen) const content = - tab === 'overview' ? : + tab === 'overview' ? switchTab('discover')} onSeeAll={() => openInStatus(ALL_SCHOOLS)} />} /> : tab === 'aid-compare' && FEATURES.aidCompare ? a.collegeId)} accent={MC} /> : - tab === 'discover' ? openInStatus(null)} onRemove={handleRemoveApp} /> : + tab === 'discover' ? : switchTab('discover')} apps={apps} onUpdate={handleUpdateApp} onRemove={handleRemoveApp} onSetShared={handleSetSharedTask} onSetSharedDue={handleSetSharedDue} gradeStartIdx={profile?.grade_start_idx} openId={school} onOpen={setSchool} colleges={collegeRows} /> const openApp = school ? apps.find((a) => a.collegeId === school) : undefined diff --git a/web/src/components/ApplicationsModuleTour.tsx b/web/src/components/ApplicationsModuleTour.tsx index eb43809..715fdb1 100644 --- a/web/src/components/ApplicationsModuleTour.tsx +++ b/web/src/components/ApplicationsModuleTour.tsx @@ -15,14 +15,14 @@ const STEPS: TourStep[] = [ selector: '[data-tour="sidebar"]', pad: 8, title: 'Module Navigation', - desc: 'Three sections: the strategy checklist, Discover (get matched to best-fit colleges and build your list), and a status tracker for each application.', + desc: 'Three sections: Applications 101 and your college list, Discover (get matched to best-fit colleges and add to your list), and a status tracker for each application.', keepClear: ['sidebar'], }, { selector: '[data-tour="tab-overview"]', pad: 6, title: 'Overview', - desc: 'Articles and tasks covering list-building, ED vs. EA strategy, the submission workflow, and what happens after you submit.', + desc: 'Your college list, pinned on a map, over articles and tasks covering list-building, ED vs. EA strategy, the submission workflow, and what happens after you submit.', switchTab: 'overview', keepClear: ['sidebar', 'content'], }, @@ -30,7 +30,7 @@ const STEPS: TourStep[] = [ selector: '[data-tour="tab-discover"]', pad: 6, title: 'Discover', - desc: 'Get matched across ~6,300 colleges — scored for how well each fits you on cost, major, size, and location, with a warm sense of your admission odds. Includes local community-college and transfer paths. Your list sits at the top, pinned on a map, and fills in as you add schools.', + desc: 'Get matched across ~6,300 colleges — scored for how well each fits you on cost, major, size, and location, with a warm sense of your admission odds. Includes local community-college and transfer paths. Anything you add shows up on your list back in Overview.', switchTab: 'discover', keepClear: ['sidebar', 'content'], }, @@ -38,7 +38,7 @@ const STEPS: TourStep[] = [ selector: '[data-tour="tab-status"]', pad: 6, title: 'Application Status', - desc: 'Track each application from "not started" through submission and into decisions. Open a school to set its round, work through its tasks, or take it off your list.', + desc: 'Opens on a summary: where every application stands, what is due next, and the tasks shared across your list. Open the full list to reach one school and set its round, work through its tasks, or take it off your list.', switchTab: 'status', keepClear: ['sidebar', 'content'], }, diff --git a/web/src/components/CollegeDiscoverTab.test.tsx b/web/src/components/CollegeDiscoverTab.test.tsx index d560c6a..33a489f 100644 --- a/web/src/components/CollegeDiscoverTab.test.tsx +++ b/web/src/components/CollegeDiscoverTab.test.tsx @@ -59,7 +59,9 @@ vi.mock('../lib/collegeSearch', async (importOriginal) => ({ fetchSavedColleges: vi.fn(async () => new Map([['sc-1', H.SAMPLE[0]]])), })) vi.mock('../lib/useCollegePrefs', () => ({ - useCollegePrefs: () => ({ prefs: H.prefs, savePrefs, loaded: true, studentProfile: H.studentProfile }), + // geocodeZip is mocked to null above, so the real hook's effectiveProfile + // would be studentProfile unchanged. + useCollegePrefs: () => ({ prefs: H.prefs, savePrefs, loaded: true, studentProfile: H.studentProfile, zip: null, origin: null, geoState: null, effectiveProfile: H.studentProfile }), })) const FLAGSHIP_ENTRY: ApplicationEntry = { @@ -67,7 +69,7 @@ const FLAGSHIP_ENTRY: ApplicationEntry = { } const renderTab = (over: Partial> = {}) => { - const props = { open: true, apps: [], listLoaded: true, onAdd: vi.fn(), onOpenSchool: vi.fn(), onManageList: vi.fn(), onRemove: vi.fn(), ...over } + const props = { open: true, apps: [], listLoaded: true, onAdd: vi.fn(), onRemove: vi.fn(), ...over } render() return props } @@ -128,44 +130,6 @@ describe('CollegeDiscoverTab', () => { expect(await screen.findByRole('dialog', { name: /state flagship university/i })).toBeInTheDocument() }) - it('shows an empty list strip until a school is added', () => { - renderTab() - expect(screen.getByText('Your list is empty.')).toBeInTheDocument() - }) - - it('shows the list with its map and average costs', async () => { - renderTab({ apps: [FLAGSHIP_ENTRY] }) - expect(screen.getByText('Your list · 1 school')).toBeInTheDocument() - expect(screen.getByRole('img', { name: /us map of your college list/i })).toBeInTheDocument() - expect(screen.getByText('Avg. net price')).toBeInTheDocument() - // cost_of_attendance_cents 3,000,000 → $30,000/yr - expect(await screen.findByText('$30,000/yr')).toBeInTheDocument() - // Where: one school, in the student's home state (CA). - expect(screen.getByText('1 state')).toBeInTheDocument() - expect(screen.getByText(/in California/)).toBeInTheDocument() - }) - - it('shows a school in the cost box from its logo, then opens its application', async () => { - const user = userEvent.setup() - const { onOpenSchool, onManageList } = renderTab({ apps: [FLAGSHIP_ENTRY] }) - await user.click(screen.getByRole('button', { name: 'Show State Flagship University' })) - expect(await screen.findByText('Cost of attendance')).toBeInTheDocument() - expect(screen.getByText('Net price for you')).toBeInTheDocument() - await user.click(screen.getByRole('button', { name: /open its application/i })) - expect(onOpenSchool).toHaveBeenCalledWith('sc-1') - await user.click(screen.getByRole('button', { name: /manage in application status/i })) - expect(onManageList).toHaveBeenCalled() - }) - - it('hides the map when the strip is collapsed', async () => { - const user = userEvent.setup() - renderTab({ apps: [FLAGSHIP_ENTRY] }) - await user.click(screen.getByRole('button', { name: /hide map/i })) - expect(screen.queryByRole('img', { name: /us map of your college list/i })).not.toBeInTheDocument() - await user.click(screen.getByRole('button', { name: /show map/i })) - expect(screen.getByRole('img', { name: /us map of your college list/i })).toBeInTheDocument() - }) - it('tags each pick with why it was picked', () => { renderTab() expect(screen.getByText('Picked for you')).toBeInTheDocument() @@ -371,9 +335,9 @@ describe('CollegeDiscoverTab — region', () => { }) describe('the saved-list boost', () => { - const base = { onAdd: vi.fn(), onOpenSchool: vi.fn(), onManageList: vi.fn(), onRemove: vi.fn() } - // YourListStrip fetches the same rows for itself, once per list it shows; - // a second call for the same list is the boost's. + const base = { onAdd: vi.fn(), onRemove: vi.fn() } + // Since the list strip moved to Overview, the boost is the only thing in + // Discover that fetches these rows — so every call here is the boost's. const fetched = () => vi.mocked(fetchSavedColleges).mock.calls.map((c) => c[0]) beforeEach(() => vi.mocked(fetchSavedColleges).mockClear()) @@ -381,13 +345,13 @@ describe('CollegeDiscoverTab — region', () => { const { rerender } = render() expect(fetched()).toEqual([]) rerender() - expect(fetched()).toEqual([['sc-1'], ['sc-1']]) // the strip's, then the boost's + expect(fetched()).toEqual([['sc-1']]) // the boost's }) it('keeps the snapshot when a school is added, even the first', () => { const { rerender } = render() rerender() - expect(fetched()).toEqual([['sc-1']]) // the strip's only + expect(fetched()).toEqual([]) // the boost did not re-take it }) }) }) diff --git a/web/src/components/CollegeDiscoverTab.tsx b/web/src/components/CollegeDiscoverTab.tsx index 57efff8..b90d6a0 100644 --- a/web/src/components/CollegeDiscoverTab.tsx +++ b/web/src/components/CollegeDiscoverTab.tsx @@ -1,12 +1,15 @@ /** * Discover tab (Application Tracking module). First-run gate → onboarding form; - * then the student's list (map + balance, see YourListStrip), a "Picked for - * you" row — a transfer path to a dream school, an affordable nearby option, - * and strong-fit likely admits, each tagged and colored by why it was picked — - * and fit-led match cards with a pathway filter. + * then a "Picked for you" row — a transfer path to a dream school, an + * affordable nearby option, and strong-fit likely admits, each tagged and + * colored by why it was picked — and fit-led match cards with a pathway filter. + * + * The student's own list is NOT here: it lives in the module Overview, so this + * tab is only about finding what is not on it yet. + * * Fit and admission chance are shown as SEPARATE signals; admission is a warm - * band and fit a word (never a bare %). The band is - * colored like the list category it becomes when added (reach / match / safety). + * band and fit a word (never a bare %). The band is colored like the list + * category it becomes when added (reach / match / safety). * * Community colleges are ranked by ZIP-radius proximity to the student * (geocoded from their profile ZIP); the home state is derived from the ZIP if @@ -15,7 +18,6 @@ import { useCallback, useMemo, useState, useEffect, memo, type CSSProperties } from 'react' import { C, fitScoreLabel } from '../lib/designTokens' import { BAND_COLOR } from '../data/applicationsChecklist' -import { useAuth } from '../contexts/AuthContext' import { scoreCollegeForProfile, BAND_META, @@ -37,10 +39,8 @@ import { type CollegeMatch, type AdmissionBand, type PathwayType, - type GeoPoint, type StudentCollegeProfile, } from '../lib/collegeMatch' -import { geocodeZip } from '../lib/geoZip' import { useCollegePrefs } from '../lib/useCollegePrefs' import { useColleges } from '../lib/useColleges' import { searchCollegesDb, fetchSavedColleges } from '../lib/collegeSearch' @@ -50,7 +50,6 @@ import { CollegeLogo } from './moduleUI' import CollegePrefsForm from './CollegePrefsForm' import { stateFromZip } from '../data/aidPrograms' import CollegeDetailModal from './CollegeDetailModal' -import YourListStrip from './YourListStrip' import { STATE_NAMES } from '../data/usStatesGeo' import type { ApplicationEntry } from '../data/applicationsChecklist' @@ -340,25 +339,19 @@ export default function CollegeDiscoverTab({ apps, listLoaded, onAdd, - onOpenSchool, - onManageList, onRemove, }: { open: boolean - /** The student's list, shown in the strip at the top. */ + /** The student's list, so a card can show it is already on it. */ apps: ApplicationEntry[] /** The list has been read (it may be empty). Until then `apps` is a placeholder. */ listLoaded: boolean onAdd: (college: College, band: AdmissionBand) => void - /** Open one school's page in Application Status. */ - onOpenSchool: (collegeId: string) => void - onManageList: () => void /** Take a school off the list (from a card's "✓ On your list"). */ onRemove: (collegeId: string) => void }) { const existingIds = useMemo(() => apps.map((a) => a.collegeId), [apps]) - const { profile } = useAuth() - const { prefs, savePrefs, loaded, studentProfile } = useCollegePrefs(open) + const { prefs, savePrefs, loaded, zip, origin, effectiveProfile } = useCollegePrefs(open) const [editing, setEditing] = useState(false) // Any combination of 4-year / Community / Trade; none chosen means all. const [pathways, setPathways] = useState>(new Set()) @@ -398,25 +391,6 @@ export default function CollegeDiscoverTab({ return () => { document.removeEventListener('mousedown', onDown); document.removeEventListener('keydown', onKey, true) } }, []) - // Geocode the student's ZIP for community-college proximity; derive home state from it. - const zip = profile?.demographics?.zipcode - const [origin, setOrigin] = useState(null) - const [geoState, setGeoState] = useState(null) - useEffect(() => { - let cancelled = false - geocodeZip(zip).then((loc) => { - if (cancelled || !loc) return - setOrigin({ lat: loc.lat, lng: loc.lng }) - setGeoState(loc.state || null) - }) - return () => { cancelled = true } - }, [zip]) - - // Effective profile: fall back to the ZIP-derived state so local CCs load without an explicit pick. - const effectiveProfile: StudentCollegeProfile = useMemo( - () => ({ ...studentProfile, homeState: studentProfile.homeState ?? geoState }), - [studentProfile, geoState], - ) // Marked in the list rather than preselected: a student browsing Discover is // often looking for somewhere they are not. const homeRegion = searchRegionOf(effectiveProfile.homeState) @@ -680,7 +654,6 @@ export default function CollegeDiscoverTab({

- {!effectiveProfile.homeState && (
diff --git a/web/src/components/CollegeListMap.tsx b/web/src/components/CollegeListMap.tsx index 9fa9273..80e4aed 100644 --- a/web/src/components/CollegeListMap.tsx +++ b/web/src/components/CollegeListMap.tsx @@ -1,6 +1,6 @@ /** * CollegeListMap — geographic view of the student's college list, shown in the - * "Your list" strip at the top of Discover. + * "Your list" strip at the top of the module Overview. * * Read-only US map (baked Albers paths). Each school on the list is a pin at its * real location: coordinates are projected at add-time and stored on the list diff --git a/web/src/components/ModuleOverviewTab.tsx b/web/src/components/ModuleOverviewTab.tsx index cd50dfb..91c44f4 100644 --- a/web/src/components/ModuleOverviewTab.tsx +++ b/web/src/components/ModuleOverviewTab.tsx @@ -38,6 +38,10 @@ interface Props { * passed down, so every panel shares the one set of handlers rather than * each module loading its own copy of the student's dates. */ aside?: ReactNode + /** Rendered above the title, inside the main column. Applications puts the + * student's college list and map here, so the module's front page opens on + * what they have before it teaches what to do next. */ + before?: ReactNode } export default function ModuleOverviewTab({ @@ -51,6 +55,7 @@ export default function ModuleOverviewTab({ accent, title, subtitle, + before, itemTypeIcon, aside, }: Props) { @@ -81,6 +86,7 @@ export default function ModuleOverviewTab({ return (
+ {before}

{title}

{subtitle} diff --git a/web/src/components/YourListStrip.test.tsx b/web/src/components/YourListStrip.test.tsx new file mode 100644 index 0000000..73300cd --- /dev/null +++ b/web/src/components/YourListStrip.test.tsx @@ -0,0 +1,98 @@ +/** + * The strip moved from Discover to the module Overview, so its own coverage + * moved here with it and now renders the component directly rather than + * reaching it through Discover's feed. + */ +import { describe, it, expect, vi } from 'vitest' +import { render, screen } from '@testing-library/react' +import userEvent from '@testing-library/user-event' +import YourListStrip from './YourListStrip' +import type { College, StudentCollegeProfile } from '../lib/collegeMatch' +import type { ApplicationEntry } from '../data/applicationsChecklist' + +const H = vi.hoisted(() => { + // Only the fields the strip reads: where the pin goes, what the cost box + // shows, and enough for the fit score. The cast keeps the other ~40 columns + // of the row out of a test that never looks at them. + const FLAGSHIP = { + id: 'id-state_flagship', scorecard_id: 1, name: 'State Flagship University', slug: 'state_flagship', + institution_type: '4yr', city: 'Testville', state: 'CA', region: 'West', ownership: 'public', + locale: 'city', latitude: 34, longitude: -118, size: 9000, admit_rate: 0.6, + sat_reading_25: 550, sat_reading_75: 650, sat_math_25: 560, sat_math_75: 660, act_25: 24, act_75: 30, + avg_net_price_cents: 1200000, net_price_by_income: { '48k_75k': 900000 }, + cost_of_attendance_cents: 3000000, programs: { engineering: 0.2 }, grad_rate: 0.8, + median_earnings_10yr_cents: 6000000, pell_pct: 0.3, source: 'scorecard', status: 'published', + } as unknown as College + return { FLAGSHIP } +}) + +vi.mock('../lib/supabase', () => ({ supabase: {} })) +vi.mock('../lib/collegeSearch', async (importOriginal) => ({ + ...(await importOriginal()), + fetchSavedColleges: vi.fn(async () => new Map([['sc-1', H.FLAGSHIP]])), +})) + +const PROFILE: StudentCollegeProfile = { + gpa: 3.6, satTotal: 1300, act: null, intendedFields: ['engineering'], familyIncomeCents: 6000000, + homeState: 'CA', prefSize: null, prefSettings: null, prefOwnership: 'either', + prefMaxDistance: 'anywhere', openToTransfer: true, openToTrade: false, +} + +const FLAGSHIP_ENTRY: ApplicationEntry = { + collegeId: 'sc-1', name: 'State Flagship University', category: 'match', + deadlineType: 'RD', status: 'not-started', state: 'CA', +} + +const renderStrip = (apps: ApplicationEntry[] = []) => { + const onOpenSchool = vi.fn(), onDiscover = vi.fn(), onSeeAll = vi.fn() + render() + return { onOpenSchool, onDiscover, onSeeAll } +} + +describe('YourListStrip', () => { + it('shows an empty strip until a school is added, pointing at Discover', async () => { + const user = userEvent.setup() + const { onDiscover } = renderStrip() + expect(screen.getByText('Your list is empty.')).toBeInTheDocument() + await user.click(screen.getByRole('button', { name: /discover colleges/i })) + expect(onDiscover).toHaveBeenCalled() + }) + + it('shows the list with its map and average costs', async () => { + renderStrip([FLAGSHIP_ENTRY]) + expect(screen.getByText('Your list · 1 school')).toBeInTheDocument() + expect(screen.getByRole('img', { name: /us map of your college list/i })).toBeInTheDocument() + expect(screen.getByText('Avg. net price')).toBeInTheDocument() + // cost_of_attendance_cents 3,000,000 → $30,000/yr + expect(await screen.findByText('$30,000/yr')).toBeInTheDocument() + // Where: one school, in the student's home state (CA). + expect(screen.getByText('1 state')).toBeInTheDocument() + expect(screen.getByText(/in California/)).toBeInTheDocument() + }) + + it('shows a school in the cost box from its logo, then opens its application', async () => { + const user = userEvent.setup() + const { onOpenSchool } = renderStrip([FLAGSHIP_ENTRY]) + await user.click(screen.getByRole('button', { name: 'Show State Flagship University' })) + expect(await screen.findByText('Cost of attendance')).toBeInTheDocument() + expect(screen.getByText('Net price for you')).toBeInTheDocument() + await user.click(screen.getByRole('button', { name: /open its application/i })) + expect(onOpenSchool).toHaveBeenCalledWith('sc-1') + }) + + it('sends the main link to Discover, not to Application Status', async () => { + const user = userEvent.setup() + const { onDiscover } = renderStrip([FLAGSHIP_ENTRY]) + await user.click(screen.getByRole('button', { name: /discover colleges/i })) + expect(onDiscover).toHaveBeenCalled() + }) + + it('hides the map when the strip is collapsed', async () => { + const user = userEvent.setup() + renderStrip([FLAGSHIP_ENTRY]) + await user.click(screen.getByRole('button', { name: /hide map/i })) + expect(screen.queryByRole('img', { name: /us map of your college list/i })).not.toBeInTheDocument() + await user.click(screen.getByRole('button', { name: /show map/i })) + expect(screen.getByRole('img', { name: /us map of your college list/i })).toBeInTheDocument() + }) +}) diff --git a/web/src/components/YourListStrip.tsx b/web/src/components/YourListStrip.tsx index e8aa053..bd7f0e1 100644 --- a/web/src/components/YourListStrip.tsx +++ b/web/src/components/YourListStrip.tsx @@ -1,13 +1,18 @@ /** - * YourListStrip — the student's college list, compact, at the top of Discover. + * YourListStrip — the student's college list, compact, at the top of Overview. * - * Replaces the old College List tab. The list is built here, so it lives here: - * a map of where the schools are, the reach / match / safety balance, a logo + * Replaces the old College List tab. It sits on Overview rather than Discover + * because it answers "what have I got so far", which is the question the + * module's front page is for; Discover is for finding what isn't there yet. + * A map of where the schools are, the reach / match / safety balance, a logo * per school, and a cost box. The box shows the list's average net price and * sticker price; hovering or clicking a school (logo or pin) swaps it for that * school's fit, net price and cost of attendance, with a link to its page in * Application Status (where category, round and removal live). Collapses to * one line for browsing. + * + * Two ways out, and they are different places: the main link goes to Discover + * to add more, "+N more" goes to the full list in Application Status. */ import { useEffect, useMemo, useState, type ReactNode } from 'react' @@ -78,7 +83,8 @@ export default function YourListStrip({ profile, origin, onOpenSchool, - onManage, + onDiscover, + onSeeAll, brief = false, }: { apps: ApplicationEntry[] @@ -87,8 +93,10 @@ export default function YourListStrip({ origin: GeoPoint | null /** Open one school's page in Application Status. */ onOpenSchool: (collegeId: string) => void - /** Go to Application Status. */ - onManage: () => void + /** Go to Discover, to add more schools. */ + onDiscover: () => void + /** Go to the full school list in Application Status. */ + onSeeAll: () => void /** The list was empty when this visit began: keep to one line as schools * are added, until the student asks for more. */ brief?: boolean @@ -148,7 +156,8 @@ export default function YourListStrip({ if (apps.length === 0) { return (

- Your list is empty. Schools you add below land here, pinned on a map. + Your list is empty. Schools you add land here, pinned on a map.{' '} +
) } @@ -158,7 +167,7 @@ export default function YourListStrip({
Your list · {apps.length} {apps.length === 1 ? 'school' : 'schools'} - +
) } @@ -342,7 +351,7 @@ export default function YourListStrip({ ) })} {apps.length > maxLogos && ( - )} @@ -353,8 +362,8 @@ export default function YourListStrip({ const footer = (
{note ?? ''} -
) diff --git a/web/src/lib/useCollegePrefs.ts b/web/src/lib/useCollegePrefs.ts index 148ac01..1bd17d4 100644 --- a/web/src/lib/useCollegePrefs.ts +++ b/web/src/lib/useCollegePrefs.ts @@ -2,12 +2,18 @@ * College Match onboarding prefs, persisted to * settings.module_data.applications.collegePrefs, plus the derived engine input * (StudentCollegeProfile) built from the student's existing demographics + prefs. + * + * The ZIP geocode lives here rather than in Discover because the college list + * is now shown in two places (Discover's feed and the Overview strip) and both + * need the same home state and origin. geocodeZip caches in memory and + * localStorage, so the second caller costs nothing. */ -import { useCallback, useMemo } from 'react' +import { useCallback, useEffect, useMemo, useState } from 'react' import { useAuth } from '../contexts/AuthContext' import { useToast } from '../contexts/ToastContext' import { useModuleValue } from './useModuleState' -import { buildStudentProfile, DEFAULT_COLLEGE_PREFS, type CollegePrefs } from './collegeMatch' +import { geocodeZip } from './geoZip' +import { buildStudentProfile, DEFAULT_COLLEGE_PREFS, type CollegePrefs, type GeoPoint, type StudentCollegeProfile } from './collegeMatch' const MODULE_NAME = 'applications' const PREFS_KEY = 'collegePrefs' @@ -28,5 +34,26 @@ export function useCollegePrefs(open: boolean) { }, [save, toast]) const demographics = profile?.demographics ?? null const studentProfile = useMemo(() => buildStudentProfile(demographics, prefs), [demographics, prefs]) - return { prefs, savePrefs, loaded, studentProfile } + + // Geocode the student's ZIP for community-college proximity; derive home state from it. + const zip = demographics?.zipcode + const [origin, setOrigin] = useState(null) + const [geoState, setGeoState] = useState(null) + useEffect(() => { + let cancelled = false + geocodeZip(zip).then((loc) => { + if (cancelled || !loc) return + setOrigin({ lat: loc.lat, lng: loc.lng }) + setGeoState(loc.state || null) + }) + return () => { cancelled = true } + }, [zip]) + + // Fall back to the ZIP-derived state so local CCs load without an explicit pick. + const effectiveProfile: StudentCollegeProfile = useMemo( + () => ({ ...studentProfile, homeState: studentProfile.homeState ?? geoState }), + [studentProfile, geoState], + ) + + return { prefs, savePrefs, loaded, studentProfile, zip, origin, geoState, effectiveProfile } }