From c21b55d35fc057116804dbb4c02fc7c0100c04d6 Mon Sep 17 00:00:00 2001 From: Daniel Clarke Date: Thu, 21 Nov 2024 13:45:03 +0000 Subject: [PATCH] start of unit tests --- .../Content/MockQualificationsRepository.cs | 147 +++++++++++++----- .../QualificationDetailsController.cs | 2 +- .../Views/Shared/Partials/RatioRow.cshtml | 4 +- .../pages/qualification-details-spec.cy.js | 8 + .../QualificationDetailsControllerTests.cs | 8 +- 5 files changed, 125 insertions(+), 44 deletions(-) diff --git a/src/Dfe.EarlyYearsQualification.Mock/Content/MockQualificationsRepository.cs b/src/Dfe.EarlyYearsQualification.Mock/Content/MockQualificationsRepository.cs index 66ea93ac..1109454b 100644 --- a/src/Dfe.EarlyYearsQualification.Mock/Content/MockQualificationsRepository.cs +++ b/src/Dfe.EarlyYearsQualification.Mock/Content/MockQualificationsRepository.cs @@ -17,7 +17,7 @@ public class MockQualificationsRepository : IQualificationsRepository "eyq-108" => await Task.FromResult(CreateQtsQualification("EYQ-108", "BTEC", AwardingOrganisations.Various, 6)), "eyq-115" => await Task.FromResult(CreateQualification("EYQ-115", "NCFE", - AwardingOrganisations.Various, 3, false)), + AwardingOrganisations.Various, 3, false)), _ => await Task.FromResult(CreateQualification("EYQ-240", "T Level Technical Qualification in Education and Childcare (Specialism - Early Years Educator)", AwardingOrganisations.Ncfe, 3)) @@ -92,7 +92,8 @@ public Task> Get(int? level, int? startDateMonth, int? start CreateQualification("EYQ-112", AwardingOrganisations.Pearson, 8, startDate, endDate), CreateQualification("EYQ-113", AwardingOrganisations.Cache, 8, startDate, endDate), CreateQualificationWithAdditionalRequirements("EYQ-909", AwardingOrganisations.Ncfe, 3, startDate, - endDate) + endDate), + CreateLevel2FurtherActionRequiredQualification("EYQ-114", "Level 2 Further Action Qualification", AwardingOrganisations.Ncfe, 5) }; // For now, inbound parameters startDateMonth and startDateYear are ignored @@ -161,42 +162,44 @@ private static Qualification CreateQualification(string qualificationId, string bool includeAdditionalRequirementQuestions = true) { var additionalRequirementQuestions = includeAdditionalRequirementQuestions - ? new List{ - new() - { - Question = "Test question", - HintText = - "This is the hint text: answer yes for full and relevant", - DetailsHeading = - "This is the details heading", - DetailsContent = - ContentfulContentHelper - .Paragraph("This is the details content"), - Answers = - [ - new Option - { - Label = "Yes", - Value = "yes" - }, + ? new List + { + new() + { + Question = "Test question", + HintText = + "This is the hint text: answer yes for full and relevant", + DetailsHeading = + "This is the details heading", + DetailsContent = + ContentfulContentHelper + .Paragraph("This is the details content"), + Answers = + [ + new Option + { + Label = "Yes", + Value = "yes" + }, + + new Option + { + Label = "No", + Value = "no" + } + ], + ConfirmationStatement = + "This is the confirmation statement 1", + AnswerToBeFullAndRelevant = true + }, + CreateSecondAdditionalRequirementQuestion(false) + } + : null; - new Option - { - Label = "No", - Value = "no" - } - ], - ConfirmationStatement = - "This is the confirmation statement 1", - AnswerToBeFullAndRelevant = true - }, - CreateSecondAdditionalRequirementQuestion(false) - } : null; - - return new Qualification(qualificationId, - qualificationName, - awardingOrganisation, - qualificationLevel) + return new Qualification(qualificationId, + qualificationName, + awardingOrganisation, + qualificationLevel) { FromWhichYear = "2020", ToWhichYear = "2021", @@ -358,4 +361,74 @@ private static AdditionalRequirementQuestion CreateSecondAdditionalRequirementQu AnswerToBeFullAndRelevant = answerToBeFullAndRelevant }; } + + private static Qualification CreateLevel2FurtherActionRequiredQualification( + string qualificationId, string qualificationName, + string awardingOrganisation, int qualificationLevel) + { + return new Qualification(qualificationId, + qualificationName, + awardingOrganisation, + qualificationLevel) + { + FromWhichYear = "2014", + ToWhichYear = "2019", + QualificationNumber = "603/5829/5", + RatioRequirements = + [ + new RatioRequirement + { + RatioRequirementName = + RatioRequirements + .Level2RatioRequirementName, + FullAndRelevantForLevel2After2014 = false, + FullAndRelevantForLevel3After2014 = false, + FullAndRelevantForLevel4After2014 = false, + FullAndRelevantForLevel5After2014 = false, + FullAndRelevantForLevel6After2014 = false, + FullAndRelevantForLevel7After2014 = false, + RequirementForLevel2BetweenSept14AndAug19 = ContentfulContentHelper.Paragraph("Level 2 further action required text") + }, + + new RatioRequirement + { + RatioRequirementName = + RatioRequirements + .Level3RatioRequirementName, + FullAndRelevantForLevel2After2014 = false, + FullAndRelevantForLevel3After2014 = false, + FullAndRelevantForLevel4After2014 = false, + FullAndRelevantForLevel5After2014 = false, + FullAndRelevantForLevel6After2014 = false, + FullAndRelevantForLevel7After2014 = false + }, + + new RatioRequirement + { + RatioRequirementName = RatioRequirements + .Level6RatioRequirementName, + FullAndRelevantForLevel2After2014 = false, + FullAndRelevantForLevel3After2014 = false, + FullAndRelevantForLevel4After2014 = false, + FullAndRelevantForLevel5After2014 = false, + FullAndRelevantForLevel6After2014 = false, + FullAndRelevantForLevel7After2014 = false + }, + + new RatioRequirement + { + RatioRequirementName = + RatioRequirements + .UnqualifiedRatioRequirementName, + FullAndRelevantForLevel2After2014 = true, + FullAndRelevantForLevel3After2014 = true, + FullAndRelevantForLevel4After2014 = true, + FullAndRelevantForLevel5After2014 = true, + FullAndRelevantForLevel6After2014 = true, + FullAndRelevantForLevel7After2014 = true + } + ], + IsAutomaticallyApprovedAtLevel6 = false + }; + } } \ No newline at end of file diff --git a/src/Dfe.EarlyYearsQualification.Web/Controllers/QualificationDetailsController.cs b/src/Dfe.EarlyYearsQualification.Web/Controllers/QualificationDetailsController.cs index 28995e6c..112c3f61 100644 --- a/src/Dfe.EarlyYearsQualification.Web/Controllers/QualificationDetailsController.cs +++ b/src/Dfe.EarlyYearsQualification.Web/Controllers/QualificationDetailsController.cs @@ -103,7 +103,7 @@ public async Task Index(string qualificationId) // Check if the qualification if not full and relevant and was started between Sept 2014 and Aug 2019 and is above a level 2 qualification if (model.RatioRequirements.IsNotFullAndRelevant && userJourneyCookieService.WasStartedBetweenSept2014AndAug2019() && qualification.QualificationLevel > 2) { - await QualIsNotLevel2NotApprovedAndStartedBetweenSept2014AndAug2019(model, qualification); + //await QualIsNotLevel2NotApprovedAndStartedBetweenSept2014AndAug2019(model, qualification); } return View(model); diff --git a/src/Dfe.EarlyYearsQualification.Web/Views/Shared/Partials/RatioRow.cshtml b/src/Dfe.EarlyYearsQualification.Web/Views/Shared/Partials/RatioRow.cshtml index 78560eb8..8862446f 100644 --- a/src/Dfe.EarlyYearsQualification.Web/Views/Shared/Partials/RatioRow.cshtml +++ b/src/Dfe.EarlyYearsQualification.Web/Views/Shared/Partials/RatioRow.cshtml @@ -1,6 +1,6 @@ @model Dfe.EarlyYearsQualification.Web.Models.RatioRowModel -
+

