Skip to content

Commit

Permalink
EYQB-485: Updated to add in the new advice pages for L6 (#294)
Browse files Browse the repository at this point in the history
* EYQB-485: Updated to add in the new advice pages for L6

* Fixed config

* Added additional e2e tests

* Updated the urls to check

* Fixed broken unit test
  • Loading branch information
sam-c-dfe authored Aug 7, 2024
1 parent db82d3d commit 049c8fd
Show file tree
Hide file tree
Showing 13 changed files with 257 additions and 12 deletions.
10 changes: 10 additions & 0 deletions src/Dfe.EarlyYearsQualification.Content/Constants/AdvicePages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,14 @@ public static class AdvicePages
/// Entry ID for the "Qualification Level 7" advice page
/// </summary>
public const string QualificationLevel7 = "1bGiyvwsJZPd14dwrVtWCM";

/// <summary>
/// Entry ID for the "Level 6 qualification pre-2014" advice page.
/// </summary>
public const string Level6QualificationPre2014 = "2TT7k2J5KUNmUQ3f8A56tw";

/// <summary>
/// Entry ID for the "Level 6 qualification post-2014" advice page.
/// </summary>
public const string Level6QualificationPost2014 = "5aoy3C3jIEKdMo8fauvyvk";
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public Task<string> RenderAsync(IContent content)
{
var heading = content as Heading4;
var headingText = heading!.Content[0] as Text;
return Task.FromResult($"<h4 class='govuk-heading-m'>{headingText!.Value}</h4>");
return Task.FromResult($"<h4 class='govuk-heading-s'>{headingText!.Value}</h4>");
}

public bool SupportsContent(IContent content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ await Task.FromResult(CreateAdvicePage("Qualification at Level 7",
body,
WhatLevelIsTheQualificationPath)),


AdvicePages.Level6QualificationPre2014 =>
await Task.FromResult(CreateAdvicePage("Level 6 qualification pre 2014",
body, WhatLevelIsTheQualificationPath)),

AdvicePages.Level6QualificationPost2014 =>
await Task.FromResult(CreateAdvicePage("Level 6 qualification post 2014",
body, WhatLevelIsTheQualificationPath)),
_ => null
};
}
Expand Down Expand Up @@ -497,6 +505,10 @@ private static RadioQuestionPage CreateWhatLevelIsTheQualificationPage()
Label = "Level 3", Value = "3"
},
new()
{
Label = "Level 6", Value = "6"
},
new()
{
Label = "Level 7", Value = "7"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ public async Task<IActionResult> QualificationNotOnTheList()
{
return await GetView(AdvicePages.QualificationNotOnTheList);
}

[HttpGet("level-6-qualification-pre-2014")]
public async Task<IActionResult> Level6QualificationPre2014()
{
return await GetView(AdvicePages.Level6QualificationPre2014);
}

[HttpGet("level-6-qualification-post-2014")]
public async Task<IActionResult> Level6QualificationPost2014()
{
return await GetView(AdvicePages.Level6QualificationPost2014);
}

[HttpGet("qualification-level-7")]
public async Task<IActionResult> QualificationLevel7()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,13 @@ public async Task<IActionResult> WhatLevelIsTheQualification(RadioQuestionModel
}

userJourneyCookieService.SetLevelOfQualification(model.Option!);

return model.Option switch
{
"2" when WasAwardedBetweenSeptember2014AndAugust2019() =>
RedirectToAction("QualificationsStartedBetweenSept2014AndAug2019", "Advice"),
"6" =>
RedirectToAction(WasStartedBeforeSeptember2014() ? "Level6QualificationPre2014" : "Level6QualificationPost2014", "Advice"),
"7" => RedirectToAction(nameof(AdviceController.QualificationLevel7), "Advice"),
_ => RedirectToAction(nameof(this.WhatIsTheAwardingOrganisation))
};
Expand Down Expand Up @@ -189,6 +191,19 @@ public async Task<IActionResult> WhatIsTheAwardingOrganisation(DropdownQuestionM
return RedirectToAction("Get", "QualificationDetails");
}

private bool WasStartedBeforeSeptember2014()
{
var (startDateMonth, startDateYear) = userJourneyCookieService.GetWhenWasQualificationAwarded();

if (startDateMonth is null || startDateYear is null)
{
return false;
}

var date = new DateOnly(startDateYear.Value, startDateMonth.Value, 1);
return date < new DateOnly(2014, 9, 1);
}

private bool WasAwardedBetweenSeptember2014AndAugust2019()
{
var (startDateMonth, startDateYear) = userJourneyCookieService.GetWhenWasQualificationAwarded();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="govuk-grid-row ratio-row">
<div class="govuk-!-width-one-half">
<div class="govuk-!-static-margin-top-6 govuk-!-static-margin-bottom-6">
<b class="govuk-!-text-align-left ratio-heading" id="@{@Model.LevelText}_heading">@Model.LevelText</b>
<p class="govuk-body govuk-!-text-align-left ratio-heading" id="@{@Model.LevelText}_heading"><strong>@Model.LevelText</strong></p>
</div>
</div>
<div class="govuk-!-width-one-half no-padding-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ var config = {
"http://localhost:5000/advice/qualifications-achieved-in-wales",
"http://localhost:5000/advice/qualifications-achieved-in-northern-ireland",
"http://localhost:5000/advice/qualification-not-on-the-list",
"http://localhost:5000/advice/qualification-level-7"
"http://localhost:5000/advice/qualification-level-7",
"http://localhost:5000/advice/level-6-qualification-pre-2014",
"http://localhost:5000/advice/level-6-qualification-post-2014"
]
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,88 @@ describe('A spec used to test the various routes through the journey', () => {
})
})

