feat(e2e): #146 MTProto Telegram user client runner
- Add standalone C# console runner tests/e2e/runner/ using WTelegramClient - Provide TelegramUserClient wrapper: login, create supergroup, invite bot, send messages/commands, read recent messages, wait for bot reply - Add .env.example and runner .gitignore to keep secrets/session files out of git - Update E2E README with runner instructions and status table - Runner project intentionally excluded from GM-Relay.slnx to avoid CI/AOT impact Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+51
-6
@@ -10,8 +10,8 @@ Tracked as a Gitea milestone: [E2E Automation](https://git.codeanddice.ru/toutsu
|
||||
| Issue | Title | Status |
|
||||
|-------|-------|--------|
|
||||
| #144 | initData / Login Widget helper for mock Telegram auth | ✅ Done |
|
||||
| #145 | Playwright tests for Blazor dashboard with mocked Telegram auth | 🚧 In progress |
|
||||
| #146 | Telegram user client (MTProto) | ⏳ Planned |
|
||||
| #145 | Playwright tests for Blazor dashboard with mocked Telegram auth | ✅ Done |
|
||||
| #146 | Telegram user client (MTProto) | 🚧 In progress |
|
||||
| #147 | Automate group creation and bot invitation | ⏳ Planned |
|
||||
| #148 | Scenario: /newsession from creation to publication | ⏳ Planned |
|
||||
| #149 | Join/leave, waitlist, reschedule and notification scenarios | ⏳ Planned |
|
||||
@@ -29,13 +29,23 @@ tests/e2e/
|
||||
│ ├── telegram_init_data.py # Build valid Telegram auth payloads
|
||||
│ ├── test_telegram_init_data.py # Self-contained sanity tests for the helper
|
||||
│ └── __init__.py
|
||||
└── dashboard/
|
||||
├── test_dashboard_auth_and_sessions.py # Playwright tests for the Blazor dashboard
|
||||
└── __init__.py
|
||||
├── dashboard/
|
||||
│ ├── test_dashboard_auth_and_sessions.py # Playwright tests for the Blazor dashboard
|
||||
│ └── __init__.py
|
||||
└── runner/
|
||||
├── GmRelay.E2E.Runner.csproj # C# console runner using WTelegramClient (MTProto)
|
||||
├── Program.cs # Entry point for quick manual checks
|
||||
├── TelegramUserClient.cs # Reusable MTProto user client wrapper
|
||||
├── RunnerConfig.cs # Configuration model
|
||||
├── .env.example # Required environment variables
|
||||
├── .gitignore # Ignore .env and session files
|
||||
└── packages.lock.json # Restored lock file for the runner project
|
||||
```
|
||||
|
||||
## Install dependencies
|
||||
|
||||
### Python (dashboard tests)
|
||||
|
||||
```bash
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
||||
@@ -43,6 +53,12 @@ pip install -r tests/e2e/requirements.txt
|
||||
playwright install chromium
|
||||
```
|
||||
|
||||
### C# runner (MTProto)
|
||||
|
||||
```bash
|
||||
dotnet restore tests/e2e/runner/GmRelay.E2E.Runner.csproj
|
||||
```
|
||||
|
||||
## Run helper tests
|
||||
|
||||
```bash
|
||||
@@ -67,6 +83,26 @@ python tests/e2e/helpers/test_telegram_init_data.py
|
||||
python tests/e2e/dashboard/test_dashboard_auth_and_sessions.py
|
||||
```
|
||||
|
||||
## Run the MTProto user client runner
|
||||
|
||||
The runner logs in to a real Telegram user account, creates a supergroup, and invites the test bot.
|
||||
|
||||
1. Copy the example environment file and fill in real values:
|
||||
```bash
|
||||
cp tests/e2e/runner/.env.example tests/e2e/runner/.env
|
||||
```
|
||||
2. Edit `tests/e2e/runner/.env` with your Telegram `api_id`, `api_hash`, `phone_number`, the bot username/token, and Web URL.
|
||||
3. Run:
|
||||
```bash
|
||||
dotnet run --project tests/e2e/runner/GmRelay.E2E.Runner.csproj
|
||||
```
|
||||
|
||||
**Security notes:**
|
||||
- Never commit `.env` or `*.session` files.
|
||||
- Use a dedicated test Telegram account, never your personal or production account.
|
||||
- The first run will prompt for the Telegram verification code (sent to the phone number).
|
||||
- Subsequent runs reuse the persisted `.session` file.
|
||||
|
||||
## What the dashboard tests cover
|
||||
|
||||
- `test_dashboard_authenticates_and_shows_groups`
|
||||
@@ -74,8 +110,17 @@ python tests/e2e/helpers/test_telegram_init_data.py
|
||||
- `test_dashboard_session_edit_flow`
|
||||
Seeds a player, group, and session directly in PostgreSQL, opens the group details page, clicks through to the session editor, changes the title, and asserts the updated title appears on the page.
|
||||
|
||||
## What the MTProto runner currently covers
|
||||
|
||||
- Login as a Telegram user.
|
||||
- Create a supergroup (`Channels_CreateChannel` with `megagroup: true`).
|
||||
- Resolve a bot by username and invite it to the group.
|
||||
- Send messages/commands and read recent messages.
|
||||
- Wait for a bot reply.
|
||||
|
||||
## Notes
|
||||
|
||||
- Authentication is mocked using `helpers/telegram_init_data.py`, which mirrors `GmRelay.Shared.Telegram.TelegramAuthPayloadBuilder`.
|
||||
- The Web instance validates HMAC-SHA256 with the same bot token, so the test payload is indistinguishable from a real Telegram Mini App payload.
|
||||
- For headful debugging, change `headless=True` to `headless=False` in the test file.
|
||||
- The runner project is intentionally **not** included in `GM-Relay.slnx` so it does not participate in CI builds or Native AOT trimming.
|
||||
- For headful debugging, change `headless=True` to `headless=False` in the dashboard test file.
|
||||
|
||||
Reference in New Issue
Block a user