diff --git a/backend/src/auth/tokenScopes.ts b/backend/src/auth/tokenScopes.ts index a520c861..f8553d6d 100644 --- a/backend/src/auth/tokenScopes.ts +++ b/backend/src/auth/tokenScopes.ts @@ -112,7 +112,7 @@ export function isScopedTokenRequestAllowed( return allowsRead(scopes, 'templates:write', 'cards:write', 'newsletter:write'); } - if (isRead && (matchesPrefix(path, '/api/academy-leads') || matchesPrefix(path, '/api/academy-pageviews'))) { + if (isRead && matchesPrefix(path, '/api/academy-pageviews')) { return allowsRead(scopes, 'cards:write', 'newsletter:write'); } diff --git a/backend/src/docs/frontend-assets.json b/backend/src/docs/frontend-assets.json index a39db23b..9bc0816e 100644 --- a/backend/src/docs/frontend-assets.json +++ b/backend/src/docs/frontend-assets.json @@ -147,7 +147,6 @@ "src/surfaces/finance/sponsors.js", "src/surfaces/finance/tuition.js", "src/surfaces/inbox.js", - "src/surfaces/academy-leads.js", "src/surfaces/knowledge/catalog.js", "src/surfaces/knowledge/filters.js", "src/surfaces/knowledge/index.js", diff --git a/backend/src/router.ts b/backend/src/router.ts index 4ed69db3..2e7abde4 100644 --- a/backend/src/router.ts +++ b/backend/src/router.ts @@ -1,5 +1,4 @@ import { handleTuitionRoutes } from './routes/tuition'; -import { handleAcademyLeadsRoutes } from './routes/academyLeads'; import { handleAcademyPageviewsRoutes } from './routes/academyPageviews'; import { timingSafeEqual } from 'crypto'; import { portalRuntimeSecret } from './runtimeSecret'; @@ -375,10 +374,6 @@ async function route(event: LambdaEvent, client: DynamoDBDocumentClient): Promis return await handleReconcileRoutes(reqPath, method, event, client); } if (reqPath === '/api/tuition' || reqPath.startsWith('/api/tuition/')) return await handleTuitionRoutes(reqPath, method, event, client); - if (reqPath === '/api/academy-leads') { - const academy = await handleAcademyLeadsRoutes(reqPath, method, event); - if (academy) return academy; - } if (reqPath === '/api/academy-pageviews') { const pageviews = await handleAcademyPageviewsRoutes(reqPath, method, event); if (pageviews) return pageviews; diff --git a/backend/src/routes/academyLeads.ts b/backend/src/routes/academyLeads.ts deleted file mode 100644 index df6d666e..00000000 --- a/backend/src/routes/academyLeads.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { listAcademyLeads, type AcademyLeadStatus } from '../academyLeads/service'; -import { json } from '../http'; -import type { LambdaEvent, LambdaResponse } from '../types'; - -export async function handleAcademyLeadsRoutes( - path: string, - method: string, - event: LambdaEvent, -): Promise { - if (path !== '/api/academy-leads' || method !== 'GET') return null; - const qs = event.queryStringParameters || {}; - const includeTests = qs.includeTests === 'true' || qs.includeTests === '1'; - const track = typeof qs.track === 'string' ? qs.track : ''; - const source = typeof qs.source === 'string' ? qs.source : ''; - const status: AcademyLeadStatus = - qs.status === 'pending' || qs.status === 'all' ? qs.status : 'confirmed'; - const data = await listAcademyLeads({ includeTests, track, source, status }); - return json(200, data); -} diff --git a/cli/src/cli.mjs b/cli/src/cli.mjs index 485808c4..28814dac 100644 --- a/cli/src/cli.mjs +++ b/cli/src/cli.mjs @@ -36,7 +36,6 @@ import * as sponsors from "./commands/sponsors.mjs"; import * as sponsorDocs from "./commands/sponsorDocs.mjs"; import * as crm from "./commands/crm.mjs"; import * as vies from "./commands/vies.mjs"; -import * as academyLeads from "./commands/academyLeads.mjs"; import * as academyPageviews from "./commands/academyPageviews.mjs"; import * as tasks from "./commands/tasks.mjs"; import * as templates from "./commands/templates.mjs"; @@ -80,7 +79,6 @@ export const FAMILIES = { "text-templates": { group: "Work", summary: textTemplates.summary, help: textTemplates.help, commands: textTemplates.commands }, email: { group: "Work", summary: email.summary, help: email.help, commands: email.commands }, "academy-pageviews": { group: "Planning", summary: academyPageviews.summary, help: academyPageviews.help, run: academyPageviews.run }, - "academy-leads": { group: "Planning", summary: academyLeads.summary, help: academyLeads.help, run: academyLeads.run }, resources: { group: "Work", summary: resources.summary, help: resources.help, commands: resources.commands }, recurring: { group: "Work", diff --git a/cli/src/commands/academyLeads.mjs b/cli/src/commands/academyLeads.mjs deleted file mode 100644 index 49a47122..00000000 --- a/cli/src/commands/academyLeads.mjs +++ /dev/null @@ -1,102 +0,0 @@ -import { apiFor } from "../session.mjs"; - -export const summary = "Academy shortlist signups and UTM attribution across tracks"; - -export const help = `dataops academy-leads - list academy.datatalks.club shortlist signups and /sessions (source=layoff_proof) leads - -Usage - dataops academy-leads [--include-tests] [--status ] [--pending] [--track ] [--source ] [--json] - -Options - --include-tests Include is_test rows (hidden by default) - --status STATUS Filter confirmation status: confirmed (default), pending, or all - --pending Shorthand for --status pending - --track TRACK Filter to one track (agentic-engineering or ai-engineering) - --source SOURCE Filter to one lead source (e.g. shortlist or layoff_proof) - --json Output raw JSON payload -`; - -export async function run(args, io) { - const api = apiFor(args); - const query = {}; - if (args["include-tests"] || args.includeTests) query.includeTests = "true"; - if (args.pending) query.status = "pending"; - else if (args.status) query.status = String(args.status); - if (args.track) query.track = String(args.track); - if (args.source) query.source = String(args.source); - const qs = new URLSearchParams(query).toString(); - const data = await api.get(`/api/academy-leads${qs ? `?${qs}` : ""}`); - - const s = data.summary || {}; - const byTrack = s.byTrack || {}; - const fc = s.firstChoice || {}; - io.print( - `Academy leads: ${s.total || 0} shown (${s.pendingCount || 0} pending, ${s.testCount || 0} test rows total) | ` + - `agentic-engineering: ${byTrack["agentic-engineering"] || 0}, ` + - `ai-engineering: ${byTrack["ai-engineering"] || 0} | ` + - `unique: agentic only=${fc["agentic only"] || 0}, AI only=${fc["AI only"] || 0}, both=${fc.both || 0}`, - ); - const interest = s.byTrackInterest || {}; - if (Object.keys(interest).length > 0) { - io.print( - "Track of interest (layoff_proof): " + - ["agentic", "ai", "both", "not_sure", "unspecified"] - .filter((k) => interest[k]) - .map((k) => `${k}=${interest[k]}`) - .join(", "), - ); - const fmt = (m) => - Object.keys(m || {}) - .sort() - .map((k) => `${k}=${m[k]}`) - .join(", ") || "none"; - io.print(`Registered per session: ${fmt(s.bySession)}`); - io.print(`Recording form per session: ${fmt(s.byQrSession)}`); - } - if (Array.isArray(s.byUtm) && s.byUtm.length > 0) { - io.print("\nBy utm_source / utm_content:"); - for (const b of s.byUtm) { - const mix = Object.entries(b.interest || {}) - .map(([k, n]) => `${k}=${n}`) - .join(","); - io.print( - ` ${b.utm_source} / ${b.utm_content}: agentic=${b.agentic}, ai=${b.ai}, total=${b.total}${mix ? `, interest ${mix}` : ""}`, - ); - } - } - if (Array.isArray(data.leads) && data.leads.length > 0) { - io.print("\nSignups:"); - for (const row of data.leads) { - const utm = [row.utm_source, row.utm_medium, row.utm_campaign, row.utm_content, row.utm_term] - .map((v) => v || "-") - .join("/"); - const ans = Object.entries(row.answers || {}) - .map(([k, v]) => `${k}=${v}`) - .join(","); - const conf = row.confirmed ? `confirmed=${row.confirmed_at || "yes"}` : "unconfirmed"; - const label = row.source && row.source !== "shortlist" ? `source=${row.source}` : row.track; - const extra = [ - row.name ? `name=${row.name}` : "", - Array.isArray(row.sessions) && row.sessions.length ? `sessions=${row.sessions.join(",")}` : "", - row.status ? `status=${row.status}` : "", - row.track_interest ? `track=${row.track_interest}` : "", - row.years_dev ? `years=${row.years_dev}` : "", - row.based_in ? `based_in=${row.based_in}` : "", - row.berlin_germany ? `berlin=${row.berlin_germany}` : "", - row.bildungsgutschein ? `bg=${row.bildungsgutschein}` : "", - row.payment_plan ? `payment_plan=${row.payment_plan}` : "", - row.session ? `qr_session=${row.session}` : "", - Array.isArray(row.qr_sessions) && row.qr_sessions.length ? `qr_sessions=${row.qr_sessions.join(",")}` : "", - row.academy_optin ? `april_optin=${row.academy_optin}` : "", - row.unsubscribed ? "unsubscribed" : "", - row.free_text ? `wants_to_learn=${JSON.stringify(row.free_text)}` : "", - ] - .filter(Boolean) - .join(" "); - io.print( - ` ${row.created_at} ${row.email}${row.is_test ? " [test]" : ""} ${label} ${conf} utm=${utm} page=${row.page || "-"}${ans ? ` answers=${ans}` : ""}${extra ? ` ${extra}` : ""}`, - ); - } - } - return data; -} diff --git a/frontend/index.html b/frontend/index.html index 4b700649..1ac00848 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -76,7 +76,6 @@ CRM Finance Bookkeeping - Academy Leads

Knowledge

Operating Model Process Docs diff --git a/frontend/src/core/workspace.js b/frontend/src/core/workspace.js index f4db98c6..ca3f0495 100644 --- a/frontend/src/core/workspace.js +++ b/frontend/src/core/workspace.js @@ -95,7 +95,6 @@ export const WORKSPACE_ROUTE_DEFINITIONS = Object.freeze({ "/newsletter/:issueId": { view: "newsletter", tasksSection: "queue", params: [] }, "/calendar": { view: "calendar", tasksSection: "queue", params: [] }, "/inbox": { view: "inbox", tasksSection: "queue", params: ["status", "item"] }, - "/academy-leads": { view: "academy-leads", tasksSection: "queue", params: ["includeTests", "track"] }, // ?view=list swaps the seasons overview for the plain episode list. "/podcast": { view: "podcast", tasksSection: "queue", params: ["view"] }, "/podcast/schedule": { view: "podcast", tasksSection: "queue", params: [] }, diff --git a/frontend/src/runtime/application.js b/frontend/src/runtime/application.js index 43bf249f..4527aa3f 100644 --- a/frontend/src/runtime/application.js +++ b/frontend/src/runtime/application.js @@ -36,7 +36,6 @@ import { createKnowledgeSurface } from "../surfaces/knowledge/index.js"; import { createDocumentEditor } from "../surfaces/document-editor/index.js"; import { createPodcastSurface } from "../surfaces/podcast/index.js"; import { createInboxSurface } from "../surfaces/inbox.js"; -import { createAcademyLeadsSurface } from "../surfaces/academy-leads.js"; import { createOperatingModelSurface } from "../surfaces/operating-model.js"; import { createApiClient, resolveApiBase } from "../shell/api.js"; import { createFeedbackShell } from "../shell/feedback.js"; @@ -159,7 +158,6 @@ const { getKnowledgeSelectedFolder: () => knowledgeState.selectedFolder, getNormalizeOperationsRecurringSnapshot: () => normalizeOperationsRecurringSnapshot, - getRenderAcademyLeadsSurface: () => academyLeadsSurface?.renderAcademyLeads || (() => undefined), getRenderAdminSurfaceView: () => renderAdminSurfaceView, getRenderBookkeepingSurface: () => renderBookkeepingSurface, getRenderFinanceOverviewSurface: () => renderFinanceOverviewSurface, @@ -600,15 +598,6 @@ inboxSurface = createInboxSurface({ workApiUrl, }); -const academyLeadsSurface = createAcademyLeadsSurface({ - documentList, - getActiveWorkspaceRoute, - navigateCanonicalWorkspace, - request, - setRouteTitle, - workApiUrl, -}); - knowledgeSurface = createKnowledgeSurface({ knowledgeTools: document.querySelector("#knowledge-tools"), renderInBackground, diff --git a/frontend/src/runtime/surface-composition.js b/frontend/src/runtime/surface-composition.js index 46b383b9..0613f7c3 100644 --- a/frontend/src/runtime/surface-composition.js +++ b/frontend/src/runtime/surface-composition.js @@ -117,7 +117,6 @@ export function createSurfaceComposition(context) { getCanLeaveDocumentEditor, getCanLeaveFinanceSurface, getKnowledgeSelectedFolder, - getRenderAcademyLeadsSurface, getRenderAdminSurfaceView, getRenderBookkeepingSurface, getRenderFinanceOverviewSurface, @@ -167,7 +166,6 @@ export function createSurfaceComposition(context) { if (view === "newsletter") return getRenderNewsletterSurface()(); if (view === "calendar") return getRenderCalendarSurface()(); if (view === "inbox") return getRenderInboxSurface()(); - if (view === "academy-leads") return getRenderAcademyLeadsSurface()(); if (view === "podcast") return getRenderPodcastSurface()(); return getRenderTasksSurface()(documents, "queue"); } diff --git a/frontend/src/shell/startup-orchestration.js b/frontend/src/shell/startup-orchestration.js index 4cb80dc3..1573328e 100644 --- a/frontend/src/shell/startup-orchestration.js +++ b/frontend/src/shell/startup-orchestration.js @@ -19,7 +19,7 @@ // deferred at bootstrap and shielded from snapshot repaints together, so the // two can never drift apart. export const SELF_LOADING_VIEWS = Object.freeze( - new Set(["academy-leads", "bookkeeping", "calendar", "finance", "inbox", "newsletter", "podcast", "sponsors", "users"]), + new Set(["bookkeeping", "calendar", "finance", "inbox", "newsletter", "podcast", "sponsors", "users"]), ); // Whether committing this route needs none of the shared snapshots yet. An diff --git a/frontend/src/surfaces/academy-leads.js b/frontend/src/surfaces/academy-leads.js deleted file mode 100644 index c74580f5..00000000 --- a/frontend/src/surfaces/academy-leads.js +++ /dev/null @@ -1,294 +0,0 @@ -import { createPageHeader } from "./operations-overview.js"; - -function el(documentRef, tag, className, text = "") { - const node = documentRef.createElement(tag); - if (className) node.className = className; - if (text) node.textContent = text; - return node; -} - -function escapeCsvCell(value) { - const str = value == null ? "" : String(value); - const safe = /^[=+\-@]/.test(str) ? `'${str}` : str; - return /[",\n\r]/.test(safe) ? `"${safe.replace(/"/g, '""')}"` : safe; -} - -export function createAcademyLeadsSurface(context) { - const { - documentList, - documentRef = globalThis.document, - getActiveWorkspaceRoute, - navigateCanonicalWorkspace, - request, - setRouteTitle, - workApiUrl, - } = context; - - let leads = []; - let summary = { - total: 0, - pendingCount: 0, - testCount: 0, - byTrack: { "agentic-engineering": 0, "ai-engineering": 0 }, - firstChoice: { "agentic only": 0, "AI only": 0, both: 0 }, - byUtm: [], - }; - let loading = false; - let error = ""; - let loadedKey = null; - - function readParam(params, name) { - if (!params) return ""; - if (typeof params.get === "function") return params.get(name) || ""; - return params[name] || ""; - } - - function currentFilters() { - const route = getActiveWorkspaceRoute(); - const includeTestsVal = readParam(route?.params, "includeTests"); - const includeTests = includeTestsVal === "true" || includeTestsVal === "1"; - const track = readParam(route?.params, "track"); - const rawStatus = readParam(route?.params, "status"); - const status = rawStatus === "pending" || rawStatus === "all" ? rawStatus : "confirmed"; - return { includeTests, track, status }; - } - - function filterKey({ includeTests, track, status }) { - return `${includeTests ? "1" : "0"}:${track}:${status}`; - } - - async function load(filters = currentFilters()) { - if (loading) return; - loading = true; - error = ""; - loadedKey = filterKey(filters); - try { - const query = {}; - if (filters.includeTests) query.includeTests = "true"; - if (filters.track) query.track = filters.track; - if (filters.status && filters.status !== "confirmed") query.status = filters.status; - const payload = await request(workApiUrl("/api/academy-leads", query)); - leads = Array.isArray(payload?.leads) ? payload.leads : []; - summary = payload?.summary || summary; - } catch (caught) { - error = caught?.message || "Academy leads are unavailable"; - } finally { - loading = false; - renderAcademyLeads(); - } - } - - function downloadCsv() { - const cols = [ - "created_at", "email", "confirmed", "confirmed_at", "track", "payment_plan", - "utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term", - "last_utm_source", "last_utm_medium", "last_utm_campaign", "last_utm_content", "last_utm_term", - "referrer", "page", "is_test", "answers", - ]; - const lines = [cols.join(",")]; - for (const row of leads) { - lines.push( - cols - .map((c) => escapeCsvCell(c === "answers" ? JSON.stringify(row.answers || {}) : row[c])) - .join(","), - ); - } - const blob = new Blob([lines.join("\n")], { type: "text/csv;charset=utf-8" }); - const url = URL.createObjectURL(blob); - const a = documentRef.createElement("a"); - a.href = url; - a.download = "academy-leads.csv"; - documentRef.body.append(a); - a.click(); - a.remove(); - URL.revokeObjectURL(url); - } - - function renderControls(root, filters) { - const bar = el(documentRef, "div", "row-actions"); - - const toggleLabel = el(documentRef, "label", "dk-checkbox-label"); - const checkbox = documentRef.createElement("input"); - checkbox.type = "checkbox"; - checkbox.checked = filters.includeTests; - checkbox.dataset.academyIncludeTests = "true"; - checkbox.addEventListener("change", () => { - navigateCanonicalWorkspace("/academy-leads", { - ...(checkbox.checked ? { includeTests: "true" } : {}), - ...(filters.track ? { track: filters.track } : {}), - ...(filters.status !== "confirmed" ? { status: filters.status } : {}), - }); - }); - toggleLabel.append(checkbox, documentRef.createTextNode(` Show test leads (${summary.testCount || 0})`)); - - const statusSelect = documentRef.createElement("select"); - statusSelect.setAttribute("aria-label", "Filter by confirmation status"); - statusSelect.dataset.academyStatusFilter = "true"; - for (const [val, label] of [ - ["confirmed", "Confirmed only"], - ["pending", `Pending (${summary.pendingCount || 0})`], - ["all", "All statuses"], - ]) { - const opt = documentRef.createElement("option"); - opt.value = val; - opt.textContent = label; - opt.selected = filters.status === val; - statusSelect.append(opt); - } - statusSelect.addEventListener("change", () => { - navigateCanonicalWorkspace("/academy-leads", { - ...(filters.includeTests ? { includeTests: "true" } : {}), - ...(filters.track ? { track: filters.track } : {}), - ...(statusSelect.value !== "confirmed" ? { status: statusSelect.value } : {}), - }); - }); - - const trackSelect = documentRef.createElement("select"); - trackSelect.setAttribute("aria-label", "Filter by track"); - trackSelect.dataset.academyTrackFilter = "true"; - for (const [val, label] of [ - ["", "All tracks"], - ["agentic-engineering", "agentic-engineering"], - ["ai-engineering", "ai-engineering"], - ]) { - const opt = documentRef.createElement("option"); - opt.value = val; - opt.textContent = label; - opt.selected = filters.track === val; - trackSelect.append(opt); - } - trackSelect.addEventListener("change", () => { - navigateCanonicalWorkspace("/academy-leads", { - ...(filters.includeTests ? { includeTests: "true" } : {}), - ...(trackSelect.value ? { track: trackSelect.value } : {}), - ...(filters.status !== "confirmed" ? { status: filters.status } : {}), - }); - }); - - const refreshBtn = el(documentRef, "button", "dk-button dk-button--secondary dk-button--sm", "Refresh"); - refreshBtn.type = "button"; - refreshBtn.addEventListener("click", () => load(filters)); - - const exportBtn = el(documentRef, "button", "dk-button dk-button--secondary dk-button--sm", "Export CSV"); - exportBtn.type = "button"; - exportBtn.disabled = leads.length === 0; - exportBtn.addEventListener("click", downloadCsv); - - bar.append(toggleLabel, statusSelect, trackSelect, refreshBtn, exportBtn); - root.append(bar); - } - - function renderSummary(root) { - const section = el(documentRef, "section", "dk-section"); - const trackCounts = el(documentRef, "p", "dk-muted"); - const ag = summary.byTrack?.["agentic-engineering"] || 0; - const ai = summary.byTrack?.["ai-engineering"] || 0; - const fc = summary.firstChoice || { "agentic only": 0, "AI only": 0, both: 0 }; - trackCounts.textContent = - `Total: ${summary.total || 0} (pending: ${summary.pendingCount || 0}) | agentic-engineering: ${ag} | ai-engineering: ${ai} ` + - `(unique leads — agentic only: ${fc["agentic only"] || 0}, AI only: ${fc["AI only"] || 0}, both: ${fc.both || 0})`; - section.append(trackCounts); - - const buckets = Array.isArray(summary.byUtm) ? summary.byUtm : []; - if (buckets.length > 0) { - const heading = el(documentRef, "h2", "dk-section-title", "Counts by utm_source / utm_content"); - const wrap = el(documentRef, "div", "dk-table-wrap"); - const table = el(documentRef, "table", "dk-table"); - table.innerHTML = - "utm_sourceutm_contentagentic-engineeringai-engineeringtotal"; - const tbody = documentRef.createElement("tbody"); - for (const b of buckets) { - const tr = documentRef.createElement("tr"); - for (const val of [b.utm_source, b.utm_content, b.agentic, b.ai, b.total]) { - const td = documentRef.createElement("td"); - td.textContent = String(val); - tr.append(td); - } - tbody.append(tr); - } - table.append(tbody); - wrap.append(table); - section.append(heading, wrap); - } - root.append(section); - } - - function renderLeadsTable(root) { - if (loading) { - root.append(el(documentRef, "p", "dk-muted", "Loading academy leads…")); - return; - } - if (error) { - root.append(el(documentRef, "p", "dk-error", error)); - return; - } - if (leads.length === 0) { - root.append(el(documentRef, "p", "dk-muted", "No academy leads match the current filter.")); - return; - } - - const wrap = el(documentRef, "div", "dk-table-wrap"); - const table = el(documentRef, "table", "dk-table"); - const cols = [ - "created_at", "email", "track", "payment_plan", - "utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term", - "referrer", "page", "answers", - ]; - const thead = documentRef.createElement("thead"); - const headRow = documentRef.createElement("tr"); - for (const col of cols) { - const th = documentRef.createElement("th"); - th.textContent = col; - headRow.append(th); - } - thead.append(headRow); - table.append(thead); - - const tbody = documentRef.createElement("tbody"); - for (const row of leads) { - const tr = documentRef.createElement("tr"); - if (row.is_test) tr.dataset.isTest = "true"; - for (const col of cols) { - const td = documentRef.createElement("td"); - if (col === "answers") { - const entries = Object.entries(row.answers || {}); - td.textContent = entries.length ? entries.map(([k, v]) => `${k}=${v}`).join(", ") : ""; - } else if (col === "email" && row.is_test) { - td.textContent = `${row.email} [test]`; - } else { - td.textContent = row[col] || ""; - } - tr.append(td); - } - tbody.append(tr); - } - table.append(tbody); - wrap.append(table); - root.append(wrap); - } - - function renderAcademyLeads() { - const route = getActiveWorkspaceRoute(); - if (route?.view !== "academy-leads") return; - setRouteTitle("Academy Leads"); - const filters = currentFilters(); - const key = filterKey(filters); - if (!loading && loadedKey !== key) { - load(filters); - } - const root = el(documentRef, "div", "academy-leads-surface"); - root.append( - createPageHeader({ - title: "Academy Leads", - subtitle: "Shortlist signups and UTM attribution across tracks (test leads hidden by default).", - documentRef, - }), - ); - renderControls(root, filters); - renderSummary(root); - renderLeadsTable(root); - documentList.replaceChildren(root); - } - - return { renderAcademyLeads, reloadAcademyLeads: load }; -} diff --git a/frontend/test/academy-leads-surface.test.mjs b/frontend/test/academy-leads-surface.test.mjs deleted file mode 100644 index 18ec61ac..00000000 --- a/frontend/test/academy-leads-surface.test.mjs +++ /dev/null @@ -1,145 +0,0 @@ -import assert from "node:assert/strict"; -import test from "node:test"; -import { createAcademyLeadsSurface } from "../src/surfaces/academy-leads.js"; - -function createFakeDom() { - class FakeNode { - constructor(tag) { - this.tagName = tag; - this.children = []; - this.dataset = {}; - this.attributes = {}; - this.listeners = {}; - this.className = ""; - this.type = ""; - this.checked = false; - this.disabled = false; - this.value = ""; - this.selected = false; - this._textContent = ""; - } - set textContent(v) { - this._textContent = String(v); - this.children = []; - } - get textContent() { - return this._textContent || this.children.map((c) => c.textContent).join(""); - } - set innerHTML(_v) {} - setAttribute(k, v) { - this.attributes[k] = String(v); - } - addEventListener(type, fn) { - this.listeners[type] = fn; - } - append(...nodes) { - for (const n of nodes) { - if (n && typeof n === "object") this.children.push(n); - } - } - replaceChildren(...nodes) { - this.children = []; - this.append(...nodes); - } - remove() {} - click() {} - } - - return { - body: new FakeNode("body"), - createElement: (tag) => new FakeNode(tag), - createTextNode: (text) => ({ textContent: text }), - }; -} - -test("createAcademyLeadsSurface renders summary and leads table", async () => { - const dom = createFakeDom(); - const documentList = dom.createElement("div"); - const requests = []; - const surface = createAcademyLeadsSurface({ - documentList, - documentRef: dom, - getActiveWorkspaceRoute: () => ({ view: "academy-leads", params: {} }), - navigateCanonicalWorkspace: () => {}, - request: async (url) => { - requests.push(url); - return { - leads: [ - { - created_at: "2026-11-14T08:00:00+00:00", - email: "ada@example.org", - track: "agentic-engineering", - utm_source: "meta", - utm_medium: "paid-social", - utm_campaign: "c1", - utm_content: "seats", - utm_term: "", - referrer: "https://l.instagram.com/", - page: "/agentic-engineering/", - is_test: false, - answers: { location: "berlin" }, - }, - ], - summary: { - total: 1, - testCount: 1, - byTrack: { "agentic-engineering": 1, "ai-engineering": 0 }, - firstChoice: { "agentic only": 1, "AI only": 0, both: 0 }, - byUtm: [{ utm_source: "meta", utm_content: "seats", agentic: 1, ai: 0, total: 1 }], - }, - }; - }, - setRouteTitle: () => {}, - workApiUrl: (path, query = {}) => { - const qs = new URLSearchParams(query).toString(); - return qs ? `${path}?${qs}` : path; - }, - }); - - surface.renderAcademyLeads(); - await new Promise((r) => setTimeout(r, 10)); - assert.equal(requests.length, 1); - assert.equal(requests[0], "/api/academy-leads"); - assert.match(documentList.textContent, /Academy Leads/); - assert.match(documentList.textContent, /ada@example\.org/); - assert.match(documentList.textContent, /agentic-engineering: 1/); -}); - -test("createAcademyLeadsSurface reads URLSearchParams filters (includeTests and track)", async () => { - const dom = createFakeDom(); - const documentList = dom.createElement("div"); - const requests = []; - - const surface = createAcademyLeadsSurface({ - documentList, - documentRef: dom, - getActiveWorkspaceRoute: () => ({ - view: "academy-leads", - params: new URLSearchParams("includeTests=true&track=agentic-engineering"), - }), - navigateCanonicalWorkspace: () => {}, - request: async (url) => { - requests.push(url); - return { - leads: [], - summary: { - total: 0, - testCount: 0, - byTrack: { "agentic-engineering": 0, "ai-engineering": 0 }, - firstChoice: { "agentic only": 0, "AI only": 0, both: 0 }, - byUtm: [], - }, - }; - }, - setRouteTitle: () => {}, - workApiUrl: (path, query = {}) => { - const qs = new URLSearchParams(query).toString(); - return qs ? `${path}?${qs}` : path; - }, - }); - - surface.renderAcademyLeads(); - await new Promise((r) => setTimeout(r, 10)); - assert.equal(requests.length, 1); - assert.equal(requests[0], "/api/academy-leads?includeTests=true&track=agentic-engineering"); -}); diff --git a/frontend/test/routing.test.mjs b/frontend/test/routing.test.mjs index f29bc442..c0957590 100644 --- a/frontend/test/routing.test.mjs +++ b/frontend/test/routing.test.mjs @@ -72,7 +72,6 @@ describe("canonical workspace routing", () => { "/newsletter/:issueId", "/calendar", "/inbox", - "/academy-leads", "/podcast", "/podcast/schedule", "/podcast/:episodeId", diff --git a/frontend/test/startup-orchestration.test.mjs b/frontend/test/startup-orchestration.test.mjs index c9f70e75..818b19c6 100644 --- a/frontend/test/startup-orchestration.test.mjs +++ b/frontend/test/startup-orchestration.test.mjs @@ -47,7 +47,7 @@ describe("startup route classification", () => { test("defers every self-loading view and nothing else", () => { assert.deepEqual( [...SELF_LOADING_VIEWS].sort(), - ["academy-leads", "bookkeeping", "calendar", "finance", "inbox", "newsletter", "podcast", "sponsors", "users"], + ["bookkeeping", "calendar", "finance", "inbox", "newsletter", "podcast", "sponsors", "users"], ); for (const view of SELF_LOADING_VIEWS) { assert.equal(isStartupDeferredRoute({ view }), true, view);