Skip to content

Commit

Permalink
Merge pull request #1061 from DFE-Digital/feature/165916-scheme-of-de…
Browse files Browse the repository at this point in the history
…legation

fix angle sharp tests
  • Loading branch information
paullocknimble authored May 22, 2024
2 parents 1350d82 + 128711c commit 7be378c
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public async Task SubmitThroughTheWizard(AdvisoryBoardDecision request)
{
await SetDecisionToAndContinue(request.Decision.GetValueOrDefault());
await SetDecisionByAndContinue(request.DecisionMadeBy.GetValueOrDefault());
await SetDecisionMakerName("Tester");
await SetIsConditionalAndContinue(request.ApprovedConditionsSet.GetValueOrDefault(), request.ApprovedConditionsDetails);
await SetDecisionDateAndContinue(request.AdvisoryBoardDecisionDate.GetValueOrDefault(DateTime.MinValue));
}
Expand Down Expand Up @@ -62,6 +63,12 @@ public async Task SetDecisionByAndContinue(DecisionMadeBy by)
await ClickSubmitButton();
}

public async Task SetDecisionMakerName(string by)
{
Document.QuerySelector<IHtmlInputElement>($"#decision-maker-name")!.Value = by;
await ClickSubmitButton();
}

public async Task SetDeclinedReasonsAndContinue(Tuple<AdvisoryBoardDeclinedReasons, string> reason, params Tuple<AdvisoryBoardDeclinedReasons, string>[] furtherReasons)
{
foreach ((AdvisoryBoardDeclinedReasons option, string detail) in new[] { reason }.Concat(furtherReasons))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public async Task InitializeAsync()
await _wizard.StartFor(_project.Id);
await _wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Approved);
await _wizard.SetDecisionByAndContinue(DecisionMadeBy.Minister);
await _wizard.SetDecisionMakerName("Tester");

Document.Url.Should().EndWith("any-conditions");
}
Expand All @@ -38,14 +39,6 @@ public Task DisposeAsync()
return Task.CompletedTask;
}

[Fact]
public void Should_display_selected_school_name()
{
string selectedSchool = Document.QuerySelector<IHtmlElement>("#selection-span")?.Text();

selectedSchool.Should().Be(_project.SchoolName);
}

[Fact]
public async Task Should_persist_selected_decision()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public async Task Should_pass_on_the_obl_parameter_when_changing_whether_the_acc

await _wizard.StartFor(_project.Id);
await _wizard.SubmitThroughTheWizard(decision);
await NavigateAsync("Change", 2);
await NavigateAsync("Change", 3);

PageHeading.Should().Be("Were any conditions set?");
Document.Url.Should().Contain("obl=");
Expand All @@ -113,9 +113,10 @@ public async Task Should_pass_on_the_obl_parameter_when_changing_declined_reason
await _wizard.StartFor(_project.Id);
await _wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Declined);
await _wizard.SetDecisionByAndContinue(DecisionMadeBy.Minister);
await _wizard.SetDecisionMakerName("Tester");
await _wizard.SetDeclinedReasonsAndContinue(Tuple.Create(AdvisoryBoardDeclinedReasons.Other, "other"));
await _wizard.SetDecisionDateAndContinue(DateTime.Today);
await NavigateAsync("Change", 2);
await NavigateAsync("Change", 3);

PageHeading.Should().Be("Why was this project declined?");
Document.Url.Should().Contain("obl=");
Expand All @@ -131,9 +132,10 @@ public async Task Should_pass_on_the_obl_parameter_when_changing_deferred_reason
await _wizard.StartFor(_project.Id);
await _wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Deferred);
await _wizard.SetDecisionByAndContinue(DecisionMadeBy.DirectorGeneral);
await _wizard.SetDecisionMakerName("Tester");
await _wizard.SetDeferredReasonsAndContinue(Tuple.Create(AdvisoryBoardDeferredReason.Other, "other"));
await _wizard.SetDecisionDateAndContinue(DateTime.Today);
await NavigateAsync("Change", 2);
await NavigateAsync("Change", 3);

