Skip to content

Commit

Permalink
Merge pull request #304 from DFE-Digital/feature/no-result-content
Browse files Browse the repository at this point in the history
Feature/no result content
  • Loading branch information
DanielClarkeEducation authored Aug 12, 2024
2 parents 07db28f + 4c1ebe7 commit 242c4f4
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ jobs:
/d:sonar.qualitygate.wait=true \
/d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml \
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" \
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.host.url="https://sonarcloud.io" \
/d:sonar.exclusions=tests/Dfe.EarlyYearsQualification.E2ETests/**
dotnet build --no-incremental
dotnet-coverage collect --settings dotnet-cover-config.xml -f xml -o coverage.xml "dotnet test"
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ public class QualificationListPage
public string AnyLevelHeading { get; init; } = string.Empty;

public string AnyAwardingOrganisationHeading { get; init; } = string.Empty;

public Document? NoResultsText { get; init; }

public string ClearSearchText { get; init; } = string.Empty;

public string NoQualificationsFoundText { get; init; } = string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public static async Task<string> Render(List<IContent> content)
continue;

case Text t:
if (t.Marks?.Exists(mark => mark.Type == "bold") == true)
{
sb.Append("<b>");
sb.Append(t.Value);
sb.Append("</b>");
continue;
}

sb.Append(t.Value);
continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,10 @@ public Task<List<Qualification>> GetQualifications()
PostSearchCriteriaContent =
ContentfulContentHelper.Text("Post search criteria content"),
AnyLevelHeading = "Any level",
AnyAwardingOrganisationHeading = "Various awarding organisations"
AnyAwardingOrganisationHeading = "Various awarding organisations",
NoResultsText = ContentfulContentHelper.ParagraphWithBold("Test no qualifications text"),
ClearSearchText = "Clear search",
NoQualificationsFoundText = "No"
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,30 @@ public static Document Link(string text, string href)
]
};
}

public static Document ParagraphWithBold(string text)
{
return new Document
{
Content =
[
new Paragraph
{
Content =
[
new Text
{
Value = text, Marks =
[
new Mark()
{
Type = "bold"
}
]
}
]
}
]
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ private async Task<QualificationListModel> MapList(QualificationListPage content
PostQualificationListContent = await htmlRenderer.ToHtml(content.PostQualificationListContent),
SearchCriteriaHeading = content.SearchCriteriaHeading,
SearchCriteria = userJourneyCookieService.GetSearchCriteria(),
Qualifications = basicQualificationsModels.OrderBy(x => x.QualificationName).ToList()
Qualifications = basicQualificationsModels.OrderBy(x => x.QualificationName).ToList(),
NoResultText = await htmlRenderer.ToHtml(content.NoResultsText),
ClearSearchText = content.ClearSearchText,
NoQualificationsFoundText = content.NoQualificationsFoundText
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ public class QualificationListModel
public string? SearchCriteria { get; init; } = string.Empty;

public List<BasicQualificationModel> Qualifications { get; init; } = [];

public string NoResultText { get; init; } = string.Empty;

public string ClearSearchText { get; init; } = string.Empty;

public string NoQualificationsFoundText { get; init; } = string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public static SecureHeadersMiddlewareConfiguration CustomConfiguration()
CommandType = CspCommandType.Directive,
DirectiveOrUri = "sha256-GUQ5ad8JK5KmEWmROf3LZd9ge94daqNvd8xy9YS1iDw="
};

var govukAllMinifiedElement = new ContentSecurityPolicyElement
{
CommandType = CspCommandType.Directive,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}

<div class="govuk-grid-row">
<div class="govuk-grid-column-one-third">
<div class="govuk-grid-column-one-quarter">
<h2 id="your-search-header" class="govuk-label-wrapper">
<label class="govuk-label govuk-label--m">@Model.SearchCriteriaHeading</label>
</h2>
Expand All @@ -24,24 +24,51 @@

<div id="post-filter-content">@Html.Raw(Model.PostSearchCriteriaContent)</div>
</div>
<div class="govuk-grid-column-two-thirds">
<div class="govuk-grid-column-three-quarters">
<h1 id="heading" class="govuk-heading-xl mb-8">@Model.Header</h1>
<h3 id="found-heading" class="govuk-heading-m govuk-!-static-margin-bottom-8">
<strong>
@Model.Qualifications.Count @(Model.Qualifications.Count == 1 ? Model.SingleQualificationFoundText : Model.MultipleQualificationsFoundText)
@if (Model.Qualifications.Count > 0)
{
@Model.Qualifications.Count
}
else
{
@Model.NoQualificationsFoundText
} @(Model.Qualifications.Count == 1 ? Model.SingleQualificationFoundText : Model.MultipleQualificationsFoundText)
</strong>
</h3>
<div id="pre-search-content">@Html.Raw(Model.PreSearchBoxContent)</div>
<div class="govuk-form-group">
@using (Html.BeginForm("Refine", "QualificationDetails", FormMethod.Post))
{
<input class="govuk-input govuk-!-width-three-quarters" id="refineSearch" name="refineSearch" aria-label="refine search box" type="text" value="@Model.SearchCriteria">
<button id="refineSearchButton" type="submit" class="govuk-button govuk-button--secondary" data-module="govuk-button">
@Model.SearchButtonText
</button>
}
<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters">
@using (Html.BeginForm("Refine", "QualificationDetails", FormMethod.Post))
{
<div class="display-flex">
<input class="govuk-input" id="refineSearch" name="refineSearch" aria-label="refine search box" type="text" value="@Model.SearchCriteria">
<button id="refineSearchButton" type="submit" class="govuk-button govuk-button--secondary govuk-!-static-margin-left-1" data-module="govuk-button">
@Model.SearchButtonText
</button>
</div>

}
</div>
<div class="govuk-grid-column-one-quarter">
@using (Html.BeginForm("Refine", "QualificationDetails", FormMethod.Post))
{
<input name="refineSearch" type="hidden" value="">
<button id="clear-search" type="submit" class="govuk-link button-as-link float-left govuk-!-static-margin-left-3 govuk-!-static-margin-top-1 govuk-!-font-size-19">@Model.ClearSearchText</button>
}
</div>
</div>
@foreach (var qualification in Model.Qualifications)

@if (Model.Qualifications.Count == 0)
{
<div id="no-result-content">
@Html.Raw(Model.NoResultText)
</div>
}

@foreach (var qualification in Model.Qualifications)
{
<div class="chevron-card__wrapper">
<a href="@Url.Action("Index", "ConfirmQualification", new { qualificationId = qualification.QualificationId })" class="govuk-link govuk-heading-m chevron-card__link">
Expand Down
22 changes: 22 additions & 0 deletions src/Dfe.EarlyYearsQualification.Web/wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,26 @@ body {

.no-padding-right {
padding-right: 0 !important;
}

.display-flex {
display: flex;
}

.float-left {
float: left;
}

.button-as-link {
background: none!important;
border: none;
color: #1d70b8;
}

.button-as-link:focus {
outline: 3px solid #0000 !important;
background-color: #fd0 !important;
box-shadow: 0 -2px #fd0, 0 4px #0b0c0c !important;
text-decoration: none !important;
-webkit-box-decoration-break: clone !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ describe("A spec used to test the qualification list page", () => {

cy.get(".level").first().should("contain.text", "Level");
cy.get(".awarding-org").first().should("contain.text", "Awarding organisation");

cy.get("#clear-search").should("contain.text", "Clear search");
cy.get("#no-result-content").should("not.exist");
})

it("Shows the default headings when any level and no awarding organisation selected", () => {
Expand All @@ -36,4 +39,13 @@ describe("A spec used to test the qualification list page", () => {
cy.get("#filter-level").should("contain.text", "Any level");
cy.get("#filter-org").should("contain.text", "Various awarding organisations");
})

it("Shows the correct no results content when there are no results in the search", () => {
cy.setCookie('user_journey', '%7B%22WhereWasQualificationAwarded%22%3A%22england%22%2C%22WhenWasQualificationAwarded%22%3A%226%2F2022%22%2C%22LevelOfQualification%22%3A%220%22%2C%22WhatIsTheAwardingOrganisation%22%3A%22%22%7D');

cy.visit("/qualifications");

cy.get("#found-heading").should("contain.text", "No qualifications found");
cy.get("#no-result-content").should("contain.text", "Test no qualifications text");
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ public void ContentHelper_RenderText()

output.Should().Be("Some text");
}

[TestMethod]
public void ContentHelper_RenderBoldText()
{
var text = new Text { Value = "Some text", Marks = [ new Mark
{
Type = "bold"
}]};

var content = new List<IContent> { text };

var output = NestedContentHelper.Render(content).Result;

output.Should().Be("<b>Some text</b>");
}

[TestMethod]
public void ContentHelper_RenderCollection()
Expand Down

0 comments on commit 242c4f4

Please sign in to comment.