Return full chat list

This commit is contained in:
sevenhill
2026-07-05 14:13:51 +03:00
parent 6dd5c7c6fb
commit 64764e99ef
2 changed files with 42 additions and 1 deletions
@@ -30,7 +30,6 @@ public sealed class ChatsController(
.OrderByDescending(x => x.IsPinned)
.ThenByDescending(x => x.UnreadCount > 0)
.ThenByDescending(x => x.LastMessageAt ?? x.UpdatedAt)
.Take(200)
.ToArray();
return chats.Select(projection.ToDto).ToArray();
+42
View File
@@ -110,6 +110,48 @@ public sealed class ApiSmokeTests : IDisposable
});
}
[Fact]
public async Task ChatListReturnsAllChatsBeyondLegacyLimit()
{
using var factory = _factory.WithWebHostBuilder(builder =>
{
builder.ConfigureTestServices(services =>
{
services.RemoveAll<IHostedService>();
});
});
using var client = factory.CreateClient();
await LoginAsync(client);
using (var scope = factory.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<QMaxDbContext>();
for (var index = 0; index < 221; index++)
{
db.Chats.Add(new Chat
{
ExternalId = $"bulk-chat-{index:D3}",
Title = index switch
{
219 => "\u0421\u0430\u0438\u0434",
220 => "\u0410\u043d\u044e\u0442\u0430",
_ => $"Bulk Chat {index:D3}"
},
Kind = ChatKind.MaxDialog,
LastMessageAt = DateTimeOffset.UtcNow.AddMinutes(-index)
});
}
await db.SaveChangesAsync();
}
var chats = await client.GetFromJsonAsync<ChatDto[]>("/api/chats", JsonOptions);
Assert.NotNull(chats);
Assert.Equal(221, chats!.Count(x => x.ExternalId?.StartsWith("bulk-chat-", StringComparison.Ordinal) == true));
Assert.Contains(chats, x => x.Title == "\u0421\u0430\u0438\u0434");
Assert.Contains(chats, x => x.Title == "\u0410\u043d\u044e\u0442\u0430");
}
[Fact]
public async Task SyncMergesLateDiscoveredAttachmentsIntoExistingMessage()
{