fix(scale): page mail and batch roles
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user