@Model.LevelText

@@ -34,7 +34,7 @@ @if ((!string.IsNullOrEmpty(Model.AdditionalInformation.AdditionalInformationBody) && !string.IsNullOrEmpty(Model.AdditionalInformation.AdditionalInformationHeader)) || Model.AdditionalInformation.ShowAdditionalInformationBodyByDefault) { -
+
@{ await Html.RenderPartialAsync("Partials/AdditionalInformation", Model.AdditionalInformation); }
diff --git a/tests/Dfe.EarlyYearsQualification.E2ETests/cypress/e2e/pages/qualification-details-spec.cy.js b/tests/Dfe.EarlyYearsQualification.E2ETests/cypress/e2e/pages/qualification-details-spec.cy.js index a0f899c8..b2e2d3dd 100644 --- a/tests/Dfe.EarlyYearsQualification.E2ETests/cypress/e2e/pages/qualification-details-spec.cy.js +++ b/tests/Dfe.EarlyYearsQualification.E2ETests/cypress/e2e/pages/qualification-details-spec.cy.js @@ -163,4 +163,12 @@ describe("A spec used to test the qualification details page", () => { expect(printStub).to.be.calledOnce }) }); + + it("When the user has a qualification that is above a level 2, started between Sept 2014 and Aug 2019, and is markes as not full and relevant, they see the level 2 qualification markes as 'Further action required'", () => { + cy.setCookie('user_journey', '%7B%22WhereWasQualificationAwarded%22%3A%22england%22%2C%22WhenWasQualificationStarted%22%3A%226%2F2016%22%2C%22LevelOfQualification%22%3A%225%22%2C%22WhatIsTheAwardingOrganisation%22%3A%22NCFE%22%2C%22SelectedAwardingOrganisationNotOnTheList%22%3Afalse%2C%22SearchCriteria%22%3A%22%22%2C%22AdditionalQuestionsAnswers%22%3A%7B%7D%2C%22QualificationWasSelectedFromList%22%3A1%7D'); + cy.visit("/qualifications/qualification-details/eyq-114"); + + cy.get("#ratio-Level 2 > .govuk-!-width-one-half .tag-padding-right > div > strong").should("contain.text", "Further action required"); + cy.get("#ratio-Level 2-additional-info").should("contain.text", "Level 2 further action required text"); + }); }); \ No newline at end of file diff --git a/tests/Dfe.EarlyYearsQualification.UnitTests/Controllers/QualificationDetailsControllerTests.cs b/tests/Dfe.EarlyYearsQualification.UnitTests/Controllers/QualificationDetailsControllerTests.cs index a39a2564..21a4daa1 100644 --- a/tests/Dfe.EarlyYearsQualification.UnitTests/Controllers/QualificationDetailsControllerTests.cs +++ b/tests/Dfe.EarlyYearsQualification.UnitTests/Controllers/QualificationDetailsControllerTests.cs @@ -1218,10 +1218,10 @@ public async Task Index_QualificationIsAutomaticallyApprovedAtL6_ApprovedAtL6() model.FromWhichYear.Should().Be(qualificationResult.FromWhichYear); model.QualificationNumber.Should().Be(qualificationResult.QualificationNumber); - model.RatioRequirements.ApprovedForLevel2.Should().BeTrue(); - model.RatioRequirements.ApprovedForLevel3.Should().BeTrue(); - model.RatioRequirements.ApprovedForLevel6.Should().BeTrue(); - model.RatioRequirements.ApprovedForUnqualified.Should().BeTrue(); + model.RatioRequirements.ApprovedForLevel2.Should().Be(QualificationApprovalStatus.Approved); + model.RatioRequirements.ApprovedForLevel3.Should().Be(QualificationApprovalStatus.Approved); + model.RatioRequirements.ApprovedForLevel6.Should().Be(QualificationApprovalStatus.Approved); + model.RatioRequirements.ApprovedForUnqualified.Should().Be(QualificationApprovalStatus.Approved); } [TestMethod]