PageHeading.Should().Be("Why was this project deferred?");
Document.Url.Should().Contain("obl=");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ public DecisionDateIntegrationTests(IntegrationTestingWebApplicationFactory fact
private IHtmlInputElement MonthPart => Document.QuerySelector<IHtmlInputElement>("#decision-date-month");
private IHtmlInputElement YearPart => Document.QuerySelector<IHtmlInputElement>("#decision-date-year");

[Fact]
public async Task Should_display_selected_school_name()
{
AcademyConversionProject project = AddGetProject(p => p.SchoolOverviewSectionComplete = false);

await ProgressToDecisionDateStep(project);

string selectedSchool = Document.QuerySelector<IHtmlElement>("#selection-span")!.Text();

selectedSchool.Should().Be(project.SchoolName);
}

[Fact]
public async Task Should_persist_approval_date()
{
Expand Down Expand Up @@ -139,6 +127,7 @@ public async Task Should_go_back_to_declined_reasons_for_the_declined_journey()
await wizard.StartFor(project.Id);
await wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Declined);
await wizard.SetDecisionByAndContinue(DecisionMadeBy.Minister);
await wizard.SetDecisionMakerName("Tester");
await wizard.SetDeclinedReasonsAndContinue(Tuple.Create(AdvisoryBoardDeclinedReasons.Finance, "Finance reasons"));

PageHeading.Should().Be("Date conversion was declined");
Expand All @@ -162,6 +151,7 @@ public async Task Should_display_the_correct_journey_in_the_required_message_whe
await wizard.StartFor(project.Id);
await wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Declined);
await wizard.SetDecisionByAndContinue(DecisionMadeBy.Minister);
await wizard.SetDecisionMakerName("Tester");
await wizard.SetDeclinedReasonsAndContinue(Tuple.Create(AdvisoryBoardDeclinedReasons.Performance, "performance reasons"));

PageHeading.Should().Be("Date conversion was declined");
Expand All @@ -185,6 +175,7 @@ private async Task ProgressToDecisionDateStep(AcademyConversionProject project)
await wizard.StartFor(project.Id);
await wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Approved);
await wizard.SetDecisionByAndContinue(DecisionMadeBy.OtherRegionalDirector);
await wizard.SetDecisionMakerName("Tester");
await wizard.SetIsConditionalAndContinue(false, "Something");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public async Task InitializeAsync()
await _wizard.StartFor(_project.Id);
await _wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Declined);
await _wizard.SetDecisionByAndContinue(DecisionMadeBy.RegionalDirectorForRegion);
await _wizard.SetDecisionMakerName("Tester");

Document.Url.Should().EndWith("/decision/declined-reason");
}
Expand All @@ -40,15 +41,6 @@ public Task DisposeAsync()
return Task.CompletedTask;
}


[Fact]
public void Should_display_the_selected_school_name()
{
string selectedSchool = Document.QuerySelector<IHtmlElement>("#selection-span")!.Text();

selectedSchool.Should().Be(_project.SchoolName);
}

[Fact]
public async Task Should_return_to_the_who_made_this_decision_page_when_back_link_is_clicked()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ public RecordDecisionIntegrationTests(IntegrationTestingWebApplicationFactory fa
{
}

[Fact]
public async Task Should_display_selected_schoolname()
{
AcademyConversionProject project = AddGetProject(p => p.SchoolOverviewSectionComplete = false);

await OpenAndConfirmPathAsync($"/task-list/{project.Id}/decision/record-decision");

string selectedSchool = Document.QuerySelector<IHtmlElement>("#selection-span")!.Text();

selectedSchool.Should().Be(project.SchoolName);
}

[Fact]
public async Task Should_persist_selected_decision()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public async Task Should_redirect_to_task_list()
ApprovedConditionsSet = true,
ApprovedConditionsDetails = "bills need to be paid",
DecisionMadeBy = DecisionMadeBy.DirectorGeneral,
DecisionMakerName = "Tester",
ConversionProjectId = _project.Id
};

