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
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public async Task MerchantSchedule_SaveSelectedYear_InvalidNovemberDate_ShowsErr

SetupPageData(merchantId, currentYear, new MerchantModels.MerchantScheduleModel { Year = currentYear, Months = [] });
SetupSchedule(futureYear, new MerchantModels.MerchantScheduleModel { Year = futureYear, Months = [] });

var cut = RenderComponent<Schedule>(parameters => parameters.Add(p => p.MerchantId, merchantId));
cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

Expand All @@ -139,18 +139,7 @@ public async Task MerchantSchedule_SaveSelectedYear_InvalidNovemberDate_ShowsErr
cut.WaitForAssertion(() => cut.Find("#month-1-closed-days").HasAttribute("disabled").ShouldBeFalse(), timeout: TimeSpan.FromSeconds(5));
cut.Find("#month-11-closed-days").Change("31");

var validationMembers = GetScheduleValidationMembers(cut.Instance);

validationMembers.SaveScheduleAsyncMethod.ShouldNotBeNull();
validationMembers.ErrorMessageField.ShouldNotBeNull();

await cut.InvokeAsync(async () =>
{
var task = (Task)validationMembers.SaveScheduleAsyncMethod.Invoke(cut.Instance, null);
await task;
});

validationMembers.ErrorMessageField.GetValue(cut.Instance).ShouldBe($"Only days between 1 and 30 can be supplied for November {futureYear}.");
cut.Markup.ShouldContain($"Invalid closed days for November.");
this.MerchantUIService.Verify(m => m.SaveMerchantSchedule(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), merchantId,
It.IsAny<MerchantModels.MerchantScheduleModel>()), Times.Never);
}
Expand Down Expand Up @@ -196,7 +185,8 @@ public async Task MerchantSchedule_SaveSelectedYear_NonLeapYearFebruary_Rejects2

SetupPageData(merchantId, currentYear, new MerchantModels.MerchantScheduleModel { Year = currentYear, Months = [] });
SetupSchedule(nonLeapYear, new MerchantModels.MerchantScheduleModel { Year = nonLeapYear, Months = [] });

this.MerchantUIService.Setup(m => m.SaveMerchantSchedule(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), merchantId,
It.IsAny<MerchantModels.MerchantScheduleModel>())).ReturnsAsync(Result.Failure($"Only days between 1 and 28 can be supplied for February {nonLeapYear}."));
var cut = RenderComponent<Schedule>(parameters => parameters.Add(p => p.MerchantId, merchantId));
cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

Expand All @@ -216,9 +206,7 @@ await cut.InvokeAsync(async () =>
await task;
});

validationMembers.ErrorMessageField.GetValue(cut.Instance).ShouldBe($"Only days between 1 and 28 can be supplied for February {nonLeapYear}.");
this.MerchantUIService.Verify(m => m.SaveMerchantSchedule(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), merchantId,
It.IsAny<MerchantModels.MerchantScheduleModel>()), Times.Never);
cut.Markup.ShouldContain($"Only days between 1 and 28 can be supplied for February {nonLeapYear}.");
}

[Fact]
Expand All @@ -244,6 +232,28 @@ public void MerchantSchedule_PreviousYear_IsReadOnly()
[Fact]
public void MerchantSchedule_ReadOnlyMode_DisablesEditingControls()
{
//var merchantId = Guid.NewGuid();
//var currentYear = DateTime.Today.Year;

//SetupPageData(merchantId, currentYear, new MerchantModels.MerchantScheduleModel
//{
// Year = currentYear,
// Months = new List<MerchantModels.MerchantScheduleMonthModel>
// {
// new() { Month = currentYear == DateTime.Today.Year && DateTime.Today.Month == 12 ? 12 : DateTime.Today.Month + 1, ClosedDays = new List<Int32> { 1, 2 } }
// }
//});

//_fakeNavigationManager.NavigateTo($"/merchants/{merchantId}/schedule?readOnly=true");

//var cut = RenderComponent<Schedule>(parameters => parameters
// .Add(p => p.MerchantId, merchantId));
//cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

//cut.Markup.ShouldContain("Selected Year Schedule");
//cut.Find("#month-1-closed-days").HasAttribute("disabled").ShouldBeTrue();
//cut.FindAll("#clonePreviousYearButton").Count.ShouldBe(0);
//cut.FindAll("#saveScheduleButton").Count.ShouldBe(0);
var merchantId = Guid.NewGuid();
var currentYear = DateTime.Today.Year;

Expand All @@ -256,10 +266,9 @@ public void MerchantSchedule_ReadOnlyMode_DisablesEditingControls()
}
});

_fakeNavigationManager.NavigateTo($"/merchants/{merchantId}/schedule?readOnly=true");

var cut = RenderComponent<Schedule>(parameters => parameters
.Add(p => p.MerchantId, merchantId));
.Add(p => p.MerchantId, merchantId)
.Add(p => p.ReadOnly, true));
cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

cut.Markup.ShouldContain("Selected Year Schedule");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,18 @@ private void SetupSuccessfulDataLoad(Guid merchantId,
Balance = 1000.00m,
AvailableBalance = 500.00m
};


var openingHours = new MerchantModels.MerchantOpeningHoursModel
{
Monday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Tuesday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Wednesday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Thursday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Friday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Saturday = new MerchantModels.DayOpeningHoursModel { Opening = "0900", Closing = "1600" },
Sunday = new MerchantModels.DayOpeningHoursModel { Opening = "1000", Closing = "1500" }
};

