Refactor Telegram API and enhance TelegramPanel form handling
ci / build-backend (push) Successful in 1m56s
ci / build-frontend (push) Successful in 59s
ci / tests (push) Successful in 2m39s
ci / sonar (push) Successful in 8m58s

Updated the TelegramApi class to improve URL construction for API calls by introducing a new MethodUrl method, ensuring proper handling of bot tokens. Refactored the TelegramPanel component to use a form for input fields, allowing for better user experience and submission handling. Adjusted password input fields to use 'new-password' for improved security. These changes aim to enhance the functionality and usability of the Telegram integration.
This commit is contained in:
Leonid Pershin
2026-07-31 08:07:49 +03:00
parent ec957fe55c
commit 54cc4862b2
3 changed files with 44 additions and 7 deletions
@@ -0,0 +1,22 @@
using TeleWave.Infrastructure.Notifications;
using Xunit;
namespace TeleWave.Application.Tests.Notifications;
/// <summary>
/// Адрес метода Bot API. Отдельный тест на одну строку — потому что ошибка в ней не видна ни при
/// сборке, ни в юнит-тестах логики: токен содержит двоеточие, и относительный путь превращается
/// в «схему» ещё до обращения к сети.
/// </summary>
public class TelegramApiUrlTests
{
[Fact]
public void MethodUrl_KeepsTokenInPath_AndStaysHttps()
{
var url = TelegramApi.MethodUrl("8613942817:AAHrandom-part_x", "getUpdates");
Assert.Equal("https", url.Scheme);
Assert.Equal("api.telegram.org", url.Host);
Assert.Equal("/bot8613942817:AAHrandom-part_x/getUpdates", url.AbsolutePath);
}
}