test(e2e): gating channels send+discover + data-prune e2e (core#2332 P1.10) #2339
Reference in New Issue
Block a user
Delete Branch "test/channels-dataprune-e2e-p110"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes two coverage gaps (core#2332 P1.10) by adding a GATING e2e to the required
E2E API Smoke Testlane (not staging-only):SendMessagewas previously only asserted by unit tests that reconstruct the payload by hand and POST it themselves (seechannels/lark_test.go's prefix-gate workaround comment) — nothing proved a message submitted through the live platform API actually serializes and POSTs to a provider endpoint. The newtests/e2e/test_channels_e2e.shstands up a local mock upstream, points a Slack Incoming-Webhook channel at it, sends viaPOST /workspaces/:id/channels/:channelId/send, and asserts the mock received the correctly-serialized{"text":...}body.POST /channels/discover) — had no test. The Telegram discover path is pointed at a mock Bot API servinggetMe/getUpdates; we assert the bot username + chat id round-trip back through the handler.DELETE ?purge=trueprunes a workspace's durable child data; the e2e seeds prunable data on a target + a sibling, purges the target, and asserts the target's channel rows are GONE while the sibling's SURVIVE.Adapter test seam (production-inert)
Every adapter pins its outbound host to the real vendor (
hooks.slack.com/api.telegram.org), so a real e2e can't point the live path at a mock.channels/testseam.goadds two env-gated overrides:MOLECULE_CHANNELS_TEST_WEBHOOK_BASE— Slack webhook accept-prefixMOLECULE_CHANNELS_TEST_TELEGRAM_API_BASE— Telegram Bot API base (usestgbotapi.NewBotAPIWithAPIEndpoint)Both are never set in any prod/staging deploy — there the helpers return
""and only the real vendor-host pins pass, so production behaviour is byte-for-byte unchanged. Adapter chosen for SEND: Slack (simplest webhook shape, plain{"text":...}).Gating / never-fail-open
Wired into
e2e-api.ymlwithE2E_REQUIRE_LIVE=1. The script never fail-opens:<9assertionsValidation
Run locally against a booted PG+Redis+platform — 11/11 assertions pass with the seam (mock confirmed it received the serialized payload), hard-RED without it, loud-skip when not require-live.
bash -n+shellcheck --severity=warningclean;lint_cleanup_traps.shpasses (mktemp + EXIT trap);channels/handlersunit suites green;go vetclean.go.sumchurn from a straygo mod download allwas reverted (no new deps).No self-merge — requesting review.
🤖 Generated with Claude Code
Closes two coverage gaps that were previously only unit-mocked, wiring GATING e2e into the required `E2E API Smoke Test` lane (not staging-only): 1. Channel SEND end-to-end. Adapters' SendMessage was only ever asserted by unit tests that reconstruct the payload by hand and POST it themselves (see channels/lark_test.go's prefix-gate workaround) — nothing proved a message submitted through the LIVE platform API serializes and POSTs to a provider endpoint. test_channels_e2e.sh stands up a local mock upstream, points a Slack Incoming-Webhook channel at it, sends via POST /workspaces/:id/channels/:id/send, and asserts the MOCK RECEIVED the correctly-serialized {"text":...} body. 2. Channel DISCOVER (POST /channels/discover) — had no test. The Telegram discover path is pointed at a mock Bot API serving getMe/getUpdates and we assert the bot username + chat id round-trip back through the handler. 3. Workspace data-prune (RFC #734) — had no test. DELETE ?purge=true prunes a workspace's durable child data; the e2e seeds prunable data on a target + a sibling, purges the target, and asserts the target's channel rows are GONE while the sibling's SURVIVE. Adapter test seam (channels/testseam.go): two env-gated overrides — MOLECULE_CHANNELS_TEST_WEBHOOK_BASE (Slack accept-prefix) and MOLECULE_CHANNELS_TEST_TELEGRAM_API_BASE (Telegram Bot API base) — let the LIVE send/discover paths target a local mock. Both are production-inert: never set in any prod/staging deploy, so the real vendor-host pins are the only thing that passes there (byte-for-byte unchanged behaviour). Used the simplest webhook shape (Slack Incoming Webhook, plain {"text":...}). Wired into e2e-api.yml with E2E_REQUIRE_LIVE=1 so a seam regression goes RED — the script NEVER fail-opens: seam-absent + require-live is a hard failure, seam-absent + ad-hoc is a loud skip. Validated locally against a booted PG+Redis+platform: 11/11 assertions pass with the seam, hard-RED without it. bash -n + shellcheck --severity=warning clean; cleanup-traps lint passes; channels/handlers unit suites green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>5-axis-lite coverage review on current head
70001f0dc9.Scope: e2e workflow/test coverage plus two env-gated channel test seams. Production/staging behavior remains pinned to real vendor endpoints unless MOLECULE_CHANNELS_TEST_WEBHOOK_BASE or MOLECULE_CHANNELS_TEST_TELEGRAM_API_BASE is explicitly set by the e2e lane.
Fail-closed confirmed: the channels e2e runs with E2E_REQUIRE_LIVE=1, fails if the seam is absent, asserts the mock upstream received the serialized Slack payload, asserts Telegram discover round-trips bot/chat data, asserts target purge removes child data while sibling data survives, and refuses vacuous green with fewer than expected assertions.
Correctness/robustness/security/performance/readability: the added seams are narrowly scoped to local mock testing; no prod secret or auth surface changes; runtime overhead is environment reads on channel validation/discovery paths; comments document the production-inert contract. Required contexts are green and mergeable=true.
Official review: APPROVED on current head. The channels send/discover/prune coverage is additive and fail-closed: workflow runs the script with E2E_REQUIRE_LIVE=1; seam absence calls loud_skip but exits 1 under require-live; any failed send/discover/prune assertion exits 1; and the script refuses a vacuous green unless >=9 assertions ran. Slack/Telegram test seams are env-gated and production-inert when unset; real vendor host pins remain the default. I found no product regression or fail-open in the diff. Note: live combined status is still red on governance/SOP contexts, so this approval is technical/official but not a merge-ready CI verdict until those gates clear.