Skip to content

test(tg): grammY integration smoke tests via mocked api transport#21

Merged
BlindMaster24 merged 2 commits into
devin/1777025566-graceful-shutdownfrom
devin/1777026000-bot-smoke
Apr 27, 2026
Merged

test(tg): grammY integration smoke tests via mocked api transport#21
BlindMaster24 merged 2 commits into
devin/1777025566-graceful-shutdownfrom
devin/1777026000-bot-smoke

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 24, 2026

Summary

Adds a focused smoke suite for the grammY framework bindings so upstream grammY bumps (and future Renovate PRs) surface breakage before it lands in prod, without requiring a real Telegram token or network calls.

Why: the existing tests/bots/telegram-flow.test.ts only checks command regexps in isolation. We had zero coverage of the grammY Bot instance itself — so a breaking 1.x → 2.x API change (request transformer signature, update routing, error boundary) would have silently passed CI until a real deploy.

What's new (tests/bots/grammy-smoke.test.ts):

  • Spins up a real new Bot(...) with a preset botInfo (skips getMe) and swaps the API transport via bot.api.config.use(...) to record every outbound call without hitting Telegram.
  • Asserts that:
    1. a /start text update is routed to its bot.hears(...) handler and the reply lands as a sendMessage call with the right chat id + text
    2. a non-matching text update triggers zero outbound calls
    3. a middleware that throws surfaces as a grammY BotError with the original error attached on .error — catches the contract we rely on for tg_update_handler_error logging in src/services/bots/tg/index.ts
    4. bot.command('ics', ...) with a realistic entities: [{ type: 'bot_command', ... }] payload fires the handler and sends the reply

No prod code change.

Checks:

  • pnpm run test:all — 33 files / 214 tests pass
  • pnpm run ts-check / pnpm run lint / pnpm run format:check — clean
  • pnpm audit --audit-level=low — no known vulnerabilities

Run the new tests with: pnpm exec vitest run tests/bots/grammy-smoke.test.ts

Stacked on PR #20.

Review & Testing Checklist for Human

  • Bump grammY locally one major (e.g. pnpm add grammy@2) and run pnpm exec vitest run tests/bots/grammy-smoke.test.ts — the suite should break loudly if the transport or error-boundary contracts change.
  • Run pnpm run test:all from a fresh checkout to confirm nothing flaky.

Notes

Link to Devin session: https://app.devin.ai/sessions/7732f5fd16e9448295cbabeb8b5f471a
Requested by: @BlindMaster24


Open in Devin Review

@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1777025566-graceful-shutdown branch from 98592de to ece7ce0 Compare April 24, 2026 10:42
@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1777026000-bot-smoke branch from f8a264d to ad1a2e1 Compare April 24, 2026 10:42
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1777026000-bot-smoke branch from ad1a2e1 to 25c76f2 Compare April 24, 2026 10:51
Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1777026000-bot-smoke branch from 2ea611c to 8d23d88 Compare April 24, 2026 10:59
@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1777026000-bot-smoke branch from 3e0007a to bdd6845 Compare April 24, 2026 11:01
@BlindMaster24 BlindMaster24 merged commit 17e010f into devin/1777025566-graceful-shutdown Apr 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant