feat/Update_Controllers_to_Allow_for_Premium_Membership
This commit is contained in:
@@ -170,6 +170,7 @@ public sealed class ProfileCvControllerTests
|
||||
var userManager = CreateUserManager();
|
||||
userManager.Setup(x => x.GetUserAsync(It.IsAny<ClaimsPrincipal>())).ReturnsAsync(user);
|
||||
userManager.Setup(x => x.FindByIdAsync("user-1")).ReturnsAsync(user);
|
||||
userManager.Setup(x => x.GetRolesAsync(user)).ReturnsAsync(new[] { "Premium" });
|
||||
userManager.Setup(x => x.UpdateAsync(user)).ReturnsAsync(IdentityResult.Success);
|
||||
var aiService = new Mock<ISummarizerService>();
|
||||
aiService
|
||||
@@ -232,6 +233,7 @@ public sealed class ProfileCvControllerTests
|
||||
var user = new ApplicationUser { Id = "user-1", ProfileCvText = "# Ada Lovelace\n\n## Skills\nC#" };
|
||||
var userManager = CreateUserManager();
|
||||
userManager.Setup(x => x.FindByIdAsync(user.Id)).ReturnsAsync(user);
|
||||
userManager.Setup(x => x.GetRolesAsync(user)).ReturnsAsync(new[] { "Premium" });
|
||||
var aiService = new Mock<ISummarizerService>();
|
||||
aiService.Setup(x => x.SummarizeSectionAsync(
|
||||
It.Is<string>(instruction => instruction.StartsWith("Rewrite this CV", StringComparison.Ordinal)),
|
||||
@@ -294,6 +296,35 @@ public sealed class ProfileCvControllerTests
|
||||
Assert.True(System.IO.File.Exists(currentPath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Background_processing_rechecks_pro_after_queueing()
|
||||
{
|
||||
var user = new ApplicationUser { Id = "user-1", ProfileCvText = "# Ada Lovelace" };
|
||||
var users = CreateUserManager();
|
||||
users.Setup(x => x.FindByIdAsync(user.Id)).ReturnsAsync(user);
|
||||
users.Setup(x => x.GetRolesAsync(user)).ReturnsAsync(Array.Empty<string>());
|
||||
var ai = new Mock<ISummarizerService>();
|
||||
await using var db = CreateDb(userId: null);
|
||||
var run = new CvExtractionRun
|
||||
{
|
||||
OwnerUserId = user.Id,
|
||||
Trigger = "improve",
|
||||
ParserVersion = "test",
|
||||
NormalizerVersion = "test",
|
||||
LlmPromptVersion = "test",
|
||||
Status = "queued",
|
||||
};
|
||||
db.CvExtractionRuns.Add(run);
|
||||
await db.SaveChangesAsync();
|
||||
var controller = CreateController(users.Object, ai.Object, db, CreatePaths());
|
||||
|
||||
await controller.ProcessQueuedRunAsync(run.Id, CancellationToken.None);
|
||||
|
||||
Assert.Equal("failed", run.Status);
|
||||
Assert.Equal("This AI feature requires Pro.", run.ErrorMessage);
|
||||
ai.Verify(x => x.SummarizeSectionAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>()), Times.Never);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Upload_reconstructs_flattened_pdf_cv_before_save()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user