Skip to content

Commit

Permalink
Added additional e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-c-dfe committed Aug 7, 2024
1 parent c9cb982 commit ede9406
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,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 @@ -133,17 +133,13 @@ public async Task<IActionResult> WhatLevelIsTheQualification(RadioQuestionModel
}

userJourneyCookieService.SetLevelOfQualification(model.Option!);

if (model.Option == "6")
{
var isPre2014 = WasAwardedBeforeSeptember2014();
return RedirectToAction(isPre2014 ? "Level6QualificationPre2014" : "Level6QualificationPost2014", "Advice");
}

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 @@ -195,7 +191,7 @@ public async Task<IActionResult> WhatIsTheAwardingOrganisation(DropdownQuestionM
return RedirectToAction("Get", "QualificationDetails");
}

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

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

0 comments on commit ede9406

Please sign in to comment.