Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paullocknimble committed Dec 19, 2023
1 parent 03522b1 commit f93c4d2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public async Task<HttpResponseMessage> GetAllProjectsAsync(AcademyConversionSear
{
return await AcademisationClient.PostAsync(PathFor.GetAllProjects, JsonContent.Create(searchModel));
}
public async Task<HttpResponseMessage> DownloadProjectExport(AcademyConversionSearchModel searchModel)
public async Task<HttpResponseMessage> DownloadProjectExport(AcademyConversionSearchModelV2 searchModel)
{
return await AcademisationClient.PostAsync(PathFor.DownloadProjectExport, JsonContent.Create(searchModel));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Dfe.PrepareConversions.Data.Features;
public interface IApiClient
{
Task<HttpResponseMessage> GetAllProjectsAsync(AcademyConversionSearchModel searchModel);
Task<HttpResponseMessage> DownloadProjectExport(AcademyConversionSearchModel searchModel);
Task<HttpResponseMessage> DownloadProjectExport(AcademyConversionSearchModelV2 searchModel);
Task<HttpResponseMessage> GetAllProjectsV2Async(AcademyConversionSearchModelV2 searchModel);
Task<HttpResponseMessage> GetProjectByIdAsync(int id);
Task<HttpResponseMessage> UpdateProjectAsync(int id, UpdateAcademyConversionProject updateProject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ public async Task<ApiResponse<FileStreamResult>> DownloadProjectExport(
IEnumerable<string> regionsFilter = default,
IEnumerable<string> applicationReferences = default)
{
AcademyConversionSearchModel searchModel = new() { TitleFilter = titleFilter, Page = page, Count = count };
AcademyConversionSearchModelV2 searchModel = new() { TitleFilter = titleFilter, Page = page, Count = count };

ProcessFilters(statusFilters, deliveryOfficerFilter, searchModel, regionsFilter, applicationReferences);
ProcessFiltersV2(statusFilters, deliveryOfficerFilter, searchModel, regionsFilter, applicationReferences);

HttpResponseMessage response = await _apiClient.DownloadProjectExport(searchModel);
if (!response.IsSuccessStatusCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract partial class BaseIntegrationTests

protected IEnumerable<AcademyConversionProject> AddGetProjects(Action<AcademyConversionProject> postSetup = null,
int? recordCount = null,
AcademyConversionSearchModel searchModel = null)
AcademyConversionSearchModelV2 searchModel = null)
{
List<AcademyConversionProject> projects = _fixture
.Build<AcademyConversionProject>()
Expand All @@ -41,17 +41,19 @@ protected IEnumerable<AcademyConversionProject> AddGetProjects(Action<AcademyCon
Paging = new ApiV2PagingInfo { RecordCount = recordCount ?? projects.Count, Page = 0 }
};

searchModel ??= new AcademyConversionSearchModel
searchModel ??= new AcademyConversionSearchModelV2
{
Page = 1,
Count = 10,
TitleFilter = null,
StatusQueryString = Array.Empty<string>(),
DeliveryOfficerQueryString = Array.Empty<string>(),
RegionQueryString = Array.Empty<string>()
RegionQueryString = Array.Empty<string>(),
LocalAuthoritiesQueryString = Array.Empty<string>(),
AdvisoryBoardDatesQueryString = Array.Empty<string>()
};

_factory.AddPostWithJsonRequest(PathFor.GetAllProjects, searchModel, response);
_factory.AddPostWithJsonRequest(PathFor.GetAllProjectsV2, searchModel, response);
return projects;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ public void Should_display_all_projects_by_default()
FilterCount.TextContent.Should().NotContainEquivalentOf("Filtered projects");
}

[Fact]
public void Should_not_display_the_filter_options_by_default()
{
FilterOptions.HasAttribute("open").Should().BeFalse();
}

[Fact]
public async Task Should_display_filtered_banner_when_filter_is_active()
{
Expand All @@ -70,26 +64,19 @@ public async Task Should_display_filtered_banner_when_filter_is_active()
FilterBanner.InnerHtml.Should().ContainEquivalentOf("Projects filtered.");
}

[Fact]
public async Task Should_keep_filter_options_visible_when_filter_is_active()
{
FilterStatuses.First().IsChecked = true;
await FilterApply.SubmitAsync();

FilterOptions.HasAttribute("open").Should().BeTrue();
}

[Fact]
public async Task Should_display_filtered_projects_in_place_of_all_projects_when_filter_is_active()
{
AcademyConversionSearchModel searchModel = new()
AcademyConversionSearchModelV2 searchModel = new()
{
Page = 1,
Count = 10,
StatusQueryString = new[] { "Accepted" },
TitleFilter = string.Empty,
DeliveryOfficerQueryString = Array.Empty<string>(),
RegionQueryString = Array.Empty<string>()
RegionQueryString = Array.Empty<string>(),
LocalAuthoritiesQueryString = Array.Empty<string>(),
AdvisoryBoardDatesQueryString = Array.Empty<string>(),
};
AddGetProjects(recordCount: _recordCount, searchModel: searchModel);

Expand All @@ -106,7 +93,7 @@ public async Task Should_keep_the_filter_options_visible_when_title_filter_is_sp
FilterTitle.Value = "something";
await FilterApply.SubmitAsync();

FilterOptions.HasAttribute("open").Should().BeTrue();

FilterTitle.Value.Should().Be("something");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

<div class="moj-filter__options">
<form method="get" class="form">
<button class="govuk-button" data-module="govuk-button" data-test-id="submit-button">
<button class="govuk-button" data-module="govuk-button" data-test-id="submit-button" data-cy='select-projectlist-filter-apply'>
Apply filters
</button>

Expand Down

0 comments on commit f93c4d2

Please sign in to comment.