it("Selecting qualification level 6 started before 1 Sept 2014 should navigate to the level 6 pre 2014 advice page", () => {
// home page
cy.get('.govuk-button--start').click();

// where-was-the-qualification-awarded page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/where-was-the-qualification-awarded');
})

cy.get('#england').click();
cy.get('button[id="question-submit"]').click();

// when-was-the-qualification-started page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/when-was-the-qualification-started');
})

cy.get('#date-started-month').type("8");
cy.get('#date-started-year').type("2014");
cy.get('button[id="question-submit"]').click();

// what-level-is-the-qualification page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/what-level-is-the-qualification');
})
cy.get('#6').click();
cy.get('button[id="question-submit"]').click();

// level 6 pre 2014 advice page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/advice/level-6-qualification-pre-2014');
})

// check back button goes back to the what level is the qualification page
cy.get('#back-button').click();

cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/what-level-is-the-qualification');
})
})

it("Selecting qualification level 6 started after 1 Sept 2014 should navigate to the level 6 post 2014 advice page", () => {
// home page
cy.get('.govuk-button--start').click();

// where-was-the-qualification-awarded page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/where-was-the-qualification-awarded');
})

cy.get('#england').click();
cy.get('button[id="question-submit"]').click();

// when-was-the-qualification-started page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/when-was-the-qualification-started');
})

cy.get('#date-started-month').type("8");
cy.get('#date-started-year').type("2015");
cy.get('button[id="question-submit"]').click();

// what-level-is-the-qualification page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/what-level-is-the-qualification');
})
cy.get('#6').click();
cy.get('button[id="question-submit"]').click();

// level 6 post 2014 advice page
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/advice/level-6-qualification-post-2014');
})

// check back button goes back to the what level is the qualification page
cy.get('#back-button').click();

cy.location().should((loc) => {
expect(loc.pathname).to.eq('/questions/what-level-is-the-qualification');
})
})

