diff --git a/.cursor/commands/smoke-test.mdc b/.cursor/commands/smoke-test.mdc new file mode 100644 index 00000000..6ce72f9a --- /dev/null +++ b/.cursor/commands/smoke-test.mdc @@ -0,0 +1,7 @@ +--- +description: Run smoke tests against the live Lambda function (requires FUNCTION_URL and WEBHOOK_SECRET in .env) +globs: + - "scripts/smoke-test.js" + - "tests/fixtures/**/*.json" +--- +node scripts/smoke-test.js all diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3a52efa5..d1f8d4b2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,6 +32,24 @@ pr: - `npm run tests:rep` run the tests with no code coverage verification and create *unit-tests-result.json* - `npm run lint` lint the project +### Smoke testing + +The smoke test script sends signed webhook events to the live Lambda function and verifies HTTP responses. +It requires `FUNCTION_URL` and `WEBHOOK_SECRET` in your `.env` file. + +- `node scripts/smoke-test.js ping` send a ping event +- `node scripts/smoke-test.js all` send all event types (ping, pull_request.opened, pull_request.closed, + pull_request_review.submitted) + +Individual event types can also be run by name (e.g. `node scripts/smoke-test.js pull_request.opened`). +The script includes retry logic to handle cold starts and propagation delays. + +The smoke test also runs automatically after each release via the +[smoke-test workflow](.github/workflows/smoke-test.yml), which can be triggered manually from the GitHub Actions UI. + +Test payloads are stored as JSON files in [tests/fixtures/](tests/fixtures/) and are shared with the +integration tests. + ### Developing Handlers All handlers are located in [src/handlers/](https://github.com/TomerFi/auto-me-bot/tree/main/src/handlers).
@@ -110,6 +128,13 @@ module.exports.run = async function(context, config, startedAt) { All handler unit tests are located in [tests/handlers/](https://github.com/TomerFi/auto-me-bot/tree/main/tests/handlers), test the *match* and *run* functions individually, you can inject fakes and stubs into these and verify their behavior.
Take note of [pr-conventional-title test cases](https://github.com/TomerFi/auto-me-bot/blob/main/tests/handlers/pr-conventional-title.test.js) which can be used as a template for future test cases as it's quite short, simple, and has full coverage. +### Integration Tests + +The Lambda handler entrypoint is tested in [tests/app-runner.test.js](tests/app-runner.test.js). +These tests instantiate a real Probot instance with a generated RSA key, sign webhook payloads with HMAC-SHA256, +and verify the handler processes events without crashing. +Payloads are loaded from [tests/fixtures/](tests/fixtures/). + ### Registering Handlers > NOTE: registering handlers requires modifying existing code, the snippets in this section are meant to help you get around the code, and to be used as boiler-plate code. @@ -208,6 +233,7 @@ This project includes Cursor-specific helpers: - **run-tests-quick** - Quick test run without coverage - **lint-fix** - Lint and auto-fix issues - **serve-docs** - Serve documentation locally +- **smoke-test** - Run smoke tests against the live Lambda function ### Agents