Fix account and backup admin settings flows

This commit is contained in:
2026-03-28 15:30:07 +01:00
parent 5f14490ead
commit 4103f84f85
12 changed files with 446 additions and 37 deletions
@@ -144,6 +144,96 @@ public sealed class JobApplicationsApplicationPackageTests
Assert.Contains(payload.KeyPoints, item => item.Contains("recruiter language", StringComparison.OrdinalIgnoreCase));
}
[Fact]
public async Task Generate_application_package_passes_typed_structured_cv_context_to_summarizer()
{
await using var db = CreateDb();
var company = new Company
{
Name = "Acme",
OwnerUserId = "user-1"
};
db.Companies.Add(company);
db.Users.Add(new ApplicationUser
{
Id = "user-1",
UserName = "user@example.test",
Email = "user@example.test",
ProfileCvText = "Built APIs and shipped backend work.",
ProfileCvStructureJson = """
{
"version": "1",
"contact": {
"fullName": "Demo User",
"headline": "Backend Developer",
"email": "user@example.test",
"location": "Oslo"
},
"summary": ["Backend-focused developer with strong API delivery experience."],
"jobs": [
{
"title": "System Developer",
"company": "Acme Consulting",
"location": "Oslo",
"start": "2020",
"end": "2024",
"isCurrent": false,
"bullets": ["Owned .NET API delivery across multiple services."],
"skills": [".NET", "SQL", "APIs"]
}
],
"education": [],
"skills": [".NET", "SQL", "APIs"],
"languages": [{ "name": "English", "level": "Native" }],
"interests": [],
"otherSections": []
}
"""
});
await db.SaveChangesAsync();
var job = new JobApplication
{
JobTitle = "Backend Developer",
CompanyId = company.Id,
OwnerUserId = "user-1",
Description = "Need .NET API ownership and strong SQL skills."
};
db.JobApplications.Add(job);
await db.SaveChangesAsync();
string? capturedContext = null;
var summarizer = new Mock<ISummarizerService>();
summarizer
.Setup(service => service.SummarizeSectionAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>()))
.ReturnsAsync((string instruction, string context, int _, int __) =>
{
if (instruction.Contains("Rewrite the candidate CV", StringComparison.OrdinalIgnoreCase))
{
capturedContext = context;
return "Tailored CV";
}
if (instruction.Contains("List up to 4 concrete application-package signals", StringComparison.OrdinalIgnoreCase))
{
return "Lead with .NET API ownership.";
}
return "Draft";
});
var controller = CreateController(db, summarizer.Object, "user-1");
var result = await controller.GenerateApplicationPackage(job.Id, null, null, null, CancellationToken.None);
Assert.IsType<OkObjectResult>(result.Result);
Assert.NotNull(capturedContext);
Assert.Contains("Structured CV:", capturedContext);
Assert.Contains("Name: Demo User", capturedContext);
Assert.Contains("Skills:\n.NET, SQL, APIs", capturedContext);
Assert.Contains("Work Experience:", capturedContext);
Assert.Contains("Owned .NET API delivery across multiple services.", capturedContext);
}
private static JobApplicationsController CreateController(JobTrackerContext db, ISummarizerService summarizer, string userId)
{
var controller = new JobApplicationsController(db, summarizer, Mock.Of<IAppEmailSender>(), CreateUserManager().Object, NullLogger<JobApplicationsController>.Instance);