# Production QA & deploy loop

Use this before pushing a website change or after adding a new AutoShorts/TrueTraceShorts companion page.

## Standard local loop

```bash
npm run sync:youtube-links -- --dry-run
npm run sync:youtube-links -- --apply
npm run qa:production
```

`qa:production` runs:

1. `npm run build`
2. static route checks against `dist/`
3. internal link and asset integrity checks
4. sitemap/robots checks
5. JSON-LD presence checks
6. placeholder leak checks

It fails on:

- missing built routes;
- broken internal links/assets;
- missing sitemap routes;
- missing canonical or JSON-LD;
- missing HowTo JSON-LD on red-flag pages;
- leaked placeholder copy such as `Recommendation placeholder`, `Video placeholder`, `Download checklist`, or TikTok placeholder text.

## Live-domain check

After deploy or when the custom domain should already be live:

```bash
npm run qa:live
```

This performs the same local build/static checks and then tries live HTTP checks for:

- `/`
- `/sitemap.xml`
- `/robots.txt`
- `/redflags/fake-captcha/`

Live checks are reported as warnings by default because DNS/deploy propagation can be outside the agent environment. If a CI job should fail on live errors, run:

```bash
node scripts/production-qa.mjs --live --fail-on-live
```

## Lighthouse / browser performance check

If the environment has both the Lighthouse CLI and Chrome/Chromium installed, run:

```bash
npm run qa:lighthouse -- --url=http://127.0.0.1:4322/
```

The helper reports a structured skip instead of failing when Lighthouse or Chrome/Chromium is unavailable. For CI environments where Lighthouse must be present, add `--require`.

## Browser QA checklist

After the script passes, inspect at minimum:

- `/` — hero, emergency CTA, carousel, checklist CTA.
- `/tools/` — no placeholder recommendations, trust-first copy readable.
- `/checklist/` — PDF/print checklist readable.
- one current `/redflags/<slug>/` page — 9:16 Example screen, Do this first box, YouTube button if uploaded, PDF checklist.

Open browser console after navigation and verify no JavaScript errors.

## Notes

- Do not claim live deployment succeeded unless the live custom domain returns successful responses from this environment or the hosting platform confirms deployment.
- Private YouTube Shorts links can be stored for workflow continuity, but public visitors will not see those videos until manually published in YouTube Studio.
- No TikTok links or placeholders unless explicitly requested.
