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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
APPCONFIG__HOLIDAYURL: ${{ secrets.APPCONFIG__HOLIDAYURL }}
TEST_RESULTS_PATH: "/home/runner/work/StpFoodBlazor/StpFoodBlazor/StpFoodBlazorTest/TestResults"
TEST_ARTIFACTS_PATH: "/home/runner/work/StpFoodBlazor/StpFoodBlazor/StpFoodBlazorTest/TestArtifacts"
MIN_LINE_COVERAGE: 87
MIN_BRANCH_COVERAGE: 86
MIN_LINE_COVERAGE: 95
MIN_BRANCH_COVERAGE: 90
ASPNETCORE_ENVIRONMENT: "Development"
AZURE_IDENTITY_DISABLE_MULTITENANTAUTH: true
AZURE_IDENTITY_DISABLE_CP1: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@inherits ComponentBase

<div id="deals_no_records" class="container text-center">
<h2>No upcoming deals that are not yet active.</h2>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inherits LayoutComponentBase
@inherits ComponentBase

<div id="giftcards_no_records" class="container text-center">
<h2>No active gift card deals. These deals are most common in May/June and December.</h2>
Expand Down
7 changes: 7 additions & 0 deletions StpFoodBlazor/Components/Pages/UpcomingDeals.razor
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@
}
else
{
@if (deals.Length == 0)
{
<UpcomingDealsNoRecords/>
}
else
{
<DealTableBody deals="@deals" selectedDayOfWeek="" upcoming=true/>
}
}
</div>

Expand Down
2 changes: 1 addition & 1 deletion StpFoodBlazor/StpFoodBlazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<InformationalVersion>0.6.0</InformationalVersion>
<InformationalVersion>0.6.1</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>true</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>

Expand Down
65 changes: 65 additions & 0 deletions StpFoodBlazorTest/Pages/UpcomingDealsTest.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
@using Bunit
@using Bunit.Rendering
@using AngleSharp.Dom
@using AngleSharp.Html.Dom
@using StpFoodBlazor.Components.Pages
@using StpFoodBlazor.Models
@using StpFoodBlazor.Services
@using StpFoodBlazorTest.Services

@code {
private TestContext ctx;
private TestTimeService timeService = new TestTimeService();

public UpcomingDealsTest()
{
ctx = new TestContext();
ctx.Services.AddSingleton<IHolidayService>(new TestHolidayService());
ctx.Services.AddSingleton<ITimeService>(timeService);
}

void Dispose()
{
}

[Fact]
public void UpcomingDealsShouldIncludeUpcomingDeals()
{
TestDealService testDealService = new TestDealService();
testDealService.Deals = new DealEvent[]
{
new DealEvent
{
Name = "Test Place",
Deal = "Test description",
Day = DayOfWeek.Saturday.ToString(),
Start = "2100-05-15"
}
};
ctx.Services.AddSingleton<IDealService>(testDealService);

var cut = ctx.Render(@<UpcomingDeals />);
var elements = getElements(cut);

Assert.Equal(1, elements.ChildElementCount);
}

[Fact]
public void UpcomingDealsShouldDisplayMessageWhenNoUpcomingDeals()
{
TestDealService testDealService = new TestDealService();
testDealService.NoRecords = true;
ctx.Services.AddSingleton<IDealService>(testDealService);

var cut = ctx.Render(@<UpcomingDeals />);
cut.WaitForElement("#deals_no_records", TimeSpan.FromSeconds(5));

Assert.Contains("No upcoming deals that are not yet active.", cut.Markup);
}

private IElement getElements(IRenderedFragment cut)
{
cut.WaitForElement("#deals_table_body", TimeSpan.FromSeconds(5));
return cut.Find("#deals_table_body");
}
}
9 changes: 7 additions & 2 deletions StpFoodBlazorTest/Services/TestDealService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace StpFoodBlazorTest.Services
public class TestDealService : IDealService
{
private static readonly string DEAL_FIXTURES_PATH = Path.Combine(Directory.GetCurrentDirectory(), "fixtures", "deals.json");
public Boolean LongRunning { get; set; } = false;

public bool LongRunning { get; set; } = false;
public DealEvent[] Deals { get; set; } = [];
public bool NoRecords { get; set; } = false;

public async Task<DealEvent[]> GetDealsAsync()
{
Expand All @@ -21,6 +21,11 @@ public async Task<DealEvent[]> GetDealsAsync()
await Task.Delay(7000);
}

if (NoRecords)
{
return [];
}

if (Deals.Length > 0)
{
return Deals;
Expand Down
4 changes: 2 additions & 2 deletions StpFoodBlazorTest/Services/TestGiftCardService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace StpFoodBlazorTest.Services
public class TestGiftCardService : IGiftCardService
{
private static readonly string GIFTCARD_FIXTURES_PATH = Path.Combine(Directory.GetCurrentDirectory(), "fixtures", "giftcards.json");
public Boolean LongRunning { get; set; } = false;
public Boolean NoRecords { get; set; } = false;
public bool LongRunning { get; set; } = false;
public bool NoRecords { get; set; } = false;
public GiftCard[] Data { get; set; } = [];

public async Task<GiftCard[]> GetGiftCardsAsync()
Expand Down
Loading