this.MerchantUIService.Setup(m => m.GetMerchant(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), merchantId))
.ReturnsAsync(Result.Success(merchant));

Expand All @@ -1229,7 +1240,9 @@ private void SetupSuccessfulDataLoad(Guid merchantId,

this.MerchantUIService.Setup(m => m.GetMerchantDevices(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), merchantId))
.ReturnsAsync(Result.Success(assignedDevices ?? new List<MerchantModels.MerchantDeviceModel>()));

this.MerchantUIService.Setup(m => m.GetMerchantOpeningHours(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), merchantId))
.ReturnsAsync(Result.Success(openingHours));

this.OperatorUIService.Setup(o => o.GetOperatorsForDropDown(It.IsAny<CorrelationId>(), It.IsAny<Guid>()))
.ReturnsAsync(Result.Success(availableOperators ?? new List<OperatorModels.OperatorDropDownModel>()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public void MerchantsView_InitialState_ShowsLoadingIndicator()
this.MerchantUIService.Setup(m => m.GetMerchantOperators(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantOperatorModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantContracts(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantContractModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantDevices(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantDeviceModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantOpeningHours(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new MerchantModels.MerchantOpeningHoursModel()));

// Act
var cut = RenderComponent<View>(parameters => parameters
Expand All @@ -58,7 +59,7 @@ public void MerchantsView_WithMerchant_DisplaysMerchantName()
this.MerchantUIService.Setup(m => m.GetMerchantOperators(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantOperatorModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantContracts(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantContractModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantDevices(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantDeviceModel>()));

this.MerchantUIService.Setup(m => m.GetMerchantOpeningHours(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new MerchantModels.MerchantOpeningHoursModel()));

// Act
var cut = RenderComponent<View>(parameters => parameters
Expand Down Expand Up @@ -87,6 +88,7 @@ public void MerchantsView_HasCorrectPageTitle()
this.MerchantUIService.Setup(m => m.GetMerchantOperators(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantOperatorModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantContracts(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantContractModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantDevices(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantDeviceModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantOpeningHours(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new MerchantModels.MerchantOpeningHoursModel()));

// Act
var cut = RenderComponent<View>(parameters => parameters
Expand Down Expand Up @@ -114,7 +116,7 @@ public void MerchantsView_HasBackButton()
this.MerchantUIService.Setup(m => m.GetMerchantOperators(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantOperatorModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantContracts(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantContractModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantDevices(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new List<MerchantModels.MerchantDeviceModel>()));

this.MerchantUIService.Setup(m => m.GetMerchantOpeningHours(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>())).ReturnsAsync(Result.Success(new MerchantModels.MerchantOpeningHoursModel()));

// Act
var cut = RenderComponent<View>(parameters => parameters
Expand Down Expand Up @@ -506,27 +508,10 @@ public void MerchantsView_DisplaysContactDetails_WhenPresent()
[Fact]
public void MerchantsView_DisplaysOpeningHours_WhenPresent()
{
var merchant = new MerchantModels.MerchantModel
{
MerchantId = Guid.NewGuid(),
MerchantName = "Test Merchant",
MerchantReference = "REF001",
OpeningHours = new MerchantModels.MerchantOpeningHoursModel
{
Monday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Tuesday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Wednesday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Thursday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Friday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Saturday = new MerchantModels.DayOpeningHoursModel { Opening = "0900", Closing = "1600" },
Sunday = new MerchantModels.DayOpeningHoursModel { Opening = "1000", Closing = "1500" }
}
};

SetupSuccessfulDataLoadWithMerchant(merchant);
SetupSuccessfulDataLoad();

var cut = RenderComponent<View>(parameters => parameters
.Add(p => p.MerchantId, merchant.MerchantId));
.Add(p => p.MerchantId, Guid.NewGuid()));
cut.WaitForState(() => !cut.Markup.Contains("animate-spin"), TimeSpan.FromSeconds(5));

IRefreshableElementCollection<IElement> buttons = cut.FindAll("button");
Expand Down Expand Up @@ -595,6 +580,17 @@ private void SetupSuccessfulDataLoad(
MerchantReference = "REF001"
};

var openingHours = new MerchantModels.MerchantOpeningHoursModel
{
Monday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Tuesday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Wednesday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Thursday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Friday = new MerchantModels.DayOpeningHoursModel { Opening = "0800", Closing = "1700" },
Saturday = new MerchantModels.DayOpeningHoursModel { Opening = "0900", Closing = "1600" },
Sunday = new MerchantModels.DayOpeningHoursModel { Opening = "1000", Closing = "1500" }
};

this.MerchantUIService.Setup(m => m.GetMerchant(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>()))
.ReturnsAsync(Result.Success(merchant));
this.MerchantUIService.Setup(m => m.GetMerchantOperators(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>()))
Expand All @@ -603,6 +599,8 @@ private void SetupSuccessfulDataLoad(
.ReturnsAsync(Result.Success(contracts ?? new List<MerchantModels.MerchantContractModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantDevices(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>()))
.ReturnsAsync(Result.Success(devices ?? new List<MerchantModels.MerchantDeviceModel>()));
this.MerchantUIService.Setup(m => m.GetMerchantOpeningHours(It.IsAny<CorrelationId>(), It.IsAny<Guid>(), It.IsAny<Guid>()))
.ReturnsAsync(Result.Success(openingHours ?? new MerchantModels.MerchantOpeningHoursModel()));
}

private void SetupSuccessfulDataLoadWithMerchant(MerchantModels.MerchantModel merchant)
Expand Down
Loading
Loading