Skip to content

Commit

Permalink
Change Resources url to resources-learning
Browse files Browse the repository at this point in the history
  • Loading branch information
killij committed Nov 1, 2023
1 parent 71f5f5c commit f8a7d52
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ResourcesController(IFeaturesConfig featuresConfig, IResourcesSearchStrat
_strategy = strategy;
}

[Route("resources", Name = "Resource")]
[Route("resources-learning")]
[HttpGet]
public async Task<IActionResult> Search([FromQuery] ResourcesQuery query, bool preferencesSet = false, CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ private static string GetPagingFormatString(IEnumerable<string> tags)
{
var tagStrings = tags.Select(x => $"tags={x}");
var allTags = string.Join("&", tagStrings);
return $"/resources?page={{0}}&{allTags}";
return $"/resources-learning?page={{0}}&{allTags}";
}

return $"/resources?page={{0}}";
return $"/resources-learning?page={{0}}";
}

public async Task<ResourcesListViewModel> SearchAsync(ResourcesQuery query, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ private static string GetPagingFormatString(int[] tags)
{
var tagStrings = tags.Select(x => $"tags={x}");
var allTags = string.Join("&", tagStrings);
return $"/resources?page={{0}}&{allTags}";
return $"/resources-learning?page={{0}}&{allTags}";
}

return $"/resources?page={{0}}";
return $"/resources-learning?page={{0}}";
}

public async Task<ResourcesListViewModel> SearchAsync(ResourcesQuery query, CancellationToken cancellationToken = default)
Expand Down
6 changes: 3 additions & 3 deletions Childrens-Social-Care-CPD/Views/Resources/Search.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@if (featuresConfig.IsEnabled(Features.ResourcesUseDynamicTags))
{
<gds-filter clear-filters-uri="/resources">
<gds-filter clear-filters-uri="/resources-learning">
@{
var groups = Model.TagInfos.GroupBy(x => x.Category);
var index = 1; // gov uk js requires starting at 1 for this control
Expand All @@ -41,7 +41,7 @@
else
{
var tagsDict = new Dictionary<int, TagInfo>(Model.TagInfos.Select((tagInfo, index) => KeyValuePair.Create(index, tagInfo)));
<gds-filter clear-filters-uri="/resources">
<gds-filter clear-filters-uri="/resources-learning">
@{
var groupsx = tagsDict.GroupBy(kvp => kvp.Value.Category);
var index = 1; // gov uk js requires starting at 1 for this control
Expand All @@ -65,7 +65,7 @@

@{
var resultString = Model.TotalResults == 1 ? "result" : "results";
<h2 class="gem-c-heading govuk-heading-s govuk-!-margin-bottom-2">
<h2 class="gem-c-heading govuk-heading-s govuk-!-margin-bottom-2" data-testid="results-count">
@Model.TotalResults @resultString
</h2>
<hr />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@model SearchResourcesByTags.SearchResult

<div>
<h2><a href="@Model.LinkedFrom.ContentCollection.Items.First().Id">@Model.Title</a></h2>
<h2><a href="/@Model.LinkedFrom.ContentCollection.Items.First().Id">@Model.Title</a></h2>
<p>@Model.SearchSummary</p>
<ul class="govuk-list govuk-body-s" style="display:flex; gap:15px; flex-flow:row">
<li>From: @Model.From</li>
Expand Down
2 changes: 1 addition & 1 deletion Childrens-Social-Care-CPD/Views/Shared/_ErrorLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
@if (featuresConfig.IsEnabled(Features.ResourcesAndLearning))
{
<li class="dfe-header__navigation-item" id="mmi-resources">
<a class="dfe-header__navigation-link" href="/resources">
<a class="dfe-header__navigation-link" href="/resources-learning">
Resources and learning
<svg class="dfe-icon dfe-icon__chevron-right" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" width="34" height="34">
<path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
Expand Down
2 changes: 1 addition & 1 deletion Childrens-Social-Care-CPD/Views/Shared/_Header.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

if (featuresConfig.IsEnabled(Features.ResourcesAndLearning))
{
RenderMenuItem("resources", "Resources and learning", "resources", category == "Resources");
RenderMenuItem("resources", "Resources and learning", "resources-learning", category == "Resources");
}
}
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test.describe('Header', () => {
['Career stages', '/career-stages'],
['Development programmes', '/development-programmes'],
['Explore roles', '/explore-roles'],
['Resources', '/training-resources'],
['Resources and learning', '/resources-learning'],
]

for (const link of links) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { test, expect } from '@playwright/test'

test.describe('Resources and learning', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/resources-learning')
})

test.describe('Filter accordian @accordian', () => {
test('All sections are collapsed when you arrive on page' , async ({ page }) => {
const sections = await page.locator('.govuk-accordion__section-content').all()
expect(sections.length).toBeGreaterThan(1)
for (const section of sections)
{
await expect(section).toHaveAttribute('hidden', 'until-found')
}
})

test('Clicking expand all, expands the sections' , async ({ page }) => {
await page.getByRole('button', { name: 'Show all sections', exact: true }).click()

const sections = await page.locator('.govuk-accordion__section-content').all()
expect(sections.length).toBeGreaterThan(1)
for (const section of sections)
{
await expect(section).not.toHaveAttribute('hidden', 'until-found')
}
})
})

test('Filter by tags performs search' , async ({ page }) => {
await page.getByRole('button', { name: 'Show all sections', exact: true }).click()
const beforeText = await page.getByTestId("results-count").textContent()
await page.locator('.govuk-checkboxes__label').first().click()
await page.getByRole('button', { name: 'Apply filter', exact: true }).click()
const afterText = await page.getByTestId("results-count").textContent()
expect(beforeText).not.toEqual(afterText)
})
})

0 comments on commit f8a7d52

Please sign in to comment.