Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Orbit.Application/Profile/Queries/GetProfileQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public record ProfileResponse(
string LevelTitle,
int AdRewardsClaimedToday,
int CurrentStreak,
int LongestStreak,
int StreakFreezesAvailable,
string? ThemePreference,
string? ColorScheme,
Expand Down Expand Up @@ -97,6 +98,7 @@ public async Task<Result<ProfileResponse>> Handle(GetProfileQuery request, Cance
? user.AdRewardsClaimedToday
: 0,
user.CurrentStreak,
user.LongestStreak,
freezesAvailable,
user.ThemePreference,
user.ColorScheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,27 @@ public async Task Handle_UserFound_ReturnsProfile()
result.Value.AiMessagesLimit.Should().Be(20);
}

[Fact]
public async Task Handle_UserWithStreak_ReturnsCurrentAndLongest()
{
var user = CreateTestUser();
user.SetStreakState(5, 12, Today);
_userRepo.GetByIdAsync(UserId, Arg.Any<CancellationToken>()).Returns(user);
_payGate.GetAiMessageLimit(UserId, Arg.Any<CancellationToken>()).Returns(20);
_streakFreezeRepo.FindAsync(
Arg.Any<Expression<Func<StreakFreeze, bool>>>(),
Arg.Any<CancellationToken>())
.Returns(new List<StreakFreeze>().AsReadOnly());

var query = new GetProfileQuery(UserId);

var result = await _handler.Handle(query, CancellationToken.None);

result.IsSuccess.Should().BeTrue();
result.Value.CurrentStreak.Should().Be(5);
result.Value.LongestStreak.Should().Be(12);
}

[Fact]
public async Task Handle_UserNotFound_ReturnsFailure()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Orbit.Infrastructure.Tests/Mcp/ProfileToolsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task GetProfile_Success_ReturnsFormattedProfile()
"Thomas", "thomas@example.com", "America/Sao_Paulo",
true, true, true, true, "pt-BR", "Pro", true, false, null, null,
5, 100, false, false, null, null, false, 1, 500, 5, "Achiever",
0, 10, 2, null, null,
0, 10, 12, 2, null, null,
false, GoogleCalendarAutoSyncStatus.Idle, null);

_mediator.Send(Arg.Any<GetProfileQuery>(), Arg.Any<CancellationToken>())
Expand Down
Loading