# Playwright smoke-test harness

A reusable harness that opens a page and checks three things from a
JSON config file: the title contains expected text, key texts are
present, and a form exists. When any check fails it saves a
screenshot of the page as found, and the CLI exits 1 so a deploy
script or cron run can gate on it.

## Run

```bash
cd ~/freelance-engine/projects/dev-artefacts/playwright-smoke-harness
~/freelance-engine/.venv/bin/python smoke.py --config config.example.json --no-proxy
```

The example config points at the bundled fixture.html. Point url at
a live http(s) page and drop --no-proxy to run through the local
relay proxy at http://127.0.0.1:18082 with certificate errors
ignored.

## Config

```json
{
  "url": "fixture.html",
  "title_contains": "Fixture Landing",
  "texts": ["Welcome to the fixture", "Sign up for updates"],
  "require_form": true,
  "screenshot_dir": "screenshots"
}
```

A relative url resolves against the config file directory. Set
require_form to false for pages with no form. Texts can be an empty
list.

## Sample output

Passing run:

```text
PASS title_contains: expected 'Fixture Landing', got 'Fixture Landing Page'
PASS text_present: expected 'Welcome to the fixture', got 'found'
PASS text_present: expected 'Sign up for updates', got 'found'
PASS form_present: expected '>= 1 form', got '1 form(s)'
smoke test passed
```

Failing run prints FAIL lines, saves screenshots/failure-<time>.png,
and exits 1.

## Tests

```bash
~/freelance-engine/.venv/bin/python -m pytest tests/ -q
```

Covers the pass case with no screenshot written, the failure case
with a non-empty screenshot file created, a title mismatch, and CLI
exit codes both ways. All against the local fixture, no network.

## Verification log

- 2026-11-19: test suite run from a clean shell, 4 passed.
- Screenshot-on-failure verified by file existence and non-zero
  size in the failure test.
