Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
Refresh timeline view (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminsampica authored Jul 7, 2022
1 parent b8324a1 commit 7101c79
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 50 deletions.
30 changes: 25 additions & 5 deletions src/Client/Features/FreeAgents/Detail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,35 @@ else
var firstBid = _result.Bids.First();
}
<MudTimelineItem Icon=@Icons.Outlined.Money Size=Size.Large Color=Color.Success>
<MudAlert Severity="Severity.Success">
@firstBid!.Team is winning with a bid of <b>@firstBid.Amount</b> on @(firstBid.CreatedOn)!
</MudAlert>
<ItemOpposite>
<MudText Color="Color.Success" Typo="Typo.h4">
@firstBid.Amount
</MudText>
</ItemOpposite>
<ItemContent>
<MudText Color="Color.Success" Typo="Typo.h5">
@firstBid.Team
</MudText>
<MudText Typo="Typo.subtitle2">
@firstBid.CreatedOn
</MudText>
</ItemContent>
</MudTimelineItem>
@foreach(var bid in _result.Bids.Skip(1))
{
<MudTimelineItem Icon=@Icons.Outlined.Money>
<MudTimelineItem TimelineAlign="TimelineAlign.End">
<ItemOpposite>
<MudText Typo="Typo.h6">
@bid.Amount
</MudText>
</ItemOpposite>
<ItemContent>
@bid!.Team bid @bid.Amount on @(bid.CreatedOn).
<MudText Typo="Typo.h6">
@bid.Team
</MudText>
<MudText Typo="Typo.subtitle2">
@bid.CreatedOn
</MudText>
</ItemContent>
</MudTimelineItem>
}
Expand Down
11 changes: 1 addition & 10 deletions src/Server/Features/FreeAgents/Detail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@ public async Task<FreeAgentDetailResult> Handle(DetailQuery request, Cancellatio
}
}

public class DetailValidator : AbstractValidator<DetailQuery>
{
public DetailValidator(ApplicationDbContext dbContext)
{
RuleFor(p => p.PlayerId)
.Must(value => dbContext.Players.Any(p => p.Id == value));
}
}

public class DetailMappingProfile : Profile
{
public DetailMappingProfile()
Expand All @@ -74,6 +65,6 @@ public DetailMappingProfile()
CreateMap<Bid, FreeAgentDetailResult.BidItem>()
.ForMember(d => d.Team, mo => mo.MapFrom(s => s.Team.Name))
.ForMember(d => d.Amount, mo => mo.MapFrom(s => s.Amount.ToString("C0")))
.ForMember(d => d.CreatedOn, mo => mo.MapFrom(s => s.CreatedOn.ToShortDateString()));
.ForMember(d => d.CreatedOn, mo => mo.MapFrom(s => s.CreatedOn.ToString("g")));
}
}
49 changes: 22 additions & 27 deletions src/Server/Infrastructure/SeedDataCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,28 @@ private async Task SeedApplicationDataAsync(CancellationToken cancellationToken)
TeamId = new Random().Next(1, 10)
};

// TODO: Come back and redo this with the state machine.
//if (i % 2 == 0)
//{
// player.SetToRostered(DateTime.Today.AddYears(1).Year, 1);

// if (i % 10 == 0)
// {
// player.SetToUnrostered();
// }
//}
//else if (i % 5 == 0)
//{
// player.SetToUnsigned();
//}
//else
//{
// player.SetToRostered(DateTime.Today.AddYears(-1).Year, 1);
// if (i % 7 == 0)
// {
// player.SetToFreeAgent(DateTime.Today.AddYears(1));
// }
// else
// {
// player.SetToFreeAgent(DateTime.Today.AddDays(-2));
// player.TeamId = 1;
// }
//}


if (i % 2 == 0)
{
player.SignForCurrentTeam(DateTime.Today.AddYears(1).Year, i);


if (i % 4 == 0)
{
player.BeginNewSeason(DateTime.Today.AddYears(1));
}

if (i % 8 == 0)
{
player.EndBidding();
}

if (i % 16 == 0)
{
player.ExpireMatch();
}
}

_dbContext.Players.Add(player);
}
Expand Down
37 changes: 35 additions & 2 deletions src/Tests/Features/FreeAgents/DetailTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using DynamoLeagueBlazor.Shared.Features.FreeAgents;
using DynamoLeagueBlazor.Client.Features.FreeAgents;
using DynamoLeagueBlazor.Shared.Features.FreeAgents;
using Microsoft.Extensions.DependencyInjection;
using MudBlazor;
using System.Net.Http.Json;

namespace DynamoLeagueBlazor.Tests.Features.FreeAgents;

public class DetailTests : IntegrationTestBase
public class DetailServerTests : IntegrationTestBase
{
[Fact]
public async Task GivenUnauthenticatedUser_ThenDoesNotAllowAccess()
Expand Down Expand Up @@ -55,3 +58,33 @@ public async Task GivenAnyAuthenticatedUser_WhenGivenValidPlayerId_ThenReturnsEx
DateTime.Parse(bid.CreatedOn).Should().BeExactly(TimeSpan.FromSeconds(0));
}
}

public class DetailClientTests : UITestBase
{
[Fact]
public void WhenLoading_ThenShowsLoading()
{
TestContext!.Services.AddSingleton(Mock.Of<IBidValidator>());

GetHttpHandler.When(HttpMethod.Get)
.TimesOutAfter(5000);

var cut = RenderComponent<Detail>();

cut.HasComponent<MudSkeleton>().Should().BeTrue();
}

[Fact]
public void GivenData_ThenShowsFormAndTimeline()
{
TestContext!.Services.AddSingleton(Mock.Of<IBidValidator>());

GetHttpHandler.When(HttpMethod.Get)
.RespondsWithJson(AutoFaker.Generate<FreeAgentDetailResult>());

var cut = RenderComponent<Detail>();

cut.HasComponent<MudTimeline>().Should().BeTrue();
cut.HasComponent<MudNumericField<int>>().Should().BeTrue();
}
}
7 changes: 1 addition & 6 deletions src/Tests/Features/Teams/SignPlayerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@ public void WhenLoading_ThenShowsSkeleton()
{
// Delay the response.
GetHttpHandler.When(HttpMethod.Get)
.Respond(async () =>
{
await Task.Delay(2000);

return new HttpResponseMessage(HttpStatusCode.OK);
});
.TimesOutAfter(5000);
var component = RenderComponent<SignPlayer>();

component.HasComponent<MudDialog>().Should().BeTrue();
Expand Down

0 comments on commit 7101c79

Please sign in to comment.