// @ts-check import { test, expect } from '@playwright/test'; import { loadTestUser } from '../utils/testUser.js'; const SCHOOL = 'Alabama A & M University'; const PROGRAM = 'Agriculture, General.'; const DEGREE = "Bachelor's Degree"; async function fillDateField(ctrl, iso = '2027-06-01', us = '06/01/2027') { const type = (await ctrl.getAttribute('type')) || ''; if (type.toLowerCase() === 'date') { await ctrl.fill(iso); } else { await ctrl.scrollIntoViewIfNeeded(); await ctrl.click({ force: true }); await ctrl.fill(''); await ctrl.type(us, { delay: 15 }); } } async function commitAutosuggest(page, input, text) { await input.click(); await input.fill(text); await page.keyboard.press('ArrowDown').catch(() => {}); await page.keyboard.press('Enter').catch(() => {}); await input.blur(); } test.describe('@p1 College-Profile (45c)', () => { test.setTimeout(20000); test('Create new college plan from list (with link-to-career prompt) → save', async ({ page, request }) => { const u = loadTestUser(); // Premium gate await page.route( /\/api\/user-profile\?fields=.*(firstname|is_premium|is_pro_premium).*/i, r => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ firstname: 'Tester', is_premium: 1, is_pro_premium: 0 }) }) ); // Seed a minimal Career Profile (needed for the prompt dropdown) const scen = await request.post('/api/premium/career-profile', { data: { career_name: 'Teaching Assistants, Postsecondary', status: 'planned', start_date: '2025-09-01' } }); const { career_profile_id } = await scen.json(); // Deterministic autosuggest + degree + tuition await page.route(/\/api\/schools\/suggest\?*/i, async route => { await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify([{ name: 'Alabama A & M University', unitId: 100654 }]) }); }); await page.route(/\/api\/programs\/suggest\?*/i, async route => { await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify([{ program: 'Agriculture, General.' }]) }); }); await page.route(/\/api\/programs\/types\?*/i, async route => { await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ types: ["Bachelor's Degree"] }) }); }); await page.route(/\/api\/tuition\/estimate\?*/i, async route => { await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ estimate: 17220 }) }); }); // Accept POST save await page.route('**/api/premium/college-profile', async route => { if (route.request().method() === 'POST') { await route.fulfill({ status: 200, body: JSON.stringify({ ok: true }) }); } else { await route.fallback(); } }); // Sign in await page.context().clearCookies(); await page.goto('/signin', { waitUntil: 'domcontentloaded' }); await page.getByPlaceholder('Username', { exact: true }).fill(u.username); await page.getByPlaceholder('Password', { exact: true }).fill(u.password); await page.getByRole('button', { name: /^Sign In$/ }).click(); await page.waitForURL('**/signin-landing**', { timeout: 15000 }); // List → + New College Plan (expect link-to-career prompt) await page.goto('/profile/college', { waitUntil: 'domcontentloaded' }); await page.getByRole('button', { name: '+ New College Plan' }).click(); // The prompt is a labeled box; target the