--- name: test description: Self-contained test automation — invoke directly, do not decompose. End-to-end integration test that assembles a fixture, deploys Connect + Cloudflare, and presents a live URL for browser verification. license: MIT allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion metadata: author: "Marcus Estes" version: "0.1.63" --- > **Plan mode**: If you are planning work, this entire skill is ONE plan step: "Invoke /vibes:test". Do not decompose the steps below into separate plan tasks. ## Integration Test Skill Orchestrates the full test pipeline: credentials → Connect studio → fixture assembly → Cloudflare deploy → live URL → unit tests. **Working directory:** `test-vibes/` (gitignored, persists across runs) ### Phase 1: Credentials Check if `test-vibes/.env` exists and has Clerk keys. ```bash # From the plugin root cat test-vibes/.env 2>/dev/null ``` **If the file exists and contains `VITE_CLERK_PUBLISHABLE_KEY`:** ``` AskUserQuestion: Question: "Reuse existing test credentials? (publishable key: pk_test_...)" Header: "Credentials" Options: - Label: "Yes, reuse" Description: "Use the Clerk keys already in test-vibes/.env" - Label: "No, enter new keys" Description: "I want to use different Clerk credentials" ``` **If the file doesn't exist or keys are missing, or user wants new keys:** ``` AskUserQuestion: Question: "Paste your Clerk Publishable Key (starts with pk_test_ or pk_live_)" Header: "Clerk PK" Options: - Label: "I need to get keys first" Description: "I'll go to clerk.com and come back" ``` If they need keys, tell them: > Go to [clerk.com](https://clerk.com) → your application → API Keys → copy Publishable Key and Secret Key. Then ask for the secret key: ``` AskUserQuestion: Question: "Paste your Clerk Secret Key (starts with sk_test_ or sk_live_)" Header: "Clerk SK" ``` Write `test-vibes/.env`: ``` VITE_CLERK_PUBLISHABLE_KEY= VITE_CLERK_SECRET_KEY= ``` ### Phase 2: Connect Studio Check if `test-vibes/.connect` exists (marks a deployed studio). ```bash cat test-vibes/.connect 2>/dev/null ``` **If `.connect` exists:** Read the studio name and API/Cloud URLs. Confirm reuse: ``` AskUserQuestion: Question: "Reuse existing Connect studio ''?" Header: "Connect" Options: - Label: "Yes, reuse" Description: "Studio is already running" - Label: "No, deploy fresh" Description: "Deploy a new Connect studio" ``` **If `.connect` doesn't exist or user wants fresh deploy:** Run the deploy script. Read the Clerk keys from `test-vibes/.env` first: ```bash node scripts/deploy-connect.js \ --studio vibes-test-studio \ --clerk-publishable-key "$VITE_CLERK_PUBLISHABLE_KEY" \ --clerk-secret-key "$VITE_CLERK_SECRET_KEY" ``` After deploy, save the studio info: ```bash # Write connect marker echo "vibes-test-studio" > test-vibes/.connect ``` Update `test-vibes/.env` with the Connect URLs: ``` VITE_API_URL=https://vibes-test-studio.exe.xyz/api VITE_CLOUD_URL=fpcloud://vibes-test-studio.exe.xyz?protocol=wss ``` ### Phase 3: Fixture Selection ``` AskUserQuestion: Question: "Which fixture to test?" Header: "Fixture" Options: - Label: "fireproof-basic (Recommended)" Description: "Fireproof CRUD with React singleton — the standard integration test" - Label: "minimal" Description: "Template + Babel + import map only — fastest, no Fireproof" - Label: "sell-ready" Description: "useTenant() + multi-tenant routing — tests sell assembly path" - Label: "ai-proxy" Description: "/api/ai/chat endpoint + CORS — requires OpenRouter key" ``` **For sell-ready fixture:** Check `test-vibes/.env` for a cached admin user ID from a previous run: ```bash grep CLERK_ADMIN_USER_ID test-vibes/.env 2>/dev/null ``` **If found**, offer to reuse it (mask the middle of the value in the prompt, e.g., `user_37ici...ohcY`): ``` AskUserQuestion: Question: "Reuse stored admin user ID? (user_37ici...ohcY)" Header: "Admin ID" Options: - Label: "Yes, reuse" Description: "Use the cached user ID from test-vibes/.env" - Label: "Skip admin" Description: "Deploy without admin — you can set it up after deploy" ``` If "Yes, reuse": use the stored value in Phase 4 assembly. If "Skip admin": omit `--admin-ids` in Phase 4. Admin setup will be offered post-deploy in Phase 5.5. **If not found:** No prompt needed. Admin will be set up post-deploy in Phase 5.5 after the user has a chance to sign up on the live app. ### Phase 3.5: Sell Configuration (sell-ready only) **Condition:** Only runs when the user selected `sell-ready` in Phase 3. **Ask billing mode:** ``` AskUserQuestion: Question: "Which billing mode should this sell test use?" Header: "Billing" Options: - Label: "Free (billing off)" Description: "Claims work without payment — tests auth + tenant routing only" - Label: "Billing required" Description: "Claims require active Clerk subscription — tests full paywall flow" ``` **If "Free":** Store `BILLING_MODE=off` in `test-vibes/.env`. Skip webhook setup. Proceed to Phase 4. **If "Billing required":** Store `BILLING_MODE=required` in `test-vibes/.env`. Then guide webhook setup: ``` AskUserQuestion: Question: "Set up the Clerk webhook for billing:\n\n1. Go to clerk.com → your app → Webhooks → Add Endpoint\n2. URL: https://vibes-test..workers.dev/webhook\n3. Subscribe to: subscription.deleted\n4. Copy the Signing Secret (starts with whsec_)\n\nPaste the webhook signing secret:" Header: "Webhook" Options: - Label: "I need help" Description: "Walk me through the Clerk webhook setup" ``` If "I need help": walk them through each step in the Clerk dashboard, then re-ask the question. Validate the secret starts with `whsec_`. If not, ask again with a note that it should start with `whsec_`. Store as `CLERK_WEBHOOK_SECRET` in `test-vibes/.env`: ```bash grep -q CLERK_WEBHOOK_SECRET test-vibes/.env 2>/dev/null && \ sed -i '' 's/^CLERK_WEBHOOK_SECRET=.*/CLERK_WEBHOOK_SECRET=/' test-vibes/.env || \ echo "CLERK_WEBHOOK_SECRET=" >> test-vibes/.env ``` Proceed to Phase 4. ### Phase 4: Assembly Copy the selected fixture and assemble: ```bash # Copy fixture to working directory cp scripts/__tests__/fixtures/.jsx test-vibes/app.jsx # Source env for assembly set -a && source test-vibes/.env && set +a ``` **For sell-ready fixture:** ```bash node scripts/assemble-sell.js test-vibes/app.jsx test-vibes/index.html \ --domain vibes-test..workers.dev \ --admin-ids '[""]' # read CLERK_ADMIN_USER_ID from test-vibes/.env ``` If admin was skipped, omit `--admin-ids`. The `--domain` flag is always required. **For all other fixtures:** ```bash node scripts/assemble.js test-vibes/app.jsx test-vibes/index.html ``` **Validate the output** (same checks as the vitest suite): 1. File exists and is non-empty 2. No `__PLACEHOLDER__` strings remain 3. Import map `