Files
GmRelayBot/tests/e2e
Toutsu 5319592964 feat(e2e): shared initData / Login Widget payload builder for E2E tests
- Add TelegramAuthPayloadBuilder in GmRelay.Shared for C# tests.
- Refactor TelegramAuthServiceTests to use the shared builder.
- Add Python equivalent (telegram_init_data.py) for E2E runner.
- Add self-contained Python tests and E2E README.

Closes #144

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 11:53:22 +03:00
..

GmRelay E2E Tests

This directory contains end-to-end tests that run locally against real Telegram infrastructure and the GmRelay Web dashboard. They are intentionally not part of CI because they require:

  • a real Telegram test user account;
  • api_id / api_hash from https://my.telegram.org;
  • a pre-authenticated MTProto session;
  • a running PostgreSQL, GmRelay.Bot, and GmRelay.Web.

Structure

tests/e2e/
├── README.md                        # this file
├── helpers/
│   ├── telegram_init_data.py        # generate valid Telegram initData / Login Widget payloads
│   └── test_telegram_init_data.py   # unit tests for the helper
└── ... (runner and scenarios will land here)

telegram_init_data.py

A small Python helper that produces Telegram Mini App initData and Login Widget payloads with valid HMAC-SHA256 signatures. It mirrors GmRelay.Shared.Telegram.TelegramAuthPayloadBuilder.

Use it to open the Blazor/Mini App dashboard in Playwright without logging into Telegram:

from helpers.telegram_init_data import build_mini_app_init_data

init = build_mini_app_init_data(
    bot_token="YOUR_BOT_TOKEN",
    telegram_id=424242,
    first_name="Test",
    username="tester")

await page.goto(f"https://localhost:8080/#tgWebAppData={init.init_data_raw}")

C# equivalent

For tests inside the solution, use GmRelay.Shared.Telegram.TelegramAuthPayloadBuilder:

var init = TelegramAuthPayloadBuilder.BuildMiniAppInitData(
    botToken: "YOUR_BOT_TOKEN",
    telegramId: 424242L,
    firstName: "Test",
    username: "tester");

// init.InitDataRaw is a valid initData string.

Running the helper tests

cd tests/e2e/helpers
python -m pytest test_telegram_init_data.py -v

Roadmap

See the Gitea milestone Этап — E2E-тестирование Telegram + Web and its issues:

  • #144 initData helper (this directory)
  • #145 Playwright dashboard tests
  • #146 MTProto test user client
  • #147 Group creation automation
  • #148 /newsession scenario
  • #149 join/leave/waitlist/reschedule scenarios
  • #150 Web dashboard round-trip verification
  • #151 Console runner + cleanup