it("Selecting qualification level 7 should navigate to the level 7 advice page", () => {
// home page
cy.get('.govuk-button--start').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ describe("A spec that tests advice pages", () => {
cy.get("#advice-page-heading").should("contain.text", "Qualifications achieved in Northern Ireland");
cy.get("#advice-page-body").should("contain.text", "Test Advice Page Body");
})

it("Checks the Level 6 qualification pre 2014 details are on the page", () => {
cy.visit("/advice/level-6-qualification-pre-2014");

cy.get("#advice-page-heading").should("contain.text", "Level 6 qualification pre 2014");
cy.get("#advice-page-body").should("contain.text", "Test Advice Page Body");
})

it("Checks the Level 6 qualification post 2014 details are on the page", () => {
cy.visit("/advice/level-6-qualification-post-2014");

cy.get("#advice-page-heading").should("contain.text", "Level 6 qualification post 2014");
cy.get("#advice-page-body").should("contain.text", "Test Advice Page Body");
})

it("Checks the Qualifications level 7 details are on the page", () => {
cy.visit("/advice/qualification-level-7");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export const pages = [
"/",
"/accessibility-statement",
"/advice/qualification-outside-the-united-kingdom",
"/advice/level-2-qualifications-started-between-1-sept-2014-and-31-aug-2019",
"/cookies",
"/questions/where-was-the-qualification-awarded",
"/questions/when-was-the-qualification-started",
Expand All @@ -11,7 +9,16 @@ export const pages = [
"/qualifications",
"/confirm-qualification/EYQ-240",
"/qualifications/qualification-details/EYQ-240",
"/qualifications/check-additional-questions/EYQ-240"
"/qualifications/check-additional-questions/EYQ-240",
"/advice/qualification-outside-the-united-kingdom",
"/advice/level-2-qualifications-started-between-1-sept-2014-and-31-aug-2019",
"/advice/qualifications-achieved-in-scotland",
"/advice/qualifications-achieved-in-wales",
"/advice/qualifications-achieved-in-northern-ireland",
"/advice/qualification-not-on-the-list",
"/advice/qualification-level-7",
"/advice/level-6-qualification-pre-2014",
"/advice/level-6-qualification-post-2014"
];

export const pagesWithForms = [
Expand All @@ -28,11 +35,14 @@ export const pagesWithForms = [
export const pagesWithoutForms = [
"/",
"/accessibility-statement",
"/qualifications/qualification-details/EYQ-240",
"/advice/qualification-outside-the-united-kingdom",
"/advice/level-2-qualifications-started-between-1-sept-2014-and-31-aug-2019",
"/qualifications/qualification-details/EYQ-240",
"/advice/qualifications-achieved-in-scotland",
"/advice/qualifications-achieved-in-wales",
"/advice/qualifications-achieved-in-northern-ireland",
"/advice/qualification-not-on-the-list",
"/advice/qualification-level-7",
"/advice/level-6-qualification-pre-2014",
"/advice/level-6-qualification-post-2014"
]
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,66 @@ public async Task Post_WhatLevelIsTheQualification_Level2WithInDate_ReturnsRedir
resultType!.ActionName.Should().Be("QualificationsStartedBetweenSept2014AndAug2019");
resultType.ControllerName.Should().Be("Advice");
}

[TestMethod]
public async Task Post_WhatLevelIsTheQualification_Level6Pre2014_ReturnsRedirectResponse()
{
var mockLogger = new Mock<ILogger<QuestionsController>>();
var mockContentService = new Mock<IContentService>();
var mockRenderer = new Mock<IHtmlRenderer>();
var mockUserJourneyCookieService = new Mock<IUserJourneyCookieService>();
var mockContentFilterService = new Mock<IContentFilterService>();
var mockQuestionModelValidator = new Mock<IDateQuestionModelValidator>();

mockUserJourneyCookieService.Setup(x => x.GetWhenWasQualificationAwarded())
.Returns((7, 2014));
var controller = new QuestionsController(mockLogger.Object, mockContentService.Object, mockRenderer.Object,
mockUserJourneyCookieService.Object, mockContentFilterService.Object,
mockQuestionModelValidator.Object);

var result = await controller.WhatLevelIsTheQualification(new RadioQuestionModel
{
Option = "6"
});

result.Should().NotBeNull();

var resultType = result as RedirectToActionResult;
resultType.Should().NotBeNull();

resultType!.ActionName.Should().Be("Level6QualificationPre2014");
resultType.ControllerName.Should().Be("Advice");
}

[TestMethod]
public async Task Post_WhatLevelIsTheQualification_Level6Post2014_ReturnsRedirectResponse()
{
var mockLogger = new Mock<ILogger<QuestionsController>>();
var mockContentService = new Mock<IContentService>();
var mockRenderer = new Mock<IHtmlRenderer>();
var mockUserJourneyCookieService = new Mock<IUserJourneyCookieService>();
var mockContentFilterService = new Mock<IContentFilterService>();
var mockQuestionModelValidator = new Mock<IDateQuestionModelValidator>();

mockUserJourneyCookieService.Setup(x => x.GetWhenWasQualificationAwarded())
.Returns((7, 2015));
var controller = new QuestionsController(mockLogger.Object, mockContentService.Object, mockRenderer.Object,
mockUserJourneyCookieService.Object, mockContentFilterService.Object,
mockQuestionModelValidator.Object);

var result = await controller.WhatLevelIsTheQualification(new RadioQuestionModel
{
Option = "6"
});

result.Should().NotBeNull();

var resultType = result as RedirectToActionResult;
resultType.Should().NotBeNull();

resultType!.ActionName.Should().Be("Level6QualificationPost2014");
resultType.ControllerName.Should().Be("Advice");
}

[TestMethod]
public async Task Post_WhatLevelIsTheQualification_Level7_ReturnsRedirectResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,32 @@ public async Task GetAdvicePage_QualificationLevel7_ReturnsExpectedDetails()
result.Body!.Content[0].Should().BeAssignableTo<Paragraph>()
.Which.Content.Should().ContainSingle(x => ((Text)x).Value == "Test Advice Page Body");
}

[TestMethod]
public async Task GetAdvicePage_Level6QualificationPre2014_ReturnsExpectedDetails()
{
var contentfulService = new MockContentfulService();

var result = await contentfulService.GetAdvicePage(AdvicePages.Level6QualificationPre2014);
result.Should().NotBeNull();
result.Should().BeAssignableTo<AdvicePage>();
result!.Heading.Should().NotBeNullOrEmpty();
result.Body!.Content[0].Should().BeAssignableTo<Paragraph>()
.Which.Content.Should().ContainSingle(x => ((Text)x).Value == "Test Advice Page Body");
}

[TestMethod]
public async Task GetAdvicePage_Level6QualificationPost2014_ReturnsExpectedDetails()
{
var contentfulService = new MockContentfulService();

var result = await contentfulService.GetAdvicePage(AdvicePages.Level6QualificationPost2014);
result.Should().NotBeNull();
result.Should().BeAssignableTo<AdvicePage>();
result!.Heading.Should().NotBeNullOrEmpty();
result.Body!.Content[0].Should().BeAssignableTo<Paragraph>()
.Which.Content.Should().ContainSingle(x => ((Text)x).Value == "Test Advice Page Body");
}

[TestMethod]
public async Task GetAdvicePage_UnknownEntryId_ReturnsException()
Expand Down Expand Up @@ -292,13 +318,15 @@ public async Task GetRadioQuestionPage_PassInWhatLevelIsTheQualification_Returns
result.AdditionalInformationBody!.Content[0].Should().BeAssignableTo<Paragraph>()
.Which.Content.Should().ContainSingle(x => ((Text)x).Value == "This is the additional information body");
result.Options.Should().NotBeNullOrEmpty();
result.Options.Count.Should().Be(3);
result.Options.Count.Should().Be(4);
result.Options[0].Label.Should().Be("Level 2");
result.Options[0].Value.Should().Be("2");
result.Options[1].Label.Should().Be("Level 3");
result.Options[1].Value.Should().Be("3");
result.Options[2].Label.Should().Be("Level 7");
result.Options[2].Value.Should().Be("7");
result.Options[2].Label.Should().Be("Level 6");
result.Options[2].Value.Should().Be("6");
result.Options[3].Label.Should().Be("Level 7");
result.Options[3].Value.Should().Be("7");
}

[TestMethod]
Expand Down
Loading

0 comments on commit 049c8fd

Please sign in to comment.