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 Jul 23, 2024
1 parent 4f14d2a commit ef41c91
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-full govuk-grid-column-two-thirds-from-desktop">
<h1 class="govuk-heading-xl">@Model.Heading</h1>
<h1 class="govuk-heading-xl" id="heading">@Model.Heading</h1>
<dl class="govuk-summary-list">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
<dt class="govuk-summary-list__key" id="qualification-name-label">
@Model.QualificationLabel
</dt>
<dd class="govuk-summary-list__value" id="qualification-name-value">
@Model.QualificationName
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
<dt class="govuk-summary-list__key" id="qualification-level-label">
@Model.QualificationLevelLabel
</dt>
<dd class="govuk-summary-list__value" id="qualification-level-value">
@Model.QualificationLevel
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
<dt class="govuk-summary-list__key" id="awarding-organisation-label">
@Model.AwardingOrganisationLabel
</dt>
<dd class="govuk-summary-list__value" id="awarding-organisation-value">
Expand All @@ -49,29 +49,33 @@

@if (Model.HasErrors)
{
<p id="confirm-qualification-choice-error" class="govuk-error-message">
<p id="question-choice-error" class="govuk-error-message">
<span class="govuk-visually-hidden">Error:</span> @Model.ErrorMessage
</p>
}

@for (var qi = 0; qi < Model.AdditionalRequirementQuestions.Count; qi++)
{
var question = Model.AdditionalRequirementQuestions[qi];
var questionId = $"question_{qi}";
<div class="govuk-form-group">
<h3 class="govuk-heading-s">@question.Question</h3>
<h3 class="govuk-heading-s" id="@questionId">@question.Question</h3>
@if (!string.IsNullOrEmpty(question.HintText))
{
<p>@question.HintText</p>
var hintId = $"{questionId}_hint";
<p id="@hintId">@question.HintText</p>
}
@if (!string.IsNullOrEmpty(question.DetailsHeading) && !string.IsNullOrEmpty(question.DetailsContent))
{
var detailsHeadingId = $"{questionId}_details_heading";
var detailsContentId = $"{questionId}_details_content";
<details class="govuk-details">
<summary class="govuk-details__summary">
<span class="govuk-details__summary-text">
<span class="govuk-details__summary-text" id="@detailsHeadingId">
@question.DetailsHeading
</span>
</summary>
<div class="govuk-details__text">
<div class="govuk-details__text" id="@detailsContentId">
@Html.Raw(question.DetailsContent)
</div>
</details>
Expand All @@ -93,7 +97,7 @@
</div>
<div class="govuk-warning-text">
<span class="govuk-warning-text__icon" aria-hidden="true">!</span>
<strong class="govuk-warning-text__text">
<strong class="govuk-warning-text__text" id="additional-requirement-warning">
<span class="govuk-visually-hidden">Warning</span>
@Model.InformationMessage
</strong>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
describe("A spec that tests the check additional questions page", () => {
beforeEach(() => {
cy.setCookie('auth-secret', Cypress.env('auth_secret'));
})

// Mock details found in Dfe.EarlyYearsQualification.Mock.Content.MockContentfulService.
it("Checks the check additional questions details are on the page", () => {
cy.visit("/qualifications/check-additional-questions/eyq-240");

cy.get("#heading").should("contain.text", "Check the additional requirements");
cy.get("#qualification-name-label").should("contain.text", "Qualification");
cy.get("#qualification-name-value").should("contain.text", "T Level Technical Qualification in Education and Childcare (Specialism - Early Years Educator)");
cy.get("#qualification-level-label").should("contain.text", "Qualification level");
cy.get("#awarding-organisation-label").should("contain.text", "Awarding organisation");
cy.get("#awarding-organisation-value").should("contain.text", "NCFE");
cy.get("#question_0").should("contain.text", "Test question");
cy.get("#question_0_hint").should("contain.text", "This is the hint text");
cy.get("#question_0_details_heading").should("contain.text", "This is the details heading");
cy.get("#question_0_details_content").should("contain.text", "This is the details content");
cy.get("Label[for='yes_0_0']").should("contain.text", "Yes");
cy.get("Label[for='no_0_1']").should("contain.text", "No");
cy.get("#additional-requirement-warning").should("contain.text", "Your result is dependent on the accuracy of the answers you have provided");
cy.get("#additional-requirement-button").should("contain.text", "Get result");
})

it("Shows errors if user does not select an option", () => {
cy.visit("/qualifications/check-additional-questions/eyq-240");

cy.get("#additional-requirement-button").click();

cy.get("#question-choice-error").should("be.visible");
cy.get("#question-choice-error").should("contain.text", "This is a test error message");

cy.get(".govuk-form-group--error").should("be.visible");
});
})

0 comments on commit ef41c91

Please sign in to comment.