From 130e076064e6dba0881b5fb530c44bfc1bbc366f Mon Sep 17 00:00:00 2001 From: Sam Carter Date: Fri, 19 Jul 2024 14:51:41 +0100 Subject: [PATCH 01/14] Created initial data model for new page --- .../Constants/ContentTypes.cs | 1 + .../CheckAdditionalRequirementsPage.cs | 18 ++++++++++ .../Services/ContentfulContentService.cs | 15 +++++++- .../Services/IContentService.cs | 2 ++ .../Content/MockContentfulService.cs | 19 +++++++++++ .../Services/ContentfulContentServiceTests.cs | 34 +++++++++++++++++++ 6 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 src/Dfe.EarlyYearsQualification.Content/Entities/CheckAdditionalRequirementsPage.cs diff --git a/src/Dfe.EarlyYearsQualification.Content/Constants/ContentTypes.cs b/src/Dfe.EarlyYearsQualification.Content/Constants/ContentTypes.cs index ca1acce6..a6278faf 100644 --- a/src/Dfe.EarlyYearsQualification.Content/Constants/ContentTypes.cs +++ b/src/Dfe.EarlyYearsQualification.Content/Constants/ContentTypes.cs @@ -16,4 +16,5 @@ public static class ContentTypes public const string DropdownQuestionPage = "dropdownQuestionPage"; public const string QualificationListPage = "qualificationListPage"; public const string ConfirmQualificationPage = "confirmQualificationPage"; + public const string CheckAdditionalRequirementsPage = "checkAdditionalRequirementsPage"; } \ No newline at end of file diff --git a/src/Dfe.EarlyYearsQualification.Content/Entities/CheckAdditionalRequirementsPage.cs b/src/Dfe.EarlyYearsQualification.Content/Entities/CheckAdditionalRequirementsPage.cs new file mode 100644 index 00000000..7fdab55c --- /dev/null +++ b/src/Dfe.EarlyYearsQualification.Content/Entities/CheckAdditionalRequirementsPage.cs @@ -0,0 +1,18 @@ +namespace Dfe.EarlyYearsQualification.Content.Entities; + +public class CheckAdditionalRequirementsPage +{ + public string Heading { get; set; } = string.Empty; + + public NavigationLink? BackButton { get; init; } + + public string QualificationLabel { get; set; } = string.Empty; + + public string QualificationLevelLabel { get; set; } = string.Empty; + + public string AwardingOrganisationLabel { get; set; } = string.Empty; + + public string InformationMessage { get; set; } = string.Empty; + + public string CtaButtonText { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/src/Dfe.EarlyYearsQualification.Content/Services/ContentfulContentService.cs b/src/Dfe.EarlyYearsQualification.Content/Services/ContentfulContentService.cs index 2eb740f9..3b5c10c7 100644 --- a/src/Dfe.EarlyYearsQualification.Content/Services/ContentfulContentService.cs +++ b/src/Dfe.EarlyYearsQualification.Content/Services/ContentfulContentService.cs @@ -29,7 +29,8 @@ private readonly Dictionary _contentTypes { typeof(DateQuestionPage), ContentTypes.DateQuestionPage }, { typeof(DropdownQuestionPage), ContentTypes.DropdownQuestionPage }, { typeof(QualificationListPage), ContentTypes.QualificationListPage }, - { typeof(ConfirmQualificationPage), ContentTypes.ConfirmQualificationPage } + { typeof(ConfirmQualificationPage), ContentTypes.ConfirmQualificationPage }, + { typeof(CheckAdditionalRequirementsPage), ContentTypes.CheckAdditionalRequirementsPage } }; public async Task GetStartPage() @@ -194,6 +195,18 @@ public async Task> GetQualifications() return confirmQualificationEntities.First(); } + public async Task GetCheckAdditionalRequirementsPage() + { + var checkAdditionalRequirementsPageEntities = await GetEntriesByType(); + if (checkAdditionalRequirementsPageEntities is null || !checkAdditionalRequirementsPageEntities.Any()) + { + logger.LogWarning("No CheckAdditionalRequirementsPage entry returned"); + return default; + } + + return checkAdditionalRequirementsPageEntities.First(); + } + public async Task GetQualificationListPage() { var qualificationListPageEntities = await GetEntriesByType(); diff --git a/src/Dfe.EarlyYearsQualification.Content/Services/IContentService.cs b/src/Dfe.EarlyYearsQualification.Content/Services/IContentService.cs index 43562633..c87ed566 100644 --- a/src/Dfe.EarlyYearsQualification.Content/Services/IContentService.cs +++ b/src/Dfe.EarlyYearsQualification.Content/Services/IContentService.cs @@ -33,4 +33,6 @@ public interface IContentService Task GetQualificationListPage(); Task GetConfirmQualificationPage(); + + Task GetCheckAdditionalRequirementsPage(); } \ No newline at end of file diff --git a/src/Dfe.EarlyYearsQualification.Mock/Content/MockContentfulService.cs b/src/Dfe.EarlyYearsQualification.Mock/Content/MockContentfulService.cs index 7dd15819..884f73df 100644 --- a/src/Dfe.EarlyYearsQualification.Mock/Content/MockContentfulService.cs +++ b/src/Dfe.EarlyYearsQualification.Mock/Content/MockContentfulService.cs @@ -281,6 +281,25 @@ public Task> GetQualifications() }); } + public async Task GetCheckAdditionalRequirementsPage() + { + return await Task.FromResult(new CheckAdditionalRequirementsPage + { + Heading = "Check the additional requirements", + BackButton = new NavigationLink + { + DisplayText = "Back", + Href = "/", + OpenInNewTab = false + }, + CtaButtonText = "Get result", + AwardingOrganisationLabel = "Awarding organisation", + QualificationLabel = "Qualification", + QualificationLevelLabel = "Qualification level", + InformationMessage = "Your result is dependent on the accuracy of the answers you have provided" + }); + } + public async Task GetStartPage() { var preCtaButtonContent = diff --git a/tests/Dfe.EarlyYearsQualification.UnitTests/Services/ContentfulContentServiceTests.cs b/tests/Dfe.EarlyYearsQualification.UnitTests/Services/ContentfulContentServiceTests.cs index 8365546f..ff7cf53f 100644 --- a/tests/Dfe.EarlyYearsQualification.UnitTests/Services/ContentfulContentServiceTests.cs +++ b/tests/Dfe.EarlyYearsQualification.UnitTests/Services/ContentfulContentServiceTests.cs @@ -901,4 +901,38 @@ public async Task GetPage_WhenContentfulGetEntriesByTypeThrows_LogsError() _logger.VerifyError($"Exception trying to retrieve {nameof(StartPage)} from Contentful."); } + + [TestMethod] + public async Task GetCheckAdditionalRequirementsPage_ReturnsPage() + { + var page = new CheckAdditionalRequirementsPage { Heading = "Test heading" }; + + _clientMock.Setup(c => + c.GetEntriesByType(It.IsAny(), + It.IsAny>(), + It.IsAny())) + .ReturnsAsync(new ContentfulCollection { Items = [page] }); + + var service = new ContentfulContentService(_clientMock.Object, _logger.Object); + + var result = await service.GetCheckAdditionalRequirementsPage(); + + result.Should().Be(page); + } + + [TestMethod] + public async Task GetCheckAdditionalRequirementsPage_ContentfulHasNoPage_ReturnsNull() + { + _clientMock.Setup(c => + c.GetEntriesByType(It.IsAny(), + It.IsAny>(), + It.IsAny())) + .ReturnsAsync(new ContentfulCollection { Items = [] }); + + var service = new ContentfulContentService(_clientMock.Object, _logger.Object); + + var result = await service.GetCheckAdditionalRequirementsPage(); + + result.Should().BeNull(); + } } \ No newline at end of file From 41ea67a090fa19be918bb1161ee549c1a1b67cdd Mon Sep 17 00:00:00 2001 From: Sam Carter Date: Mon, 22 Jul 2024 15:00:42 +0100 Subject: [PATCH 02/14] Added in extra logic for the view and created the post method --- .../Entities/AdditionalRequirementQuestion.cs | 2 + .../CheckAdditionalRequirementsPage.cs | 16 ++- .../Services/ContentfulContentService.cs | 1 + .../Attributes/AnswerValidationAttribute.cs | 27 ++++ .../CheckAdditionalRequirementsController.cs | 129 ++++++++++++++++++ .../ConfirmQualificationController.cs | 39 +++--- .../QualificationDetailsController.cs | 2 - .../AdditionalRequirementQuestionModel.cs | 6 +- .../CheckAdditionalRequirementsPageModel.cs | 43 ++++++ .../Content/QuestionModels/OptionModel.cs | 8 ++ .../QuestionModels/RadioQuestionModel.cs | 7 - .../Models/UserJourneyModel.cs | 2 + .../IUserJourneyCookieService.cs | 2 + .../UserJourneyCookieService.cs | 15 ++ .../CheckAdditionalRequirements/Index.cshtml | 108 +++++++++++++++ .../ConfirmQualificationControllerTests.cs | 108 ++++++--------- .../Services/UserJourneyCookieServiceTests.cs | 37 +++++ 17 files changed, 447 insertions(+), 105 deletions(-) create mode 100644 src/Dfe.EarlyYearsQualification.Web/Attributes/AnswerValidationAttribute.cs create mode 100644 src/Dfe.EarlyYearsQualification.Web/Controllers/CheckAdditionalRequirementsController.cs create mode 100644 src/Dfe.EarlyYearsQualification.Web/Models/Content/CheckAdditionalRequirementsPageModel.cs create mode 100644 src/Dfe.EarlyYearsQualification.Web/Models/Content/QuestionModels/OptionModel.cs create mode 100644 src/Dfe.EarlyYearsQualification.Web/Views/CheckAdditionalRequirements/Index.cshtml diff --git a/src/Dfe.EarlyYearsQualification.Content/Entities/AdditionalRequirementQuestion.cs b/src/Dfe.EarlyYearsQualification.Content/Entities/AdditionalRequirementQuestion.cs index 66b00c92..d8f851e6 100644 --- a/src/Dfe.EarlyYearsQualification.Content/Entities/AdditionalRequirementQuestion.cs +++ b/src/Dfe.EarlyYearsQualification.Content/Entities/AdditionalRequirementQuestion.cs @@ -15,4 +15,6 @@ public class AdditionalRequirementQuestion public string ConfirmationStatement { get; set; } = string.Empty; public bool AnswerToBeFullAndRelevant { get; set; } + + public List