Skip to content

Commit

Permalink
start of unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielClarkeEducation committed Nov 21, 2024
1 parent 46c3f73 commit c21b55d
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -92,7 +92,8 @@ public Task<List<Qualification>> 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
Expand Down Expand Up @@ -161,42 +162,44 @@ private static Qualification CreateQualification(string qualificationId, string
bool includeAdditionalRequirementQuestions = true)
{
var additionalRequirementQuestions = includeAdditionalRequirementQuestions
? new List<AdditionalRequirementQuestion>{
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<AdditionalRequirementQuestion>
{
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",
Expand Down Expand Up @@ -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
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public async Task<IActionResult> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@model Dfe.EarlyYearsQualification.Web.Models.RatioRowModel

<div class="govuk-grid-row ratio-row">
<div id="[email protected]" class="govuk-grid-row ratio-row">
<div class="govuk-!-width-one-half">
<div class="govuk-!-static-margin-top-6 govuk-!-static-margin-bottom-6">
<p class="govuk-body govuk-!-text-align-left ratio-heading" id="@{@Model.LevelText}_heading"><strong>@Model.LevelText</strong></p>
Expand Down Expand Up @@ -34,7 +34,7 @@
@if ((!string.IsNullOrEmpty(Model.AdditionalInformation.AdditionalInformationBody) && !string.IsNullOrEmpty(Model.AdditionalInformation.AdditionalInformationHeader))
|| Model.AdditionalInformation.ShowAdditionalInformationBodyByDefault)
{
<div class="govuk-grid-row">
<div id="[email protected]" class="govuk-grid-row">
<div class="govuk-grid-column-full">
@{ await Html.RenderPartialAsync("Partials/AdditionalInformation", Model.AdditionalInformation); }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit c21b55d

Please sign in to comment.