fix(scale): page mail and batch roles
CI and Deploy / test (pull_request) Failing after 2m46s
CI and Deploy / deploy (pull_request) Has been skipped

This commit is contained in:
cesnimda
2026-08-15 21:02:50 +02:00
parent 8ef8b098c8
commit e7cacad7d6
11 changed files with 284 additions and 20 deletions
@@ -85,4 +85,45 @@ public sealed class CorrespondenceControllerTests
var otherResult = await new CorrespondenceController(otherDb).GetMessage(messageId, CancellationToken.None);
Assert.IsType<NotFoundResult>(otherResult.Result);
}
[Fact]
public async Task Paged_inbox_returns_every_owned_message_without_the_legacy_cap()
{
await using var db = TestHostFactory.CreateInMemoryDb();
var company = new Company { Name = "Scale fixture", OwnerUserId = "user-1" };
var otherCompany = new Company { Name = "Other tenant", OwnerUserId = "user-2" };
db.Companies.AddRange(company, otherCompany);
await db.SaveChangesAsync();
var job = new JobApplication { JobTitle = "Paged role", CompanyId = company.Id, OwnerUserId = "user-1" };
var otherJob = new JobApplication { JobTitle = "Private role", CompanyId = otherCompany.Id, OwnerUserId = "user-2" };
db.JobApplications.AddRange(job, otherJob);
await db.SaveChangesAsync();
db.Correspondences.AddRange(Enumerable.Range(1, 205).Select(index => new Correspondence
{
JobApplicationId = job.Id,
From = "Recruiter",
Subject = $"Message {index}",
Content = $"Content {index}",
Date = new DateTime(2026, 1, 1).AddMinutes(index)
}));
db.Correspondences.Add(new Correspondence
{
JobApplicationId = otherJob.Id,
From = "Other recruiter",
Subject = "Private message",
Content = "Must stay tenant isolated",
Date = new DateTime(2026, 2, 1)
});
await db.SaveChangesAsync();
var result = await new CorrespondenceController(db).GetInboxPage(null, null, null, 3, 100, CancellationToken.None);
var page = Assert.IsType<CorrespondenceController.CorrespondenceInboxPageDto>(Assert.IsType<OkObjectResult>(result.Result).Value);
Assert.Equal(205, page.Total);
Assert.Equal(3, page.TotalPages);
Assert.Equal(3, page.Page);
Assert.Equal(5, page.Items.Count);
Assert.Equal("Message 5", page.Items[0].Subject);
Assert.Equal("Message 1", page.Items[^1].Subject);
}
}