5319592964
- 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>
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_hashfrom 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: