@egbe-ai/opencode 0.0.0-stage → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -0
- package/README.md +124 -2
- package/index.js +5 -0
- package/package.json +55 -4
- package/plugin.js +230 -0
- package/session-log.js +315 -0
- package/skills/.egbe-catalog/manifest.json +1 -0
- package/skills/egbe-os-analytics/SKILL.md +499 -0
- package/skills/egbe-os-analytics/canonical-events.v1.json +256 -0
- package/skills/egbe-os-analytics/references/session-funnel.md +130 -0
- package/skills/egbe-os-analytics/references/workflows/activation-tracking.md +147 -0
- package/skills/egbe-os-analytics/references/workflows/landing-click-tracking.md +209 -0
- package/skills/egbe-os-analytics/references/workflows/payment-lifecycle-tracking.md +122 -0
- package/skills/egbe-os-analytics/references/workflows/product-funnel-tracking.md +77 -0
- package/skills/egbe-os-analytics/references/workflows/signup-lifecycle-tracking.md +208 -0
- package/skills/egbe-os-analytics/scripts/umami_funnel.py +927 -0
- package/skills/egbe-os-apollo-lead-finder/SKILL.md +135 -0
- package/skills/egbe-os-apollo-lead-finder/references/operations.md +240 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/enrich.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/enrich.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/find-leads.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/find-leads.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/apollo-client.js +343 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/connection-identity.js +17 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/helpers.js +127 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/places-filters.js +217 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/sourcing.js +153 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/places-leads.js +653 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/places-leads.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/search.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/search.sh +4 -0
- package/skills/egbe-os-campaign-landing-page/SKILL.md +95 -0
- package/skills/egbe-os-campaign-landing-page/agents/openai.yaml +4 -0
- package/skills/egbe-os-campaign-landing-page/references/leads-calendar-and-tracking.md +66 -0
- package/skills/egbe-os-campaign-landing-page/references/os-wiring.md +58 -0
- package/skills/egbe-os-campaign-landing-page/references/qa.md +40 -0
- package/skills/egbe-os-campaign-landing-page/references/routing.md +32 -0
- package/skills/egbe-os-db/SKILL.md +174 -0
- package/skills/egbe-os-deploy/SKILL.md +412 -0
- package/skills/egbe-os-design/SKILL.md +182 -0
- package/skills/egbe-os-design-landing-page/SKILL.md +117 -0
- package/skills/egbe-os-design-landing-page/agents/openai.yaml +4 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/.dockerignore +11 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/AGENTS.md +31 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/Dockerfile +21 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/eslint.config.mjs +18 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/next.config.ts +11 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/package.json +36 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/postcss.config.mjs +7 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/public/.gitkeep +1 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/sentry.edge.config.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/sentry.server.config.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/global-error.tsx +19 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/globals.css +22 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/layout.tsx +21 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/page.tsx +3 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/privacy/page.tsx +28 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/components/egbe-analytics.tsx +39 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/instrumentation-client.ts +15 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/instrumentation.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/lib/egbe-observability.generated.ts +20 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/lib/utils.ts +6 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/tsconfig.json +34 -0
- package/skills/egbe-os-design-landing-page/references/application-preparation.md +44 -0
- package/skills/egbe-os-design-landing-page/references/page-inputs.md +22 -0
- package/skills/egbe-os-destination-readiness/SKILL.md +132 -0
- package/skills/egbe-os-destination-readiness/references/checks.md +130 -0
- package/skills/egbe-os-destination-readiness/references/network-requirements.md +34 -0
- package/skills/egbe-os-destination-readiness/references/report.md +116 -0
- package/skills/egbe-os-domains/SKILL.md +189 -0
- package/skills/egbe-os-errors/SKILL.md +259 -0
- package/skills/egbe-os-git/SKILL.md +275 -0
- package/skills/egbe-os-git/references/issues.md +33 -0
- package/skills/egbe-os-google-ads/SKILL.md +163 -0
- package/skills/egbe-os-google-ads/references/artifacts.md +133 -0
- package/skills/egbe-os-google-ads/references/campaigns.md +157 -0
- package/skills/egbe-os-google-ads/references/conversions.md +153 -0
- package/skills/egbe-os-google-ads/references/delivery.md +128 -0
- package/skills/egbe-os-google-ads/references/keyword-ideas.md +40 -0
- package/skills/egbe-os-google-ads/references/reporting.md +105 -0
- package/skills/egbe-os-google-ads/references/search-assets.md +219 -0
- package/skills/egbe-os-google-ads/references/server-conversions.md +119 -0
- package/skills/egbe-os-google-auth/SKILL.md +285 -0
- package/skills/egbe-os-google-auth/agents/openai.yaml +4 -0
- package/skills/egbe-os-gtm-knowledge/SKILL.md +151 -0
- package/skills/egbe-os-images/SKILL.md +163 -0
- package/skills/egbe-os-images/references/stock-images.md +21 -0
- package/skills/egbe-os-instantly-campaign-launcher/SKILL.md +127 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/instantly-ops.md +260 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/observation-and-scheduling.md +188 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/reply-handling.md +116 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/run-spec-template.json +65 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/run-state.md +145 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/conclude-campaign.js +158 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/install-crons.js +956 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/launch-campaign.js +2008 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/campaign-metrics.js +124 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/confirmed-opt-outs.js +208 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/connection-identity.js +17 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/create-once.js +23 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/gtm-identity.js +125 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/helpers.js +545 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/html-body.js +266 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/instantly-client.js +328 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/outreach-db.js +370 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/recipient-exclusion/index.js +86 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/replenish-test-harness.js +53 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/reply-queue.js +67 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/run-config.js +103 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/sender-selection.js +105 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/monitor-campaign.js +607 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/outreach-report.js +147 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/replenish-leads.js +619 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/reply-worker.js +258 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/run-cron-job.js +32 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/send-reply.js +260 -0
- package/skills/egbe-os-linkedin-ads/SKILL.md +114 -0
- package/skills/egbe-os-linkedin-ads/references/destination-requirements.md +30 -0
- package/skills/egbe-os-linkedin-ads/references/runtime/api-reference.md +154 -0
- package/skills/egbe-os-linkedin-ads/references/runtime/artifacts.md +63 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/build-paused.md +44 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/conversions.md +88 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/launch-and-pause.md +49 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/monitoring.md +35 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/readiness.md +63 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/targeting-and-creative.md +52 -0
- package/skills/egbe-os-llm/SKILL.md +160 -0
- package/skills/egbe-os-mail/SKILL.md +180 -0
- package/skills/egbe-os-me/SKILL.md +119 -0
- package/skills/egbe-os-meta-ads/SKILL.md +114 -0
- package/skills/egbe-os-meta-ads/references/creative/creative-specs.md +15 -0
- package/skills/egbe-os-meta-ads/references/creative/talking-head.md +35 -0
- package/skills/egbe-os-meta-ads/references/destination-requirements.md +30 -0
- package/skills/egbe-os-meta-ads/references/runtime/api-reference.md +436 -0
- package/skills/egbe-os-meta-ads/references/runtime/artifacts.md +51 -0
- package/skills/egbe-os-meta-ads/references/runtime/insights-reference.md +187 -0
- package/skills/egbe-os-meta-ads/references/runtime/pixel-install.md +196 -0
- package/skills/egbe-os-meta-ads/references/runtime/shared-analytics-attribution.md +16 -0
- package/skills/egbe-os-meta-ads/references/workflows/build-paused.md +36 -0
- package/skills/egbe-os-meta-ads/references/workflows/launch-ready.md +16 -0
- package/skills/egbe-os-meta-ads/references/workflows/launch.md +23 -0
- package/skills/egbe-os-meta-ads/references/workflows/monitoring.md +72 -0
- package/skills/egbe-os-meta-ads/references/workflows/pause.md +17 -0
- package/skills/egbe-os-meta-ads/references/workflows/recovery.md +23 -0
- package/skills/egbe-os-meta-ads/scripts/check-pixel.py +229 -0
- package/skills/egbe-os-meta-ads/scripts/validate-meta-artifacts.py +187 -0
- package/skills/egbe-os-notifications/SKILL.md +78 -0
- package/skills/egbe-os-openai-ads/SKILL.md +149 -0
- package/skills/egbe-os-openai-ads/references/creative/chat-card.md +51 -0
- package/skills/egbe-os-openai-ads/references/destination-requirements.md +29 -0
- package/skills/egbe-os-openai-ads/references/runtime/api-reference.md +219 -0
- package/skills/egbe-os-openai-ads/references/runtime/artifacts.md +169 -0
- package/skills/egbe-os-openai-ads/references/workflows/build-paused.md +40 -0
- package/skills/egbe-os-openai-ads/references/workflows/conversions.md +40 -0
- package/skills/egbe-os-openai-ads/references/workflows/creative-assembly.md +24 -0
- package/skills/egbe-os-openai-ads/references/workflows/launch.md +27 -0
- package/skills/egbe-os-openai-ads/references/workflows/monitoring.md +54 -0
- package/skills/egbe-os-openai-ads/references/workflows/pause.md +22 -0
- package/skills/egbe-os-openai-ads/references/workflows/readiness.md +37 -0
- package/skills/egbe-os-openai-ads/references/workflows/tracking.md +32 -0
- package/skills/egbe-os-openai-ads/scripts/validate-openai-artifacts.py +271 -0
- package/skills/egbe-os-organic-trend-watch/SKILL.md +139 -0
- package/skills/egbe-os-organic-trend-watch/agents/openai.yaml +4 -0
- package/skills/egbe-os-organic-trend-watch/references/analysis-and-adaptation.md +54 -0
- package/skills/egbe-os-organic-trend-watch/references/collection-and-analysis.md +117 -0
- package/skills/egbe-os-organic-trend-watch/references/output-contract.md +133 -0
- package/skills/egbe-os-organic-trend-watch/references/provider-contract.md +169 -0
- package/skills/egbe-os-organic-trend-watch/references/runtime-contract.md +204 -0
- package/skills/egbe-os-organic-trend-watch/references/visual-analysis-prompt.md +17 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_analysis.py +612 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_contract.py +1133 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_provider_inputs.py +165 -0
- package/skills/egbe-os-organic-trend-watch/scripts/analyze-visual-evidence.py +315 -0
- package/skills/egbe-os-organic-trend-watch/scripts/build-provider-inputs.py +88 -0
- package/skills/egbe-os-organic-trend-watch/scripts/connection_identity.py +22 -0
- package/skills/egbe-os-organic-trend-watch/scripts/egbe_artifacts.py +24 -0
- package/skills/egbe-os-organic-trend-watch/scripts/finalize-receipt.py +106 -0
- package/skills/egbe-os-organic-trend-watch/scripts/normalize-videos.py +647 -0
- package/skills/egbe-os-organic-trend-watch/scripts/prepare-visual-evidence.py +324 -0
- package/skills/egbe-os-organic-trend-watch/scripts/render-result.py +30 -0
- package/skills/egbe-os-organic-trend-watch/scripts/run-apify.py +723 -0
- package/skills/egbe-os-organic-trend-watch/scripts/run-state.py +192 -0
- package/skills/egbe-os-organic-trend-watch/scripts/validate-context.py +27 -0
- package/skills/egbe-os-organic-trend-watch/scripts/validate-runtime.py +137 -0
- package/skills/egbe-os-payments/SKILL.md +215 -0
- package/skills/egbe-os-payments/agents/openai.yaml +4 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/.egbe/scaffolds/billing-nextjs-subscription.v1.json +5 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/AGENTS.append.md +13 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/db/migrations/1000_egbe_billing.sql +66 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/package.fragment.json +12 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/scripts/billing-sync.mjs +162 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/error.tsx +11 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/loading.tsx +8 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/page.tsx +121 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/checkout/route.ts +102 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/portal/route.ts +54 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/status/route.ts +22 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/payments/webhook/route.ts +65 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/components/egbe-billing/plan-badge.tsx +16 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/billing-sync.test.mjs +58 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/catalog.ts +82 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/checkout-payload.ts +47 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/foundation-contract.test.mjs +59 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.d.ts +16 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.mjs +82 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.test.mjs +94 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/os-client.ts +96 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/plans.json +17 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/repository.ts +325 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/signature.d.ts +6 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/signature.mjs +22 -0
- package/skills/egbe-os-payments/references/contracts/plan-catalog.md +46 -0
- package/skills/egbe-os-payments/references/security/durable-verification.md +64 -0
- package/skills/egbe-os-payments/references/security/server-integration.md +26 -0
- package/skills/egbe-os-payments/references/security/webhook-and-entitlements.md +152 -0
- package/skills/egbe-os-payments/references/ux/billing-experience.md +47 -0
- package/skills/egbe-os-payments/references/workflows/account-billing.md +64 -0
- package/skills/egbe-os-payments/references/workflows/discounts-and-promotion-codes.md +265 -0
- package/skills/egbe-os-payments/references/workflows/one-time-purchase.md +75 -0
- package/skills/egbe-os-payments/references/workflows/product-checkout.md +355 -0
- package/skills/egbe-os-payments/references/workflows/subscription-lifecycle.md +55 -0
- package/skills/egbe-os-playbook/SKILL.md +79 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/email-outreach.md +91 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/google-search.md +40 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/linkedin.md +24 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/meta.md +23 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/openai.md +15 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/reddit.md +56 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/choose-test.md +73 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/evaluate.md +91 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/market.md +96 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/run-test.md +111 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition.md +56 -0
- package/skills/egbe-os-playbook/playbooks/product/business-loop.md +141 -0
- package/skills/egbe-os-playbook/playbooks/product/collaboration.md +26 -0
- package/skills/egbe-os-playbook/playbooks/product/deliver.md +75 -0
- package/skills/egbe-os-playbook/playbooks/product/diagnose.md +80 -0
- package/skills/egbe-os-playbook/playbooks/product/evaluate.md +67 -0
- package/skills/egbe-os-playbook/playbooks/product/experience.md +132 -0
- package/skills/egbe-os-playbook/playbooks/product/loop-examples.md +67 -0
- package/skills/egbe-os-playbook/playbooks/product/offer.md +65 -0
- package/skills/egbe-os-playbook/playbooks/product/value.md +91 -0
- package/skills/egbe-os-playbook/playbooks/product.md +67 -0
- package/skills/egbe-os-playbook/references/catalog.md +127 -0
- package/skills/egbe-os-playbook/references/changes.md +167 -0
- package/skills/egbe-os-playbook/scripts/playbook-changes.py +6 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/__init__.py +1 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/cli.py +57 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/operations.py +137 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/protocol.py +132 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/storage.py +180 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/transport.py +113 -0
- package/skills/egbe-os-product-auth/SKILL.md +151 -0
- package/skills/egbe-os-product-auth/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-auth/assets/db/README.md +102 -0
- package/skills/egbe-os-product-auth/assets/db/create-validation-session.mjs +223 -0
- package/skills/egbe-os-product-auth/assets/db/migrate.mjs +64 -0
- package/skills/egbe-os-product-auth/assets/db/migrations/0001_auth.sql +33 -0
- package/skills/egbe-os-product-auth/assets/db/migrations/0002_auth_identities.sql +16 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-auth-database/AGENTS.append.md +17 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-auth-database/package.fragment.json +10 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/AGENTS.append.md +9 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/package.fragment.json +13 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/db.ts +31 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/identity.ts +94 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/index.ts +3 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/session.ts +91 -0
- package/skills/egbe-os-product-auth/references/contracts/live-auth-interface.md +108 -0
- package/skills/egbe-os-product-auth/references/frameworks/nextjs.md +34 -0
- package/skills/egbe-os-product-auth/references/security/session-and-credentials.md +73 -0
- package/skills/egbe-os-product-auth/references/ux/auth-experience.md +58 -0
- package/skills/egbe-os-product-auth/references/workflows/account-recovery.md +22 -0
- package/skills/egbe-os-product-auth/references/workflows/build-auth.md +212 -0
- package/skills/egbe-os-product-auth/references/workflows/google.md +34 -0
- package/skills/egbe-os-product-auth/references/workflows/passwordless-email.md +65 -0
- package/skills/egbe-os-product-build/SKILL.md +111 -0
- package/skills/egbe-os-product-build/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-build/references/capabilities.md +25 -0
- package/skills/egbe-os-product-build/references/engineering.md +72 -0
- package/skills/egbe-os-product-build/references/execution.md +55 -0
- package/skills/egbe-os-product-build/references/foundations.md +93 -0
- package/skills/egbe-os-product-build/references/interface-quality.md +32 -0
- package/skills/egbe-os-product-build/references/workflows/private-review-handoff.md +86 -0
- package/skills/egbe-os-product-build/scripts/scaffold.py +296 -0
- package/skills/egbe-os-product-demo-video/SKILL.md +118 -0
- package/skills/egbe-os-product-demo-video/references/recording.md +32 -0
- package/skills/egbe-os-product-market-research/SKILL.md +159 -0
- package/skills/egbe-os-product-market-research/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-market-research/references/catalog.v1.json +177 -0
- package/skills/egbe-os-product-market-research/references/config/channel-footprint-sources.v1.json +99 -0
- package/skills/egbe-os-product-market-research/references/config/creative-taxonomy.v1.json +367 -0
- package/skills/egbe-os-product-market-research/references/contracts/creative-video.md +75 -0
- package/skills/egbe-os-product-market-research/references/contracts/funnel-teardown.md +235 -0
- package/skills/egbe-os-product-market-research/references/contracts/geography-comparison.md +71 -0
- package/skills/egbe-os-product-market-research/references/contracts/lifecycle-capture.md +119 -0
- package/skills/egbe-os-product-market-research/references/contracts/research-artifacts.md +520 -0
- package/skills/egbe-os-product-market-research/references/contracts/walk-mechanics.v2.json +18 -0
- package/skills/egbe-os-product-market-research/references/prompts/acquisition-channels.md +137 -0
- package/skills/egbe-os-product-market-research/references/prompts/acquisition-channels.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/competitive-landscape.md +118 -0
- package/skills/egbe-os-product-market-research/references/prompts/competitive-landscape.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/demand-validation.md +154 -0
- package/skills/egbe-os-product-market-research/references/prompts/demand-validation.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/market-size-and-dynamics.md +100 -0
- package/skills/egbe-os-product-market-research/references/prompts/market-size-and-dynamics.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/pricing-and-monetization.md +126 -0
- package/skills/egbe-os-product-market-research/references/prompts/pricing-and-monetization.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/target-audience.md +98 -0
- package/skills/egbe-os-product-market-research/references/prompts/target-audience.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/unit-economics.md +217 -0
- package/skills/egbe-os-product-market-research/references/prompts/unit-economics.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/value-proposition.md +113 -0
- package/skills/egbe-os-product-market-research/references/prompts/value-proposition.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/workflows/acquisition-channels.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/channel-footprint.md +163 -0
- package/skills/egbe-os-product-market-research/references/workflows/community-demand.md +100 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitive-landscape.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitor-ads.md +82 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitor-set.md +300 -0
- package/skills/egbe-os-product-market-research/references/workflows/creative-patterns.md +228 -0
- package/skills/egbe-os-product-market-research/references/workflows/demand-validation.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/fleet-prior.md +80 -0
- package/skills/egbe-os-product-market-research/references/workflows/funnel-teardown.md +184 -0
- package/skills/egbe-os-product-market-research/references/workflows/geography-comparison.md +84 -0
- package/skills/egbe-os-product-market-research/references/workflows/keyword-economics.md +122 -0
- package/skills/egbe-os-product-market-research/references/workflows/lifecycle-capture.md +218 -0
- package/skills/egbe-os-product-market-research/references/workflows/local-research.md +55 -0
- package/skills/egbe-os-product-market-research/references/workflows/market-size-and-dynamics.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/preview.md +175 -0
- package/skills/egbe-os-product-market-research/references/workflows/pricing-and-monetization.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/recommendations.md +35 -0
- package/skills/egbe-os-product-market-research/references/workflows/review-mining.md +76 -0
- package/skills/egbe-os-product-market-research/references/workflows/target-audience.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/tiktok-reels-market-trends.md +46 -0
- package/skills/egbe-os-product-market-research/references/workflows/unit-economics.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/value-proposition.md +27 -0
- package/skills/egbe-os-product-market-research/scripts/build-organic-trend-context.py +167 -0
- package/skills/egbe-os-product-market-research/scripts/build-preview-context.py +91 -0
- package/skills/egbe-os-product-market-research/scripts/build-research-query.py +225 -0
- package/skills/egbe-os-product-market-research/scripts/channel-footprint-model.py +294 -0
- package/skills/egbe-os-product-market-research/scripts/connection_identity.py +22 -0
- package/skills/egbe-os-product-market-research/scripts/creative-model.py +364 -0
- package/skills/egbe-os-product-market-research/scripts/creative-selection.py +113 -0
- package/skills/egbe-os-product-market-research/scripts/creative-semantics.py +365 -0
- package/skills/egbe-os-product-market-research/scripts/creative-video.py +542 -0
- package/skills/egbe-os-product-market-research/scripts/egbe_artifacts.py +24 -0
- package/skills/egbe-os-product-market-research/scripts/finalize-organic-trend-watch.py +304 -0
- package/skills/egbe-os-product-market-research/scripts/funnel-email-review.py +97 -0
- package/skills/egbe-os-product-market-research/scripts/funnel-model.py +966 -0
- package/skills/egbe-os-product-market-research/scripts/funnel_features.py +50 -0
- package/skills/egbe-os-product-market-research/scripts/geography-comparison-contract.py +172 -0
- package/skills/egbe-os-product-market-research/scripts/geography-comparison.py +169 -0
- package/skills/egbe-os-product-market-research/scripts/keyword-forecast.py +61 -0
- package/skills/egbe-os-product-market-research/scripts/keyword-locale-publication.py +136 -0
- package/skills/egbe-os-product-market-research/scripts/lifecycle-start.py +190 -0
- package/skills/egbe-os-product-market-research/scripts/persist-research-report.py +63 -0
- package/skills/egbe-os-product-market-research/scripts/research-artifact-io.py +281 -0
- package/skills/egbe-os-product-market-research/scripts/research-evidence.py +496 -0
- package/skills/egbe-os-product-market-research/scripts/research-policy.py +33 -0
- package/skills/egbe-os-product-market-research/scripts/research-section-runtime.py +343 -0
- package/skills/egbe-os-product-market-research/scripts/research-section-workflow.py +288 -0
- package/skills/egbe-os-product-market-research/scripts/research_integrity.py +122 -0
- package/skills/egbe-os-product-market-research/scripts/review-research-completion.py +306 -0
- package/skills/egbe-os-product-market-research/scripts/run-acquisition-channels.py +72 -0
- package/skills/egbe-os-product-market-research/scripts/run-channel-footprint.py +2258 -0
- package/skills/egbe-os-product-market-research/scripts/run-community-demand.py +1603 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitive-landscape.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitor-ads.py +1156 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitor-set.py +2514 -0
- package/skills/egbe-os-product-market-research/scripts/run-creative-patterns.py +2042 -0
- package/skills/egbe-os-product-market-research/scripts/run-demand-validation.py +72 -0
- package/skills/egbe-os-product-market-research/scripts/run-fleet-prior.py +652 -0
- package/skills/egbe-os-product-market-research/scripts/run-funnel-teardown.py +493 -0
- package/skills/egbe-os-product-market-research/scripts/run-keyword-economics.py +1443 -0
- package/skills/egbe-os-product-market-research/scripts/run-lifecycle-capture.py +1543 -0
- package/skills/egbe-os-product-market-research/scripts/run-market-size-and-dynamics.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-os-research.py +311 -0
- package/skills/egbe-os-product-market-research/scripts/run-pricing-and-monetization.py +71 -0
- package/skills/egbe-os-product-market-research/scripts/run-review-mining.py +1051 -0
- package/skills/egbe-os-product-market-research/scripts/run-target-audience.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-unit-economics.py +71 -0
- package/skills/egbe-os-product-market-research/scripts/run-value-proposition.py +67 -0
- package/skills/egbe-os-product-market-research/scripts/upsert-markdown-section.py +156 -0
- package/skills/egbe-os-product-market-research/scripts/walk-funnels.py +249 -0
- package/skills/egbe-os-product-market-research/scripts/write-preview.py +710 -0
- package/skills/egbe-os-product-market-research/scripts/write-recommendations.py +272 -0
- package/skills/egbe-os-product-report/SKILL.md +150 -0
- package/skills/egbe-os-product-report/references/artifacts.md +84 -0
- package/skills/egbe-os-product-report/references/brief.md +34 -0
- package/skills/egbe-os-product-report/references/daily.md +76 -0
- package/skills/egbe-os-product-report/references/sources.md +68 -0
- package/skills/egbe-os-product-routines/SKILL.md +166 -0
- package/skills/egbe-os-product-routines/references/catalog.md +22 -0
- package/skills/egbe-os-product-routines/references/continuation-check.md +41 -0
- package/skills/egbe-os-product-routines/references/product-reporting.md +163 -0
- package/skills/egbe-os-product-routines/references/run-preset.md +32 -0
- package/skills/egbe-os-quickstart/scripts/egbe-curl.py +357 -0
- package/skills/egbe-os-quiz-funnel/SKILL.md +152 -0
- package/skills/egbe-os-quiz-funnel/agents/openai.yaml +4 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.d.mts +224 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.mjs +652 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.test.mjs +764 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.d.mts +31 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.mjs +87 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.test.mjs +265 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-reference.test.mjs +254 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/QUIZ.md +195 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/quiz.json +421 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/quiz.public.json +369 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/validation.json +21 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/index.html +26 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-bootstrap.js +31 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-early-actions.mjs +11 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-first-screen.mjs +32 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-page.mjs +480 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz.css +264 -0
- package/skills/egbe-os-quiz-funnel/references/competitor-teardown.md +159 -0
- package/skills/egbe-os-quiz-funnel/references/conversion-handoff.md +156 -0
- package/skills/egbe-os-quiz-funnel/references/implementation.md +207 -0
- package/skills/egbe-os-quiz-funnel/references/inputs.md +37 -0
- package/skills/egbe-os-quiz-funnel/references/measurement.md +122 -0
- package/skills/egbe-os-quiz-funnel/references/spec-contract.md +335 -0
- package/skills/egbe-os-quiz-funnel/references/verification.md +101 -0
- package/skills/egbe-os-quiz-funnel/references/walk-mechanics.v2.json +18 -0
- package/skills/egbe-os-quiz-funnel/scripts/compile-quiz-spec.py +1869 -0
- package/skills/egbe-os-quiz-funnel/scripts/prepare-research-identity.py +66 -0
- package/skills/egbe-os-reddit-ads/SKILL.md +121 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/bold-statement/schema.json +41 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/bold-statement/template.html +106 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/data-proof/schema.json +61 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/data-proof/template.html +151 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/honest-breakdown/schema.json +91 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/honest-breakdown/template.html +185 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/question-hook/schema.json +51 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/question-hook/template.html +121 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/reddit-post-style/schema.json +87 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/reddit-post-style/template.html +212 -0
- package/skills/egbe-os-reddit-ads/references/creative/html-to-png-pipeline.md +123 -0
- package/skills/egbe-os-reddit-ads/references/creative/static-banner-qa.md +12 -0
- package/skills/egbe-os-reddit-ads/references/creative/static-banner-system.md +16 -0
- package/skills/egbe-os-reddit-ads/references/destination-requirements.md +36 -0
- package/skills/egbe-os-reddit-ads/references/runtime/api-reference.md +435 -0
- package/skills/egbe-os-reddit-ads/references/runtime/artifacts.md +57 -0
- package/skills/egbe-os-reddit-ads/references/runtime/monitoring.md +64 -0
- package/skills/egbe-os-reddit-ads/references/runtime/pixel-and-tracking.md +49 -0
- package/skills/egbe-os-reddit-ads/references/runtime/policies.md +19 -0
- package/skills/egbe-os-reddit-ads/references/runtime/shared-analytics-attribution.md +14 -0
- package/skills/egbe-os-reddit-ads/references/workflows/build-paused.md +35 -0
- package/skills/egbe-os-reddit-ads/references/workflows/launch-ready.md +19 -0
- package/skills/egbe-os-reddit-ads/references/workflows/launch.md +32 -0
- package/skills/egbe-os-reddit-ads/references/workflows/readiness.md +9 -0
- package/skills/egbe-os-reddit-ads/scripts/capture-ad.sh +178 -0
- package/skills/egbe-os-reddit-ads/scripts/validate-reddit-artifacts.py +187 -0
- package/skills/egbe-os-report-ui/SKILL.md +133 -0
- package/skills/egbe-os-report-ui/assets/egbe-wordmark.svg +9 -0
- package/skills/egbe-os-report-ui/assets/examples/components.html +417 -0
- package/skills/egbe-os-report-ui/assets/examples/editorial.html +209 -0
- package/skills/egbe-os-report-ui/assets/scaffold.html +179 -0
- package/skills/egbe-os-report-ui/references/components.md +209 -0
- package/skills/egbe-os-research/SKILL.md +125 -0
- package/skills/egbe-os-saas-unit-economics/SKILL.md +188 -0
- package/skills/egbe-os-scrape/SKILL.md +160 -0
- package/skills/egbe-os-search/SKILL.md +182 -0
- package/skills/egbe-os-search/references/google-places.md +81 -0
- package/skills/egbe-os-support/SKILL.md +149 -0
- package/skills/egbe-os-telemetry/SKILL.md +344 -0
- package/skills/egbe-os-telemetry/references/harnesses/claude-code.md +97 -0
- package/skills/egbe-os-telemetry/references/harnesses/codex.md +22 -0
- package/skills/egbe-os-telemetry/references/harnesses/hermes.md +39 -0
- package/skills/egbe-os-telemetry/references/harnesses/openclaw.md +139 -0
- package/skills/egbe-os-telemetry/references/harnesses/opencode.md +28 -0
- package/skills/egbe-os-tools/SKILL.md +180 -0
- package/skills/egbe-os-tools/references/theona.md +26 -0
- package/skills/egbe-os-wallet/SKILL.md +181 -0
- package/skills/egbe-setup/EGBE.md +484 -0
- package/skills/egbe-setup/SKILL.md +116 -0
- package/skills/egbe-setup/references/project.md +80 -0
- package/state.js +37 -0
- package/update.js +361 -0
|
@@ -0,0 +1,764 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import test from "node:test";
|
|
4
|
+
|
|
5
|
+
import { PUBLIC_CONTRACT, createQuiz } from "./quiz-engine.mjs";
|
|
6
|
+
|
|
7
|
+
const example = JSON.parse(
|
|
8
|
+
await readFile(
|
|
9
|
+
new URL("../examples/egbe-docs/product/quizzes/books-checkup/quiz.public.json", import.meta.url),
|
|
10
|
+
"utf8",
|
|
11
|
+
),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const DEFAULT_ANSWERS = {
|
|
15
|
+
role: "freelancer",
|
|
16
|
+
behind: "many",
|
|
17
|
+
tracking: "sheet",
|
|
18
|
+
worries: ["deadline"],
|
|
19
|
+
volume: "mid",
|
|
20
|
+
penalty: "no",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function spec(changes = {}) {
|
|
24
|
+
return { ...structuredClone(example), ...changes };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function screenOf(quizSpec, id) {
|
|
28
|
+
return quizSpec.screens.find((screen) => screen.id === id);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function memoryStorage(initial = {}) {
|
|
32
|
+
const items = new Map(Object.entries(initial));
|
|
33
|
+
return {
|
|
34
|
+
getItem: (key) => (items.has(key) ? items.get(key) : null),
|
|
35
|
+
setItem: (key, value) => items.set(key, String(value)),
|
|
36
|
+
removeItem: (key) => items.delete(key),
|
|
37
|
+
items,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function recorder() {
|
|
42
|
+
const events = [];
|
|
43
|
+
return { events, onEvent: (event) => events.push(event) };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Answer screens until `stop` is the current screen, or until the result. */
|
|
47
|
+
function walk(quiz, answers = {}, stop = null) {
|
|
48
|
+
const chosen = { ...DEFAULT_ANSWERS, ...answers };
|
|
49
|
+
while (!quiz.snapshot().atResult && quiz.snapshot().screen.id !== stop) {
|
|
50
|
+
const { screen } = quiz.snapshot();
|
|
51
|
+
if (screen.type === "interstitial") {
|
|
52
|
+
quiz.advance();
|
|
53
|
+
} else if (screen.select === "multi") {
|
|
54
|
+
for (const optionId of chosen[screen.id]) quiz.toggle(optionId);
|
|
55
|
+
quiz.advance();
|
|
56
|
+
} else {
|
|
57
|
+
quiz.select(chosen[screen.id]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return quiz;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
test("rejects a specification of another contract", () => {
|
|
64
|
+
assert.throws(() => createQuiz({ contract: "something-else" }), /quiz-funnel-public-v1/);
|
|
65
|
+
assert.throws(() => createQuiz(spec({ screens: [] })), /no screens/);
|
|
66
|
+
assert.throws(() => createQuiz(spec({ results: [] })), /no results/);
|
|
67
|
+
assert.equal(example.contract, PUBLIC_CONTRACT);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("opens on the first question and advances on a single choice", () => {
|
|
71
|
+
const { events, onEvent } = recorder();
|
|
72
|
+
const quiz = createQuiz(spec(), { onEvent });
|
|
73
|
+
|
|
74
|
+
const first = quiz.snapshot();
|
|
75
|
+
assert.equal(first.index, 0);
|
|
76
|
+
assert.equal(first.screen.id, "role");
|
|
77
|
+
assert.equal(first.screen.type, "question");
|
|
78
|
+
assert.equal(first.screen.lead, "Find out what your books need before tax season.");
|
|
79
|
+
assert.equal(first.canGoBack, false);
|
|
80
|
+
assert.equal(first.canAdvance, false);
|
|
81
|
+
assert.equal(first.progressLabel, "Step 1 of 8");
|
|
82
|
+
|
|
83
|
+
const second = quiz.select("studio");
|
|
84
|
+
assert.equal(second.screen.id, "behind");
|
|
85
|
+
assert.equal(second.position, 2);
|
|
86
|
+
assert.deepEqual(events, [
|
|
87
|
+
{
|
|
88
|
+
name: "button_click",
|
|
89
|
+
data: {
|
|
90
|
+
product_slug: "example-books",
|
|
91
|
+
path: "/quiz/books-checkup",
|
|
92
|
+
surface: "quiz",
|
|
93
|
+
button_id: "role.studio",
|
|
94
|
+
button_role: "quiz_answer",
|
|
95
|
+
position: 1,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("refuses unknown options and the wrong kind of step", () => {
|
|
102
|
+
const quiz = createQuiz(spec());
|
|
103
|
+
assert.throws(() => quiz.select("nobody"), /no option nobody/);
|
|
104
|
+
assert.throws(() => quiz.advance(), /advances through select/);
|
|
105
|
+
assert.throws(() => quiz.toggle("freelancer"), /not a multi-select question/);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("a tap that arrives after the screen has changed is ignored", () => {
|
|
109
|
+
const { events, onEvent } = recorder();
|
|
110
|
+
const quiz = createQuiz(spec(), { onEvent });
|
|
111
|
+
quiz.select("studio", "role");
|
|
112
|
+
events.length = 0;
|
|
113
|
+
|
|
114
|
+
// A second tap meant for the first screen lands while the second is shown.
|
|
115
|
+
assert.equal(quiz.select("few", "role").screen.id, "behind");
|
|
116
|
+
assert.equal(quiz.toggle("few", "worries").screen.id, "behind");
|
|
117
|
+
assert.equal(quiz.advance("halfway").screen.id, "behind");
|
|
118
|
+
assert.deepEqual(quiz.answers(), { role: ["studio"] });
|
|
119
|
+
assert.deepEqual(events, []);
|
|
120
|
+
|
|
121
|
+
assert.equal(quiz.select("few", "behind").screen.id, "tracking");
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("a multi-select question needs a choice and reports it in option order", () => {
|
|
125
|
+
const { events, onEvent } = recorder();
|
|
126
|
+
const quiz = walk(createQuiz(spec(), { onEvent }), {}, "worries");
|
|
127
|
+
events.length = 0;
|
|
128
|
+
|
|
129
|
+
const screen = quiz.snapshot();
|
|
130
|
+
assert.equal(screen.screen.hint, "Choose all that apply.");
|
|
131
|
+
assert.equal(screen.canAdvance, false);
|
|
132
|
+
assert.throws(() => quiz.advance(), /needs at least one option/);
|
|
133
|
+
|
|
134
|
+
quiz.toggle("audit");
|
|
135
|
+
quiz.toggle("deadline");
|
|
136
|
+
quiz.toggle("cashflow");
|
|
137
|
+
assert.deepEqual(quiz.toggle("cashflow").selected, ["audit", "deadline"]);
|
|
138
|
+
assert.equal(quiz.snapshot().canAdvance, true);
|
|
139
|
+
assert.deepEqual(events, [], "switching an option is not an analytics event");
|
|
140
|
+
|
|
141
|
+
assert.equal(quiz.advance().screen.id, "volume");
|
|
142
|
+
assert.equal(events.length, 1);
|
|
143
|
+
assert.equal(events[0].data.button_id, "worries.continue");
|
|
144
|
+
assert.equal(events[0].data.button_role, "quiz_answer");
|
|
145
|
+
assert.equal(events[0].data.state, "deadline+audit");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test("an escape option excludes the other options of a multi-select question", () => {
|
|
149
|
+
const quiz = walk(createQuiz(spec()), {}, "worries");
|
|
150
|
+
quiz.toggle("deadline");
|
|
151
|
+
assert.deepEqual(quiz.toggle("nothing").selected, ["nothing"]);
|
|
152
|
+
assert.deepEqual(quiz.toggle("audit").selected, ["audit"]);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("the answer to a sensitive question stays on the page", () => {
|
|
156
|
+
const { events, onEvent } = recorder();
|
|
157
|
+
const quiz = walk(createQuiz(spec(), { onEvent }), {}, "penalty");
|
|
158
|
+
events.length = 0;
|
|
159
|
+
|
|
160
|
+
assert.equal(quiz.snapshot().screen.sensitive, true);
|
|
161
|
+
quiz.select("yes");
|
|
162
|
+
assert.equal(events[0].data.button_id, "penalty.answered");
|
|
163
|
+
assert.deepEqual(quiz.answers().penalty, ["yes"], "the page itself keeps the answer");
|
|
164
|
+
|
|
165
|
+
const multi = spec();
|
|
166
|
+
screenOf(multi, "worries").sensitive = true;
|
|
167
|
+
const second = recorder();
|
|
168
|
+
const sensitive = walk(createQuiz(multi, { onEvent: second.onEvent }), {}, "volume");
|
|
169
|
+
const confirmed = second.events.at(-1).data;
|
|
170
|
+
assert.equal(confirmed.button_id, "worries.continue");
|
|
171
|
+
assert.equal("state" in confirmed, false);
|
|
172
|
+
assert.deepEqual(sensitive.answers().worries, ["deadline"]);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("an interstitial screen shows its own texts or the first matching variant", () => {
|
|
176
|
+
const { events, onEvent } = recorder();
|
|
177
|
+
const plain = walk(createQuiz(spec(), { onEvent }), { behind: "few" }, "halfway");
|
|
178
|
+
assert.deepEqual(plain.snapshot().screen, {
|
|
179
|
+
id: "halfway",
|
|
180
|
+
type: "interstitial",
|
|
181
|
+
kind: "encouragement",
|
|
182
|
+
headline: "You are halfway there",
|
|
183
|
+
points: [],
|
|
184
|
+
proof: [],
|
|
185
|
+
media: null,
|
|
186
|
+
button: "Continue",
|
|
187
|
+
body: "Three more answers and you will see what your books need first.",
|
|
188
|
+
});
|
|
189
|
+
assert.equal(plain.snapshot().canAdvance, true);
|
|
190
|
+
|
|
191
|
+
events.length = 0;
|
|
192
|
+
plain.advance();
|
|
193
|
+
assert.deepEqual(events[0].data, {
|
|
194
|
+
product_slug: "example-books",
|
|
195
|
+
path: "/quiz/books-checkup",
|
|
196
|
+
surface: "quiz",
|
|
197
|
+
button_id: "halfway.continue",
|
|
198
|
+
button_role: "quiz_continue",
|
|
199
|
+
position: 4,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const adapted = walk(createQuiz(spec()), { behind: "year" }, "halfway").snapshot().screen;
|
|
203
|
+
assert.equal(adapted.headline, "This is what a catch-up is for");
|
|
204
|
+
assert.equal(
|
|
205
|
+
adapted.body,
|
|
206
|
+
"Books that are over a year behind can be reconciled month by month. " +
|
|
207
|
+
"Three more answers and you will see where to start.",
|
|
208
|
+
);
|
|
209
|
+
assert.equal(adapted.button, "Continue");
|
|
210
|
+
assert.equal("variants" in adapted, false);
|
|
211
|
+
assert.equal("when" in adapted, false);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("an interstitial screen lists the proof it shows", () => {
|
|
215
|
+
const screen = walk(createQuiz(spec()), {}, "how").snapshot().screen;
|
|
216
|
+
assert.deepEqual(screen.proof, [
|
|
217
|
+
{
|
|
218
|
+
id: "review-summary",
|
|
219
|
+
kind: "fact",
|
|
220
|
+
text: "The review takes 20 minutes and you keep the written summary.",
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: "one-bookkeeper",
|
|
224
|
+
kind: "fact",
|
|
225
|
+
text: "One bookkeeper handles your books from the first month to the last.",
|
|
226
|
+
},
|
|
227
|
+
]);
|
|
228
|
+
|
|
229
|
+
const custom = spec();
|
|
230
|
+
screenOf(custom, "how").variants = [
|
|
231
|
+
{
|
|
232
|
+
when: { any: [{ screen: "worries", any_of: ["audit"] }] },
|
|
233
|
+
proof_ids: ["one-bookkeeper"],
|
|
234
|
+
points: ["You named {{answer:worries}}"],
|
|
235
|
+
},
|
|
236
|
+
];
|
|
237
|
+
const varied = walk(createQuiz(custom), { worries: ["audit", "cashflow"] }, "how");
|
|
238
|
+
assert.deepEqual(
|
|
239
|
+
varied.snapshot().screen.proof.map((proof) => proof.id),
|
|
240
|
+
["one-bookkeeper"],
|
|
241
|
+
);
|
|
242
|
+
assert.deepEqual(varied.snapshot().screen.points, ["You named cash flow, an audit"]);
|
|
243
|
+
assert.equal(varied.snapshot().screen.headline, "Here is how the review works");
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test("back keeps the answers and stops at the first screen", () => {
|
|
247
|
+
const quiz = createQuiz(spec());
|
|
248
|
+
quiz.select("shop");
|
|
249
|
+
quiz.select("few");
|
|
250
|
+
|
|
251
|
+
const previous = quiz.back();
|
|
252
|
+
assert.equal(previous.screen.id, "behind");
|
|
253
|
+
assert.deepEqual(previous.selected, ["few"]);
|
|
254
|
+
assert.equal(quiz.back().screen.id, "role");
|
|
255
|
+
assert.equal(quiz.back().index, 0);
|
|
256
|
+
assert.deepEqual(quiz.answers(), { role: ["shop"], behind: ["few"] });
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
test("the browser's back and forward reach only screens already reached", () => {
|
|
260
|
+
const quiz = walk(createQuiz(spec()), {}, "worries");
|
|
261
|
+
assert.equal(quiz.snapshot().index, 4);
|
|
262
|
+
|
|
263
|
+
assert.equal(quiz.goTo(1).screen.id, "behind");
|
|
264
|
+
assert.equal(quiz.goTo(4).screen.id, "worries", "forward to the furthest screen reached");
|
|
265
|
+
assert.equal(quiz.goTo(5).screen.id, "worries", "not past an unanswered question");
|
|
266
|
+
assert.equal(quiz.goTo(-1).screen.id, "worries");
|
|
267
|
+
assert.equal(quiz.goTo(1.5).screen.id, "worries");
|
|
268
|
+
assert.equal(quiz.goTo("2").screen.id, "worries");
|
|
269
|
+
|
|
270
|
+
const finished = walk(createQuiz(spec()));
|
|
271
|
+
assert.equal(finished.goTo(0).screen.id, "role");
|
|
272
|
+
assert.equal(finished.goTo(8).atResult, true);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
test("there is no result before the answers decide it", () => {
|
|
276
|
+
const quiz = createQuiz(spec());
|
|
277
|
+
quiz.select("freelancer");
|
|
278
|
+
assert.equal(quiz.result(), null);
|
|
279
|
+
assert.equal(quiz.cta(), null);
|
|
280
|
+
quiz.select("current");
|
|
281
|
+
assert.equal(quiz.result(), null, "the tracking answer can still change the result");
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
test("a not-fit result appears as soon as the answers decide it", () => {
|
|
285
|
+
const { events, onEvent } = recorder();
|
|
286
|
+
const quiz = createQuiz(spec(), { onEvent });
|
|
287
|
+
quiz.select("freelancer");
|
|
288
|
+
quiz.select("current");
|
|
289
|
+
const view = quiz.select("app");
|
|
290
|
+
|
|
291
|
+
assert.equal(view.atResult, true, "the remaining questions would not change it");
|
|
292
|
+
assert.equal(view.index, example.screens.length);
|
|
293
|
+
assert.equal(quiz.result().id, "in-shape");
|
|
294
|
+
assert.equal(quiz.cta().event.data.cta_role, "alternative");
|
|
295
|
+
assert.deepEqual(
|
|
296
|
+
events.map((event) => [event.data.button_id, event.data.position]),
|
|
297
|
+
[["role.freelancer", 1], ["behind.current", 2], ["tracking.app", 3]],
|
|
298
|
+
);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
test("a fit or partial result waits for every question", () => {
|
|
302
|
+
// Nothing after "behind" can turn these answers into a not-fit result, but
|
|
303
|
+
// the fitting results quote later answers: the visitor answers them all.
|
|
304
|
+
const quiz = createQuiz(spec());
|
|
305
|
+
quiz.select("freelancer");
|
|
306
|
+
assert.equal(quiz.select("few").screen.id, "tracking");
|
|
307
|
+
assert.equal(quiz.select("sheet").screen.id, "halfway");
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
test("an earlier result that a later answer can still reach keeps the questions coming", () => {
|
|
311
|
+
const custom = spec();
|
|
312
|
+
custom.results = [
|
|
313
|
+
{ id: "busy", fit: "fit", when: { all: [{ screen: "volume", any_of: ["high"] }] }, headline: "Busy", body: "Body", cta: { label: "Go" } },
|
|
314
|
+
{ id: "current", fit: "not_fit", when: { all: [{ screen: "behind", any_of: ["current"] }] }, headline: "Current", body: "Body", cta: null },
|
|
315
|
+
{ id: "rest", fit: "partial", headline: "Rest", body: "Body", cta: { label: "Go" } },
|
|
316
|
+
];
|
|
317
|
+
const quiz = walk(createQuiz(custom), { behind: "current" }, "volume");
|
|
318
|
+
assert.equal(quiz.snapshot().screen.id, "volume", "a high volume would still lead to busy");
|
|
319
|
+
const view = quiz.select("low");
|
|
320
|
+
assert.equal(view.atResult, true, "after the volume the not-fit result is decided");
|
|
321
|
+
assert.equal(quiz.result().id, "current");
|
|
322
|
+
assert.equal(quiz.back().screen.id, "volume");
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
test("back and the browser's history return to the deciding question, not to skipped screens", () => {
|
|
326
|
+
const quiz = createQuiz(spec());
|
|
327
|
+
quiz.select("freelancer");
|
|
328
|
+
quiz.select("current");
|
|
329
|
+
quiz.select("app");
|
|
330
|
+
|
|
331
|
+
assert.equal(quiz.goTo(3).atResult, true, "the interstitial after the deciding question is skipped");
|
|
332
|
+
assert.equal(quiz.goTo(7).atResult, true);
|
|
333
|
+
const back = quiz.back();
|
|
334
|
+
assert.equal(back.screen.id, "tracking");
|
|
335
|
+
assert.deepEqual(back.selected, ["app"]);
|
|
336
|
+
assert.equal(quiz.goTo(example.screens.length).atResult, true, "forward to the result again");
|
|
337
|
+
assert.equal(quiz.goTo(1).screen.id, "behind");
|
|
338
|
+
|
|
339
|
+
// Another answer to the deciding question continues with the remaining screens.
|
|
340
|
+
quiz.goTo(2);
|
|
341
|
+
assert.equal(quiz.select("sheet").screen.id, "halfway");
|
|
342
|
+
assert.equal(quiz.goTo(3).screen.id, "halfway");
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
test("an early result quotes only the answers that decided it", () => {
|
|
346
|
+
const custom = spec();
|
|
347
|
+
const inShape = custom.results.find((result) => result.id === "in-shape");
|
|
348
|
+
inShape.headline = "Books {{answer:behind}}";
|
|
349
|
+
inShape.points = ["Invoices a month: {{answer:volume}}", "Tracked with {{answer:tracking}}"];
|
|
350
|
+
|
|
351
|
+
// A full path first, then back to the tracking question and a deciding answer.
|
|
352
|
+
const quiz = walk(createQuiz(custom), { behind: "current", tracking: "sheet", volume: "high" });
|
|
353
|
+
assert.equal(quiz.result().id, "review");
|
|
354
|
+
quiz.goTo(2);
|
|
355
|
+
quiz.select("app");
|
|
356
|
+
const result = quiz.result();
|
|
357
|
+
assert.equal(result.id, "in-shape");
|
|
358
|
+
assert.equal(result.headline, "Books up to date");
|
|
359
|
+
assert.deepEqual(result.points, ["Tracked with an accounting app"], "the old volume answer is not quoted");
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
test("a not-fit result that quotes a later answer in a sentence waits for it", () => {
|
|
363
|
+
const custom = spec();
|
|
364
|
+
custom.results.find((result) => result.id === "in-shape").body = "About {{answer:volume}} invoices a month.";
|
|
365
|
+
const quiz = createQuiz(custom);
|
|
366
|
+
quiz.select("freelancer");
|
|
367
|
+
quiz.select("current");
|
|
368
|
+
assert.equal(quiz.select("app").screen.id, "halfway", "the sentence would break without the volume");
|
|
369
|
+
const finished = walk(quiz, { behind: "current", tracking: "app" });
|
|
370
|
+
assert.equal(finished.result().body, "About 10 to 50 invoices a month.");
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
test("a reload keeps an early result, and a saved later screen shows it", () => {
|
|
374
|
+
const storage = memoryStorage();
|
|
375
|
+
const quiz = createQuiz(spec(), { storage });
|
|
376
|
+
quiz.select("freelancer");
|
|
377
|
+
quiz.select("current");
|
|
378
|
+
quiz.select("app");
|
|
379
|
+
const reloaded = createQuiz(spec(), { storage });
|
|
380
|
+
assert.equal(reloaded.snapshot().atResult, true);
|
|
381
|
+
assert.equal(reloaded.result().id, "in-shape");
|
|
382
|
+
assert.equal(reloaded.back().screen.id, "tracking");
|
|
383
|
+
|
|
384
|
+
const key = "quiz-funnel:books-checkup";
|
|
385
|
+
const answers = { role: ["freelancer"], behind: ["current"], tracking: ["app"] };
|
|
386
|
+
const later = memoryStorage({ [key]: JSON.stringify({ version: example.public_sha256, index: 4, answers }) });
|
|
387
|
+
assert.equal(createQuiz(spec(), { storage: later }).snapshot().atResult, true);
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
test("too many remaining answers leave the decision to the last screen", () => {
|
|
391
|
+
const custom = spec();
|
|
392
|
+
const many = (id) => ({
|
|
393
|
+
id,
|
|
394
|
+
type: "question",
|
|
395
|
+
select: "multi",
|
|
396
|
+
headline: "Pick",
|
|
397
|
+
hint: "Choose all that apply.",
|
|
398
|
+
button: "Continue",
|
|
399
|
+
options: Array.from({ length: 11 }, (_, n) => ({ id: `o${n}`, label: `Option ${n}` })),
|
|
400
|
+
});
|
|
401
|
+
custom.screens.push(many("first"), many("second"));
|
|
402
|
+
custom.results.unshift({
|
|
403
|
+
id: "picky",
|
|
404
|
+
fit: "fit",
|
|
405
|
+
when: { all: [{ screen: "first", any_of: ["o1"] }, { screen: "second", any_of: ["o1"] }] },
|
|
406
|
+
headline: "Picky",
|
|
407
|
+
body: "Body",
|
|
408
|
+
cta: { label: "Go" },
|
|
409
|
+
});
|
|
410
|
+
custom.results.find((result) => result.id === "in-shape").when.all.push({ screen: "first", none_of: ["o0"] });
|
|
411
|
+
const quiz = createQuiz(custom);
|
|
412
|
+
quiz.select("freelancer");
|
|
413
|
+
quiz.select("current");
|
|
414
|
+
assert.equal(quiz.select("app").screen.id, "halfway", "2^11 x 2^11 combinations are too many to be sure");
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
test("the first matching result wins and the last one is the default", () => {
|
|
418
|
+
const cases = [
|
|
419
|
+
[{ behind: "many", volume: "high" }, "planned-catch-up"],
|
|
420
|
+
[{ behind: "year", volume: "low" }, "catch-up"],
|
|
421
|
+
[{ behind: "few" }, "tidy-up"],
|
|
422
|
+
[{ behind: "current", tracking: "app" }, "in-shape"],
|
|
423
|
+
[{ behind: "current", tracking: "sheet" }, "review"],
|
|
424
|
+
];
|
|
425
|
+
for (const [answers, expected] of cases) {
|
|
426
|
+
const quiz = walk(createQuiz(spec()), answers);
|
|
427
|
+
assert.equal(quiz.result().id, expected, JSON.stringify(answers));
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
test("conditions support any, none_of, and multi-select answers", () => {
|
|
432
|
+
const custom = spec();
|
|
433
|
+
custom.results = [
|
|
434
|
+
{
|
|
435
|
+
id: "worried",
|
|
436
|
+
fit: "fit",
|
|
437
|
+
when: {
|
|
438
|
+
any: [
|
|
439
|
+
{ screen: "worries", any_of: ["audit"] },
|
|
440
|
+
{ screen: "volume", any_of: ["high"] },
|
|
441
|
+
],
|
|
442
|
+
},
|
|
443
|
+
headline: "Worried",
|
|
444
|
+
body: "Body",
|
|
445
|
+
cta: { label: "Go" },
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
id: "calm",
|
|
449
|
+
fit: "partial",
|
|
450
|
+
when: { all: [{ screen: "worries", none_of: ["deadline", "audit"] }] },
|
|
451
|
+
headline: "Calm",
|
|
452
|
+
body: "Body",
|
|
453
|
+
cta: { label: "Go" },
|
|
454
|
+
},
|
|
455
|
+
{ id: "rest", fit: "partial", headline: "Rest", body: "Body", cta: { label: "Go" } },
|
|
456
|
+
];
|
|
457
|
+
|
|
458
|
+
const pick = (answers) => walk(createQuiz(custom), answers).result().id;
|
|
459
|
+
assert.equal(pick({ worries: ["cashflow", "audit"], volume: "low" }), "worried");
|
|
460
|
+
assert.equal(pick({ worries: ["cashflow"], volume: "high" }), "worried");
|
|
461
|
+
assert.equal(pick({ worries: ["cashflow"], volume: "low" }), "calm");
|
|
462
|
+
assert.equal(pick({ worries: ["nothing"], volume: "low" }), "calm");
|
|
463
|
+
assert.equal(pick({ worries: ["deadline"], volume: "low" }), "rest");
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
test("a sentence quotes the answer in its sentence form", () => {
|
|
467
|
+
const review = walk(createQuiz(spec()), { behind: "current", tracking: "bank" }).result();
|
|
468
|
+
assert.match(review.body, /tracking expenses with bank statements only can cost you time/);
|
|
469
|
+
assert.doesNotMatch(review.body, /\{\{/);
|
|
470
|
+
|
|
471
|
+
const unphrased = spec();
|
|
472
|
+
delete screenOf(unphrased, "tracking").options[2].phrase;
|
|
473
|
+
const fallback = walk(createQuiz(unphrased), { behind: "current", tracking: "bank" }).result();
|
|
474
|
+
assert.match(fallback.body, /tracking expenses with Bank statements only can cost/);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
test("points quote any answer and drop what the visitor declined", () => {
|
|
478
|
+
const full = walk(createQuiz(spec()), {
|
|
479
|
+
behind: "current",
|
|
480
|
+
role: "shop",
|
|
481
|
+
volume: "mid",
|
|
482
|
+
worries: ["audit", "deadline"],
|
|
483
|
+
}).result();
|
|
484
|
+
assert.deepEqual(full.points, [
|
|
485
|
+
"Your business: online shop",
|
|
486
|
+
"Invoices a month: 10 to 50",
|
|
487
|
+
"On your mind: the tax deadline, an audit",
|
|
488
|
+
]);
|
|
489
|
+
|
|
490
|
+
const declined = walk(createQuiz(spec()), {
|
|
491
|
+
behind: "current",
|
|
492
|
+
role: "other",
|
|
493
|
+
worries: ["nothing"],
|
|
494
|
+
}).result();
|
|
495
|
+
assert.deepEqual(declined.points, ["Invoices a month: 10 to 50"]);
|
|
496
|
+
|
|
497
|
+
const none = spec();
|
|
498
|
+
delete none.results.at(-1).points;
|
|
499
|
+
assert.deepEqual(walk(createQuiz(none), { behind: "current" }).result().points, []);
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
test("a result lists the proof it shows", () => {
|
|
503
|
+
const custom = spec();
|
|
504
|
+
custom.results.at(-1).proof_ids = ["review-summary"];
|
|
505
|
+
const result = walk(createQuiz(custom), { behind: "current" }).result();
|
|
506
|
+
assert.deepEqual(result.proof, [
|
|
507
|
+
{
|
|
508
|
+
id: "review-summary",
|
|
509
|
+
kind: "fact",
|
|
510
|
+
text: "The review takes 20 minutes and you keep the written summary.",
|
|
511
|
+
},
|
|
512
|
+
]);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
test("screens and results pass their image on", () => {
|
|
516
|
+
const custom = spec();
|
|
517
|
+
const sample = { src: "/quiz/books-checkup/summary.png", alt: "A written summary" };
|
|
518
|
+
const close = { src: "https://cdn.example.com/close.png", alt: "A monthly close" };
|
|
519
|
+
screenOf(custom, "how").media = sample;
|
|
520
|
+
screenOf(custom, "halfway").variants[0].media = close;
|
|
521
|
+
custom.results.at(-1).media = sample;
|
|
522
|
+
|
|
523
|
+
assert.equal(walk(createQuiz(custom), { behind: "few" }, "halfway").snapshot().screen.media, null);
|
|
524
|
+
assert.deepEqual(
|
|
525
|
+
walk(createQuiz(custom), { behind: "year" }, "halfway").snapshot().screen.media,
|
|
526
|
+
close,
|
|
527
|
+
);
|
|
528
|
+
assert.deepEqual(walk(createQuiz(custom), {}, "how").snapshot().screen.media, sample);
|
|
529
|
+
assert.deepEqual(walk(createQuiz(custom), { behind: "current" }).result().media, sample);
|
|
530
|
+
assert.equal(walk(createQuiz(custom)).result().media, null);
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
test("a call to action carries the note that is shown under it", () => {
|
|
534
|
+
const quiz = walk(createQuiz(spec()));
|
|
535
|
+
assert.equal(quiz.cta().note, "The call takes 20 minutes. You keep the written summary.");
|
|
536
|
+
|
|
537
|
+
const other = walk(createQuiz(spec()), { behind: "current", tracking: "app" });
|
|
538
|
+
assert.equal(other.cta().note, null);
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
test("a booking link keeps its own parameters and carries the first touch", () => {
|
|
542
|
+
const custom = spec();
|
|
543
|
+
custom.goal.destination.url = "https://cal.example.com/books-review?utm_medium=partner&seat=2";
|
|
544
|
+
const quiz = walk(createQuiz(custom));
|
|
545
|
+
|
|
546
|
+
const { destination, event, label } = quiz.cta({
|
|
547
|
+
first_utm_source: "meta",
|
|
548
|
+
first_utm_medium: "paid_social",
|
|
549
|
+
first_utm_campaign: " spring ",
|
|
550
|
+
first_utm_content: "ad-7",
|
|
551
|
+
first_fbclid: "click-1",
|
|
552
|
+
email: "person@example.com",
|
|
553
|
+
});
|
|
554
|
+
const params = new URL(destination.href).searchParams;
|
|
555
|
+
|
|
556
|
+
assert.equal(label, "Book the free review");
|
|
557
|
+
assert.equal(destination.kind, "booking_url");
|
|
558
|
+
assert.equal(destination.href.split("?")[0], "https://cal.example.com/books-review");
|
|
559
|
+
assert.equal(params.get("seat"), "2");
|
|
560
|
+
assert.equal(params.get("utm_medium"), "partner", "the address keeps its own value");
|
|
561
|
+
assert.equal(params.get("utm_source"), "meta");
|
|
562
|
+
assert.equal(params.get("utm_campaign"), "spring");
|
|
563
|
+
assert.equal(
|
|
564
|
+
params.get("utm_content"),
|
|
565
|
+
"books-checkup.catch-up",
|
|
566
|
+
"the result parameter is always delivered",
|
|
567
|
+
);
|
|
568
|
+
assert.doesNotMatch(destination.href, /person|click-1|ad-7/);
|
|
569
|
+
assert.deepEqual(event, {
|
|
570
|
+
name: "cta_click",
|
|
571
|
+
data: {
|
|
572
|
+
product_slug: "example-books",
|
|
573
|
+
path: "/quiz/books-checkup",
|
|
574
|
+
surface: "quiz_result",
|
|
575
|
+
cta_id: "catch-up",
|
|
576
|
+
cta_role: "call_primary",
|
|
577
|
+
label: "Book the free review",
|
|
578
|
+
destination: "https://cal.example.com/books-review",
|
|
579
|
+
},
|
|
580
|
+
});
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
test("fallback parameters describe only a visitor without a campaign", () => {
|
|
584
|
+
const quiz = walk(createQuiz(spec()));
|
|
585
|
+
|
|
586
|
+
const direct = new URL(quiz.cta().destination.href).searchParams;
|
|
587
|
+
assert.equal(direct.get("utm_source"), "quiz");
|
|
588
|
+
assert.equal(direct.get("utm_campaign"), "books-checkup");
|
|
589
|
+
assert.equal(direct.get("utm_content"), "books-checkup.catch-up");
|
|
590
|
+
|
|
591
|
+
const paid = new URL(quiz.cta({ first_utm_source: "reddit" }).destination.href).searchParams;
|
|
592
|
+
assert.equal(paid.get("utm_source"), "reddit");
|
|
593
|
+
assert.equal(paid.has("utm_campaign"), false, "no invented campaign for a real source");
|
|
594
|
+
assert.equal(paid.get("utm_content"), "books-checkup.catch-up");
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
test("the result is left out of the link unless a parameter is named for it", () => {
|
|
598
|
+
const custom = spec();
|
|
599
|
+
delete custom.goal.destination.result_param;
|
|
600
|
+
delete custom.goal.destination.fallback_params;
|
|
601
|
+
const quiz = walk(createQuiz(custom));
|
|
602
|
+
assert.equal(quiz.cta().destination.href, "https://cal.example.com/books-review");
|
|
603
|
+
assert.equal(
|
|
604
|
+
quiz.cta({ first_utm_content: "ad-7" }).destination.href,
|
|
605
|
+
"https://cal.example.com/books-review?utm_content=ad-7",
|
|
606
|
+
);
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
test("signup and checkout destinations stay on the product origin", () => {
|
|
610
|
+
const signup = spec();
|
|
611
|
+
signup.goal = { type: "signup", destination: { kind: "signup", path: "/signup?next=/dashboard" } };
|
|
612
|
+
const signupCta = walk(createQuiz(signup)).cta({ first_utm_source: "meta" });
|
|
613
|
+
assert.deepEqual(signupCta.destination, { kind: "signup", href: "/signup?next=/dashboard" });
|
|
614
|
+
assert.equal(signupCta.event.data.cta_role, "signup_primary");
|
|
615
|
+
assert.equal(signupCta.event.data.destination, "/signup");
|
|
616
|
+
|
|
617
|
+
const checkout = spec();
|
|
618
|
+
checkout.goal = {
|
|
619
|
+
type: "payment",
|
|
620
|
+
destination: {
|
|
621
|
+
kind: "checkout",
|
|
622
|
+
path: "/checkout",
|
|
623
|
+
plan_key: "pro monthly",
|
|
624
|
+
price: "$95 per month",
|
|
625
|
+
},
|
|
626
|
+
};
|
|
627
|
+
const checkoutCta = walk(createQuiz(checkout)).cta();
|
|
628
|
+
assert.deepEqual(checkoutCta.destination, {
|
|
629
|
+
kind: "checkout",
|
|
630
|
+
href: "/checkout?plan=pro%20monthly",
|
|
631
|
+
});
|
|
632
|
+
assert.equal(checkoutCta.event.data.cta_role, "checkout_primary");
|
|
633
|
+
|
|
634
|
+
checkout.goal.destination = {
|
|
635
|
+
kind: "checkout",
|
|
636
|
+
path: "/checkout?ref=quiz",
|
|
637
|
+
plan_key: "pro",
|
|
638
|
+
price: "$95 per month",
|
|
639
|
+
plan_param: "tier",
|
|
640
|
+
};
|
|
641
|
+
assert.equal(walk(createQuiz(checkout)).cta().destination.href, "/checkout?ref=quiz&tier=pro");
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
test("a request form receives the shareable answers and the first touch", () => {
|
|
645
|
+
const lead = spec();
|
|
646
|
+
lead.goal = {
|
|
647
|
+
type: "call",
|
|
648
|
+
destination: {
|
|
649
|
+
kind: "lead_form",
|
|
650
|
+
action: "/api/lead",
|
|
651
|
+
fields: ["name", "email"],
|
|
652
|
+
field_labels: { name: "Name", email: "Work email" },
|
|
653
|
+
submit_label: "Request the review",
|
|
654
|
+
error: "We could not send your request. Please try again.",
|
|
655
|
+
success: { headline: "Request received", body: "We will reply within one working day." },
|
|
656
|
+
},
|
|
657
|
+
};
|
|
658
|
+
const { destination, event } = walk(createQuiz(lead), { penalty: "yes" }).cta({
|
|
659
|
+
visitor_id: "v-1",
|
|
660
|
+
first_utm_source: "meta",
|
|
661
|
+
unknown: "dropped",
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
assert.equal(destination.kind, "lead_form");
|
|
665
|
+
assert.equal(destination.action, "/api/lead");
|
|
666
|
+
assert.deepEqual(destination.fields, ["name", "email"]);
|
|
667
|
+
assert.equal(destination.consentNote, null);
|
|
668
|
+
assert.deepEqual(destination.payload, {
|
|
669
|
+
quiz_slug: "books-checkup",
|
|
670
|
+
result_id: "catch-up",
|
|
671
|
+
answers: {
|
|
672
|
+
role: ["freelancer"],
|
|
673
|
+
behind: ["many"],
|
|
674
|
+
tracking: ["sheet"],
|
|
675
|
+
worries: ["deadline"],
|
|
676
|
+
volume: ["mid"],
|
|
677
|
+
},
|
|
678
|
+
attribution: { visitor_id: "v-1", first_utm_source: "meta" },
|
|
679
|
+
});
|
|
680
|
+
assert.equal(event.data.destination, "/api/lead");
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
test("a not-fit result leads to its own destination or to none", () => {
|
|
684
|
+
const quiz = walk(createQuiz(spec()), { behind: "current", tracking: "app" });
|
|
685
|
+
assert.equal(quiz.result().fit, "not_fit");
|
|
686
|
+
const { destination, event } = quiz.cta({ first_utm_source: "meta" });
|
|
687
|
+
assert.deepEqual(destination, { kind: "link", href: "/guides/monthly-close" });
|
|
688
|
+
assert.equal(event.data.cta_role, "alternative");
|
|
689
|
+
|
|
690
|
+
const silent = spec();
|
|
691
|
+
silent.results[0].cta = null;
|
|
692
|
+
const none = walk(createQuiz(silent), { behind: "current", tracking: "app" });
|
|
693
|
+
assert.equal(none.result().hasCta, false);
|
|
694
|
+
assert.equal(none.cta(), null);
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
test("progress survives a reload and a changed page starts over", () => {
|
|
698
|
+
const storage = memoryStorage();
|
|
699
|
+
const first = createQuiz(spec(), { storage });
|
|
700
|
+
first.select("studio");
|
|
701
|
+
first.select("year");
|
|
702
|
+
|
|
703
|
+
const reloaded = createQuiz(spec(), { storage });
|
|
704
|
+
assert.equal(reloaded.snapshot().screen.id, "tracking");
|
|
705
|
+
assert.deepEqual(reloaded.answers(), { role: ["studio"], behind: ["year"] });
|
|
706
|
+
|
|
707
|
+
const notes = createQuiz(spec({ spec_sha256: "edited-internal-notes" }), { storage });
|
|
708
|
+
assert.equal(notes.snapshot().screen.id, "tracking", "only a change of the page resets");
|
|
709
|
+
|
|
710
|
+
const changed = createQuiz(spec({ public_sha256: "another" }), { storage });
|
|
711
|
+
assert.equal(changed.snapshot().index, 0);
|
|
712
|
+
assert.deepEqual(changed.answers(), {});
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
test("a finished quiz restores its result for the product to continue", () => {
|
|
716
|
+
const storage = memoryStorage();
|
|
717
|
+
walk(createQuiz(spec(), { storage }), { behind: "few" });
|
|
718
|
+
assert.equal(createQuiz(spec(), { storage }).result().id, "tidy-up");
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
test("damaged saved state is ignored", () => {
|
|
722
|
+
const key = "quiz-funnel:books-checkup";
|
|
723
|
+
const version = example.public_sha256;
|
|
724
|
+
const damaged = [
|
|
725
|
+
"not json",
|
|
726
|
+
JSON.stringify({ version, index: 99, answers: {} }),
|
|
727
|
+
JSON.stringify({ version, index: 2, answers: { role: ["freelancer"] } }),
|
|
728
|
+
JSON.stringify({ version, index: 1, answers: { role: ["nobody"] } }),
|
|
729
|
+
JSON.stringify({ version, index: 1, answers: { role: ["freelancer", "studio"] } }),
|
|
730
|
+
JSON.stringify({ version, index: 1, answers: { role: ["freelancer", "freelancer"] } }),
|
|
731
|
+
JSON.stringify({ version, index: 1, answers: { invented: ["x"] } }),
|
|
732
|
+
JSON.stringify({ version, index: 1, answers: [] }),
|
|
733
|
+
JSON.stringify({ version, index: "1", answers: { role: ["freelancer"] } }),
|
|
734
|
+
];
|
|
735
|
+
for (const value of damaged) {
|
|
736
|
+
const quiz = createQuiz(spec(), { storage: memoryStorage({ [key]: value }) });
|
|
737
|
+
assert.equal(quiz.snapshot().index, 0, value);
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
test("blocked storage does not stop the quiz", () => {
|
|
742
|
+
const blocked = {
|
|
743
|
+
getItem: () => {
|
|
744
|
+
throw new Error("blocked");
|
|
745
|
+
},
|
|
746
|
+
setItem: () => {
|
|
747
|
+
throw new Error("blocked");
|
|
748
|
+
},
|
|
749
|
+
removeItem: () => {
|
|
750
|
+
throw new Error("blocked");
|
|
751
|
+
},
|
|
752
|
+
};
|
|
753
|
+
const quiz = createQuiz(spec(), { storage: blocked });
|
|
754
|
+
assert.equal(quiz.select("freelancer").screen.id, "behind");
|
|
755
|
+
assert.equal(quiz.restart().index, 0);
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
test("restart clears the answers and the saved state", () => {
|
|
759
|
+
const storage = memoryStorage();
|
|
760
|
+
const quiz = walk(createQuiz(spec(), { storage }));
|
|
761
|
+
assert.equal(quiz.restart().screen.id, "role");
|
|
762
|
+
assert.deepEqual(quiz.answers(), {});
|
|
763
|
+
assert.equal(storage.items.size, 0);
|
|
764
|
+
});
|