Expand All @@ -52,29 +53,6 @@ public async Task Should_redirect_to_task_list()
PageSubHeading.Should().Be("Prepare a project document");
}

[Fact]
public async Task Should_display_selected_school_name()
{
AdvisoryBoardDecision request = new()
{
Decision = AdvisoryBoardDecisions.Approved,
AdvisoryBoardDecisionDate = new DateTime(2021, 01, 01),
ApprovedConditionsSet = true,
ApprovedConditionsDetails = "bills need to be paid",
DecisionMadeBy = DecisionMadeBy.DirectorGeneral,
ConversionProjectId = _project.Id
};

_factory.AddPostWithJsonRequest("/conversion-project/advisory-board-decision", request, "");

await OpenAndConfirmPathAsync($"/task-list/{_project.Id}/decision/record-decision");

await _wizard.SubmitThroughTheWizard(request);

Document.QuerySelector<IHtmlElement>("#selection-span")!.Text().Should()
.Be(_project.SchoolName);
}

[Fact]
public async Task Should_populate_summary_and_create_new_decision()
{
Expand All @@ -85,6 +63,7 @@ public async Task Should_populate_summary_and_create_new_decision()
ApprovedConditionsSet = true,
ApprovedConditionsDetails = "bills need to be paid",
DecisionMadeBy = DecisionMadeBy.DirectorGeneral,
DecisionMakerName = "Tester",
ConversionProjectId = _project.Id
};

Expand All @@ -109,6 +88,7 @@ public async Task Should_populate_summary_and_save_existing_decision()
ApprovedConditionsSet = true,
ApprovedConditionsDetails = "bills need to be paid",
DecisionMadeBy = DecisionMadeBy.DirectorGeneral,
DecisionMakerName = "Tester",
ConversionProjectId = _project.Id
};

Expand Down Expand Up @@ -159,6 +139,7 @@ public async Task Should_display_declined_for_declined_projects()
await _wizard.StartFor(_project.Id);
await _wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Declined);
await _wizard.SetDecisionByAndContinue(DecisionMadeBy.DirectorGeneral);
await _wizard.SetDecisionMakerName("Tester");
await _wizard.SetDeclinedReasonsAndContinue(Tuple.Create(AdvisoryBoardDeclinedReasons.Finance, "Finance reason"));
await _wizard.SetDecisionDateAndContinue(DateTime.Today);

Expand All @@ -171,6 +152,7 @@ public async Task Should_show_the_selected_decline_reasons_and_details()
await _wizard.StartFor(_project.Id);
await _wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Declined);
await _wizard.SetDecisionByAndContinue(DecisionMadeBy.Minister);
await _wizard.SetDecisionMakerName("Tester");
await _wizard.SetDeclinedReasonsAndContinue(Tuple.Create(AdvisoryBoardDeclinedReasons.Finance, "Finance detail"),
Tuple.Create(AdvisoryBoardDeclinedReasons.ChoiceOfTrust, "Choice of trust detail"));
await _wizard.SetDecisionDateAndContinue(DateTime.Today);
Expand All @@ -193,6 +175,7 @@ public async Task Should_show_the_selected_deferred_reasons_and_details()
await _wizard.StartFor(_project.Id);
await _wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Deferred);
await _wizard.SetDecisionByAndContinue(DecisionMadeBy.Minister);
await _wizard.SetDecisionMakerName("Tester");
await _wizard.SetDeferredReasonsAndContinue(
Tuple.Create(AdvisoryBoardDeferredReason.PerformanceConcerns, "Performance detail"),
Tuple.Create(AdvisoryBoardDeferredReason.Other, "Other detail"),
Expand All @@ -218,6 +201,7 @@ public async Task Should_not_display_conditions_details_for_declined_projects()
await _wizard.StartFor(_project.Id);
await _wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Declined);
await _wizard.SetDecisionByAndContinue(DecisionMadeBy.OtherRegionalDirector);
await _wizard.SetDecisionMakerName("Tester");
await _wizard.SetDeclinedReasonsAndContinue(Tuple.Create(AdvisoryBoardDeclinedReasons.Finance, "finance reasons"));
await _wizard.SetDecisionDateAndContinue(DateTime.Today);

