Files
ComfyUI_frontend/apps/website/vitest.config.ts
Glary-Bot bd555a8732 feat(website): implement sales contact form submission via HubSpot
The /contact form's handleSubmit was a stub, silently dropping enterprise
leads. Submit form data to HubSpot's Forms Submissions API v3
(unauthenticated, CORS-enabled) so leads land in the configured HubSpot
contact-sales form.

Form structure now matches the HubSpot form definition exactly:
- Drop the 'Company' field (not present in HubSpot definition)
- Add a required 'Work Email' field (HubSpot rejects without it)
- Add a required 'Who primarily builds workflows?' multi-checkbox group
- Mark the 'What are you looking for?' textarea as required
- Map package values to HubSpot's enumeration (Individual=No,
  Teams=Teams, Enterprise=Yes) and submit them under the form's actual
  internal property name
- Submit each field with objectTypeId='0-1' per HubSpot's schema

Submission utility:
- Add submitHubspotForm with fetch DI, abort/timeout, and a typed
  HubspotSubmissionError that carries HubSpot's per-field error array
- Read the visitor's hubspotutk tracking cookie so submissions tie back
  to HubSpot's session tracking
- Surface HubSpot's per-field validation messages to the user instead
  of a generic 'something went wrong'

Tests:
- Vitest coverage for the utility (15 cases): payload shape including
  objectTypeId, region switching, empty-value pruning, context handling,
  success body parse, HubspotSubmissionError on 400, unparseable error
  bodies, unconfigured guard, timeout/abort, and the hubspotutk cookie
  reader
- Component tests (3 cases) using @testing-library/vue + user-event:
  payload shape end-to-end, success state + form reset, and HubSpot
  error surfacing

Configuration:
- Default Portal ID and Form GUID baked into the component (and
  documented in .env_example) — these are public IDs that appear in
  HubSpot's own embed code, not secrets
- PUBLIC_HUBSPOT_PORTAL_ID, PUBLIC_HUBSPOT_FORM_ID_CONTACT_SALES, and
  PUBLIC_HUBSPOT_REGION env vars override the defaults per environment
- Wire @vitejs/plugin-vue into vitest.config so .vue components can be
  tested with happy-dom
2026-04-28 01:22:40 +00:00

12 lines
236 B
TypeScript

import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vitest/config'
export default defineConfig({
plugins: [vue()],
test: {
environment: 'node',
include: ['src/**/*.{test,spec}.ts'],
globals: false
}
})