Enhance SwarmUI integration by adding swarm connection status to the API and updating client-side components to reflect this status. Improved localization strings for various SwarmUI states and refactored ApplicantsDialog and PersonCard components to utilize the new connection information, ensuring a more responsive user experience.
ci / server (push) Failing after 4m56s
ci / client (push) Failing after 15s

This commit is contained in:
Leonid Pershin
2026-08-20 04:21:35 +03:00
parent 36b46774a7
commit 5991dcd5c4
13 changed files with 246 additions and 33 deletions
@@ -34,6 +34,44 @@ public class SwarmUiClientTests
Assert.Contains("/API/GenerateText2Image", handler.Requests[1]);
}
[Fact]
public async Task ProbeAsync_ReturnsTrueWhenSessionOpens()
{
var handler = new FakeHandler();
var http = new HttpClient(handler) { BaseAddress = new Uri("http://swarm.test/") };
var client = new SwarmUiClient(
http,
Options.Create(new SwarmUiOptions { BaseUrl = "http://swarm.test", TimeoutSeconds = 30 }),
NullLogger<SwarmUiClient>.Instance);
var ok = await client.ProbeAsync(TimeSpan.FromSeconds(5), CancellationToken.None);
Assert.True(ok);
Assert.Single(handler.Requests);
Assert.Contains("/API/GetNewSession", handler.Requests[0]);
}
[Fact]
public async Task ProbeAsync_ReturnsFalseWhenUnreachable()
{
var handler = new FailingHandler();
var http = new HttpClient(handler) { BaseAddress = new Uri("http://swarm.test/") };
var client = new SwarmUiClient(
http,
Options.Create(new SwarmUiOptions { BaseUrl = "http://swarm.test", TimeoutSeconds = 30 }),
NullLogger<SwarmUiClient>.Instance);
var ok = await client.ProbeAsync(TimeSpan.FromSeconds(5), CancellationToken.None);
Assert.False(ok);
}
private sealed class FailingHandler : HttpMessageHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) =>
Task.FromResult(new HttpResponseMessage(HttpStatusCode.ServiceUnavailable));
}
private sealed class FakeHandler : HttpMessageHandler
{
public List<string> Requests { get; } = [];