Expand All @@ -228,8 +212,8 @@ public async Task Should_not_display_conditions_details_for_declined_projects()

[Theory]
[InlineData(1, "Who made this decision?")]
[InlineData(2, "Were any conditions set?")]
[InlineData(3, "Date conversion was approved")]
[InlineData(3, "Were any conditions set?")]
[InlineData(4, "Date conversion was approved")]
public async Task Should_go_back_to_choose_and_back_link_to_summary(int changeLinkIndex, string expectedTitle)
{
AdvisoryBoardDecision request = new()
Expand Down Expand Up @@ -258,9 +242,9 @@ public async Task Should_go_back_to_choose_and_back_link_to_summary(int changeLi

[Theory]
[InlineData(0, "Record the decision", "Who made this decision?")]
[InlineData(1, "Who made this decision?", "Were any conditions set?")]
[InlineData(2, "Were any conditions set?", "Date conversion was approved")]
[InlineData(3, "Date conversion was approved", "Check your answers before recording this decision")]
[InlineData(1, "Who made this decision?", "Decision maker's name")]
[InlineData(3, "Were any conditions set?", "Date conversion was approved")]
[InlineData(4, "Date conversion was approved", "Check your answers before recording this decision")]
public async Task Should_go_back_to_choose_and_submit_back_to_summary(int changeLinkIndex, string changePageTitle, string nextPageTitle)
{
AdvisoryBoardDecision request = new()
Expand Down Expand Up @@ -292,6 +276,7 @@ public async Task Should_store_the_reasons_in_the_expected_order()
await _wizard.StartFor(_project.Id);
await _wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Declined);
await _wizard.SetDecisionByAndContinue(DecisionMadeBy.Minister);
await _wizard.SetDecisionMakerName("Tester");
await _wizard.SetDeclinedReasonsAndContinue(
Tuple.Create(AdvisoryBoardDeclinedReasons.ChoiceOfTrust, "trust"),
Tuple.Create(AdvisoryBoardDeclinedReasons.Other, "other"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ public WhoDecidedIntegrationTests(IntegrationTestingWebApplicationFactory factor
{
}

[Fact]
public async Task Should_display_selected_schoolname()
{
AcademyConversionProject project = AddGetProject(p => p.SchoolOverviewSectionComplete = false);

await OpenAndConfirmPathAsync($"/task-list/{project.Id}/decision/who-decided");

string selectedSchool = Document.QuerySelector<IHtmlElement>("#selection-span")!.Text();

selectedSchool.Should().Be(project.SchoolName);
}

[Fact]
public async Task Should_persist_who_decided()
Expand Down Expand Up @@ -79,6 +68,7 @@ public async Task Should_redirect_to_decline_reasons_if_project_declined()
await wizard.StartFor(project.Id);
await wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Declined);
await wizard.SetDecisionByAndContinue(DecisionMadeBy.RegionalDirectorForRegion);
await wizard.SetDecisionMakerName("Tester");

Document.Url.Should().EndWith("/decision/declined-reason", "reason should be the second question in the declined journey");
Document.QuerySelector<IHtmlHeadingElement>(".govuk-fieldset__heading")!.TextContent.Trim()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,11 @@ public async Task InitializeAsync()
await _wizard.StartFor(_project.Id);
await _wizard.SetDecisionToAndContinue(AdvisoryBoardDecisions.Deferred);
await _wizard.SetDecisionByAndContinue(DecisionMadeBy.RegionalDirectorForRegion);
await _wizard.SetDecisionMakerName("Tester");

Document.Url.Should().EndWith("/decision/why-deferred");
}

[Fact]
public void Should_display_the_selected_school_name()
{
string selectedSchool = Document.QuerySelector<IHtmlElement>("#selection-span")!.Text();

selectedSchool.Should().Be(_project.SchoolName);
}

[Fact]
public async Task Should_return_to_the_who_made_this_decision_page_when_back_link_is_clicked()
{
Expand Down

0 comments on commit 7be378c

Please sign in to comment.