diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/FormsEngineTests.cs b/Frontend/CO.CDP.OrganisationApp.Tests/FormsEngineTests.cs index 3456a5237..6e872bb91 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/FormsEngineTests.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/FormsEngineTests.cs @@ -1,4 +1,5 @@ using CO.CDP.OrganisationApp.Models; +using CO.CDP.OrganisationApp.Pages.Forms.ChoiceProviderStrategies; using FluentAssertions; using Moq; using DataShareWebApiClient = CO.CDP.DataSharing.WebApiClient; @@ -11,6 +12,7 @@ public class FormsEngineTests private readonly Mock _formsApiClientMock; private readonly Mock _dataSharingClientMock; private readonly Mock _tempDataServiceMock; + private readonly Mock _choiceProviderServiceMock; private readonly FormsEngine _formsEngine; public FormsEngineTests() @@ -18,7 +20,8 @@ public FormsEngineTests() _formsApiClientMock = new Mock(); _dataSharingClientMock = new Mock(); _tempDataServiceMock = new Mock(); - _formsEngine = new FormsEngine(_formsApiClientMock.Object, _tempDataServiceMock.Object, _dataSharingClientMock.Object); + _choiceProviderServiceMock = new Mock(); + _formsEngine = new FormsEngine(_formsApiClientMock.Object, _tempDataServiceMock.Object, _choiceProviderServiceMock.Object, _dataSharingClientMock.Object); } private static (Guid organisationId, Guid formId, Guid sectionId, string sessionKey) CreateTestGuids() @@ -135,6 +138,8 @@ public async Task GetFormSectionAsync_ShouldFetchAndCacheResponse_WhenCachedResp _tempDataServiceMock.Setup(t => t.Peek(sessionKey)) .Returns((SectionQuestionsResponse?)null); + _choiceProviderServiceMock.Setup(t => t.GetStrategy(It.IsAny())) + .Returns(new DefaultChoiceProviderStrategy()); _formsApiClientMock.Setup(c => c.GetFormSectionQuestionsAsync(formId, sectionId, organisationId)) .ReturnsAsync(apiResponse); diff --git a/Frontend/CO.CDP.OrganisationApp/FormsEngine.cs b/Frontend/CO.CDP.OrganisationApp/FormsEngine.cs index 2687b897a..71021d588 100644 --- a/Frontend/CO.CDP.OrganisationApp/FormsEngine.cs +++ b/Frontend/CO.CDP.OrganisationApp/FormsEngine.cs @@ -8,7 +8,6 @@ namespace CO.CDP.OrganisationApp; public class FormsEngine( IFormsClient formsApiClient, ITempDataService tempDataService, - IServiceProvider serviceProvider, IChoiceProviderService choiceProviderService, DataShareWebApiClient.IDataSharingClient dataSharingClient) : IFormsEngine { @@ -19,10 +18,10 @@ public async Task GetFormSectionAsync(Guid organisatio var sessionKey = $"Form_{organisationId}_{formId}_{sectionId}_Questions"; var cachedResponse = tempDataService.Peek(sessionKey); - //if (cachedResponse != null) - //{ - // return cachedResponse; - //} + if (cachedResponse != null) + { + return cachedResponse; + } var response = await formsApiClient.GetFormSectionQuestionsAsync(formId, sectionId, organisationId); diff --git a/Frontend/CO.CDP.OrganisationApp/UserInfoService.cs b/Frontend/CO.CDP.OrganisationApp/UserInfoService.cs index 4dac31f7f..21383d9b2 100644 --- a/Frontend/CO.CDP.OrganisationApp/UserInfoService.cs +++ b/Frontend/CO.CDP.OrganisationApp/UserInfoService.cs @@ -26,7 +26,7 @@ public async Task UserHasScope(string scope) return scopes.Contains(scope); } - public async Task GetPersonOrganisation(Guid organisationId) + private async Task GetPersonOrganisation(Guid organisationId) { // Role checks may be made multiple times when building a page // Therefore we cache the person's organisation details for the duration of the http request