Skip to content

Commit

Permalink
Merge pull request #1197 from DFE-Digital/feature/redirect-from-proje…
Browse files Browse the repository at this point in the history
…ct-type

Feature/redirect from project type
  • Loading branch information
paullocknimble authored Oct 2, 2024
2 parents 960d6c1 + 01b937d commit 9b6ebdd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AngleSharp.Dom;
using AngleSharp.Html.Dom;
using Dfe.PrepareConversions.Tests.Extensions;
using FluentAssertions;
using System.Threading.Tasks;
using Xunit;
Expand All @@ -12,65 +13,9 @@ public ProjectTypeIntegrationTests(IntegrationTestingWebApplicationFactory facto


[Fact]
public async Task Should_display_labels_for_radio_with_correct_value()
public async Task Should_redirect_to_project_list_page()
{
await OpenAndConfirmPathAsync("/project-type");
Document.QuerySelector("label[for=transfer-radio]")!.Text();
Document.QuerySelector("label[for=conversion-radio]")!.Text().Should().Contain("Manage an academy conversion");
Document.QuerySelector("label[for=transfer-radio]")!.Text().Should().Contain("Manage an academy transfer");
await OpenAndConfirmPathAsync("/project-type", "/project-list");
}

[Fact]
public async Task Should_not_have_any_values_selected_on_page_load()
{
await OpenAndConfirmPathAsync("/project-type");

Document.QuerySelector<IHtmlInputElement>("#conversion-radio")!.IsChecked.Should().BeFalse();
Document.QuerySelector<IHtmlInputElement>("#transfer-radio")!.IsChecked.Should().BeFalse();
}

[Fact]
public async Task Should_display_error_and_not_continue_if_no_option_is_selected()
{
await OpenAndConfirmPathAsync("/project-type");

Document.QuerySelector<IHtmlInputElement>("#conversion-radio")!.IsChecked = false;
Document.QuerySelector<IHtmlInputElement>("#transfer-radio")!.IsChecked = false;

await Document.QuerySelector<IHtmlButtonElement>("#submit-btn")!.SubmitAsync();

Document.QuerySelector("h1")!.TextContent!.Trim().Should().Be("What do you want to do?");

Document.QuerySelector(".govuk-error-summary")!.Should().NotBeNull();
Document.QuerySelector(".govuk-error-summary")!.TextContent.Should().Contain("Select a project type");
}

[Fact]
public async Task Should_navigate_to_project_list_page_if_conversions_is_selected()
{
await OpenAndConfirmPathAsync("/project-type");

string baseUrlHost = Document.BaseUrl!.Host;

Document.QuerySelector<IHtmlInputElement>("#conversion-radio")!.IsChecked = true;

await Document.QuerySelector<IHtmlButtonElement>("#submit-btn")!.SubmitAsync();

Document.BaseUrl.Host.Should().Be(baseUrlHost);
Document.Url.Should().EndWith("project-list");
}

[Fact]
public async Task Should_navigate_to_external_service_if_transfers_is_selected()
{
await OpenAndConfirmPathAsync("/project-type");

string baseUrlHost = Document.BaseUrl!.Host;

Document.QuerySelector<IHtmlInputElement>("#transfer-radio")!.IsChecked = true;

await Document.QuerySelector<IHtmlButtonElement>("#submit-btn")!.SubmitAsync();

Document.BaseUrl.Host.Should().NotBe(baseUrlHost);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ public IndexModel(IOptions<ServiceLinkOptions> options, ErrorService errorServic
public IActionResult OnGet()
{
ProjectListFilters.ClearFiltersFrom(TempData);
return Page();

// this page is no longer required now transfers has been merged into this code base
// this redirect will push anyone that has book mark to this page back to the project list page
return RedirectToPage(Links.ProjectList.Index.Page);
}

public IActionResult OnPost()
Expand Down

0 comments on commit 9b6ebdd

Please sign in to comment.