public void Evidence_POST_RemoveFile() { WebAppTest(client => { // prep this test by adding a file to remove var cloudName = System.Guid.NewGuid().ToString(); var detail = NewCocDetail("form123"); detail.Evidence.Files.Add(new EvidenceFile { Name = "UploadedFile.pdf", CloudName = cloudName }); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); // now remove it var response = client.Get(CocActions.Evidence(detail.Id)) .Form <EvidenceFile>(1) .SubmitName(CocButtons.RemoveFile, client); ExecutorStub.Executed <RemoveEvidenceFile>(0).ShouldBeEquivalentTo(new RemoveEvidenceFile { FormId = "form123", CloudName = cloudName, }); response.ActionResultOf <RedirectResult>().Url.Should().Be(CocActions.Evidence("form123")); }); }
public void Declaration_GET() { WebAppTest(client => { // the declaration form is now dependent on a completed ApplicantDetails, so... var detail = NewBsgDetail("form123"); // with default age ... ExecutorStub.SetupQuery(It.IsAny<FindBsgSection>(), detail); var response = client.Get(BsgActions.Declaration(detail.Id)); response.Text.ToLower().Should().Contain("the information you've given"); }); }
public void FirstSectionDoesNotNeedId() { WebAppTest(client => { ExecutorStub.SetupQuery <FindBsgSection, BsgDetail>((cmd, r) => { throw new DomainException("cannot call FindBsgSection with a null id"); }); var firstSection = Navigation.Order.First(); var firstAction = SectionActionStrategy.For(firstSection).Action(null); client.Get(firstAction); }); }
public void Declaration_GET_HandlesMissingSections() { WebAppTest(client => { var detail = new BsgDetail { Id = "form123" }; ExecutorStub.SetupQuery(It.IsAny<FindBsgSection>(), detail); var response = client.Get(BsgActions.Declaration(detail.Id)); response.HttpStatusCode.Should().Be(HttpStatusCode.OK); }); }
public void DeclarationU16_GET() { WebAppTest(client => { // the declaration form is now dependent on a completed ApplicantDetails, so... var detail = NewBsgDetail("form123"); // then ensure under 16... detail.ApplicantDetails.DateOfBirth = System.DateTime.Now.AddYears(-15); ExecutorStub.SetupQuery(It.IsAny<FindBsgSection>(), detail); var response = client.Get(BsgActions.Declaration(detail.Id)); response.Text.ToLower().Should().Contain("you are under the age of 16"); }); }
public void ExistingChildren_GET_WhenNoExistingChildren_PrePopulatesOneChild() { WebAppTest(client => { var detail = NewBsgDetail("form123"); detail.ExistingChildren.Children = new List <ExistingChild>(); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ExistingChildren(detail.Id)); response.Doc.FindAll(".existing-child").Count.Should().Be(1, "should have at least one child pre-populated (albeit hidden)"); }); }
public void Declaration_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny<FindBsgSection>(), detail); var response = client.Get(BsgActions.Declaration(detail.Id)); ExecutorStub.Executed<FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.Declaration }); response.Doc.Form<Declaration>(1).GetConfirm(m => m.AgreedToLegalStatement).Should().Be(detail.Declaration.AgreedToLegalStatement); }); }
public void ExpectedChildren_GET_DefaultsToExpectedBaby_AndHidesQuestion() { WebAppTest(client => { var detail = NewCocDetail("form123"); detail.ExpectedChildren = null; ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.ExpectedChildren(detail.Id)); response.Doc.Form <ExpectedChildren>(1).GetText(m => m.IsBabyExpected).Should().Be(true.ToString()); response.Doc.Find("#IsBabyExpected_FormGroup").ShouldBeHidden(); }); }
public void ExistingChildren_AsksForReason_OnlyWhenNoChildBenefit() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ExistingChildren(detail.Id)); var form = response.Form <ExistingChildren>(1); form.RadioShows(m => m.Children[0].ChildBenefit, false, "child0-reason"); form.RadioShows(m => m.Children[1].ChildBenefit, false, "child1-reason"); }); }
public void ExistingChildren_AsksChildDetails_OnlyWhenSelectedYesToChildren() { WebAppTest(client => { var detail = NewBsgDetail("form123", 2); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ExistingChildren(detail.Id)); var form = response.Form <ExistingChildren>(1); form.RadioShows(m => m.AnyExistingChildren, true, "children-details"); response.Doc.FindAll("button[name=RemoveChild]").Count.Should().Be(2, "should have 2 remove buttons"); }); }
public void ExistingChildren_GET_WhenExactlyOneChild_NoRemoveButtonIsShown() { WebAppTest(client => { var detail = NewBsgDetail("form123", 1); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ExistingChildren(detail.Id)); var form = response.Form <ExistingChildren>(1); form.RadioShows(m => m.AnyExistingChildren, true, "children-details"); response.Doc.FindAll("button[name=RemoveChild]").Count.Should().Be(0, "no remove child button when there's only 1 child (select 'no' instead)"); }); }
public void HealthProfessional_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.HealthProfessional(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { FormId = detail.Id, Section = Sections.HealthProfessional }); response.Doc.Form <HealthProfessional>(1).GetText(m => m.Pin).Should().Be(detail.HealthProfessional.Pin); }); }
public void Identity_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.Identity(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { FormId = detail.Id, Section = Sections.Identity }); response.Doc.Form <IdentityModel>(1).GetText(m => m.Email).Should().Be(detail.Identity); }); }
public void ApplicantBenefits_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ApplicantBenefits(detail.Id)); ExecutorStub.Executed <FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.ApplicantBenefits }); response.Doc.Form <Benefits>(1).GetConfirm(m => m.HasIncomeSupport).Should().Be(detail.ApplicantBenefits.HasIncomeSupport); }); }
public void ApplicantDetails_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.ApplicantDetails(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { FormId = detail.Id, Section = Sections.ApplicantDetails }); response.Doc.Form <ApplicantDetails>(1).GetText(m => m.FullName).Should().Be(detail.ApplicantDetails.FullName); }); }
public void GuardianDetails_GET_PopulatesExistingAddressDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.GuardianDetails(detail.Id)); ExecutorStub.Executed <FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.GuardianDetails }); response.Doc.Form <RelationDetails>(1).GetText(m => m.Address.Line1).Should().Be(detail.GuardianDetails.Address.Line1); }); }
public void ExpectedChildren_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.ExpectedChildren(detail.Id)); ExecutorStub.Executed <FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.ExpectedChildren }); response.Doc.Form <ExpectedChildren>(1).GetText(m => m.ExpectedBabyCount).Should().Be(detail.ExpectedChildren.ExpectedBabyCount.ToString()); }); }
public void PaymentDetails_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.PaymentDetails(detail.Id)); ExecutorStub.Executed <FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.PaymentDetails }); response.Doc.Form <PaymentDetails>(1).GetText(m => m.NameOfAccountHolder).Should().Be(detail.PaymentDetails.NameOfAccountHolder); }); }
public void Options_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.Options(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { FormId = detail.Id, Section = Sections.Options }); response.Doc.Form <Options>(1).GetConfirm(m => m.ChangePersonalDetails).Should().Be(detail.Options.ChangePersonalDetails); }); }
public void Evidence_GET_PopulatesExistingDetails() { WebAppTest(client => { var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindBsgSection>(), detail); var response = client.Get(BsgActions.Evidence(detail.Id)); ExecutorStub.Executed <FindBsgSection>(0).ShouldBeEquivalentTo(new FindBsgSection { FormId = detail.Id, Section = Sections.Evidence }); response.Doc.Form <Evidence>(1).GetConfirm(m => m.SendingByPost).Should().Be(detail.Evidence.SendingByPost); response.Doc.Document.Body.TextContent.Should().Contain("No files uploaded"); }); }
public void Declaration_POST_ErrorsAreDisplayed() { WebAppTest(client => { // the declaration form is now dependent on a completed ApplicantDetails, so... // even if the form is not queried such as this test, the browser cannot render the page without ApplicantDetails var detail = NewBsgDetail("form123"); ExecutorStub.SetupQuery(It.IsAny<FindBsgSection>(), detail); ExecutorStub.SetupCommand<AddDeclaration, NextSection>((cmd, def) => { throw new DomainException("simulated logic error"); }); var response = client.Get(BsgActions.Declaration(detail.Id)).Form<Declaration>(1) .SubmitName("", client, r => r.SetExpectedResponse(HttpStatusCode.OK)); response.Doc.Find(".validation-summary-errors").Should().NotBeNull(); }); }
public void Declaration_GET_DisplaysAllSectionContent() { WebAppTest(client => { var detail = NewBsgDetail("form123"); detail.PartnerDetails.InheritAddress = true; ExecutorStub.SetupQuery(It.IsAny<FindBsgSection>(), detail); var expectedAnswers = new List<string>(); MemberVisitor.Visit(detail, (name, member, type, value) => expectedAnswers.Add(name)); var namesToIgnore = new List<string> { "Id", "Consent.", "Declaration.", "PreviousSection", "IsFinalSection", }; // the partner details inherit the address, and the guardian and guardian's partner have full addresses namesToIgnore.Add("PartnerDetails.Address."); namesToIgnore.Add("GuardianDetails.InheritAddress"); namesToIgnore.Add("GuardianPartnerDetails.InheritAddress"); expectedAnswers = expectedAnswers .Where(ea => !namesToIgnore.Any(i => ea.StartsWith(i))) .ToList(); var response = client.Get(BsgActions.Declaration(detail.Id)); var missingAnswers = new List<string>(); foreach (var expectedAnswer in expectedAnswers) { var selector = $"[data-answer-for='{expectedAnswer}']"; var output = response.Doc.FindAll(selector); output.Count.Should().BeLessOrEqualTo(1, "did not expected multiple entries for {0}", expectedAnswer); if (output.Count < 1) missingAnswers.Add(expectedAnswer); } missingAnswers.Count.Should().Be(0, "all questions should have an answer; could not find answers to the following questions:\n{0}", string.Join("\n", missingAnswers)); }); }
public void Declaration_POST_PopulatesDeclaration() { WebAppTest(client => { // the declaration form is now dependent on a completed ApplicantDetails, so... var detail = NewCocDetail("form123"); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.Declaration(detail.Id)).Form <Declaration>(1) .SelectConfirm(m => m.AgreedToLegalStatement, true) .Submit(client); ExecutorStub.Executed <AddDeclaration>(0).ShouldBeEquivalentTo(new AddDeclaration { FormId = "form123", Declaration = new Declaration { AgreedToLegalStatement = true }, }); response.ActionResultOf <RedirectResult>().Url.Should().NotBeNullOrWhiteSpace(); }); }
public void Evidence_GET_ListsExistingFiles() { WebAppTest(client => { var detail = NewCocDetail("form123"); detail.Evidence.Files.Add(new EvidenceFile { Name = "file 1" }); detail.Evidence.Files.Add(new EvidenceFile { Name = "file 2" }); ExecutorStub.SetupQuery(It.IsAny <FindCocSection>(), detail); var response = client.Get(CocActions.Evidence(detail.Id)); ExecutorStub.Executed <FindCocSection>(0).ShouldBeEquivalentTo(new FindCocSection { FormId = detail.Id, Section = Sections.Evidence }); response.Doc.Form <Evidence>(1).GetConfirm(m => m.SendingByPost).Should().Be(detail.Evidence.SendingByPost); response.Doc.Document.Body.TextContent.Should().NotContain("No files uploaded"); response.Doc.FindAll("#uploadedFiles li").Count.Should().Be(2); }); }
public void ApplicantDetails_AjaxShowsHidesQuestions() { WebAppTest(client => { var response = client.Get(BsgActions.ApplicantDetails("form123")); ExecutorStub.SetupQuery(It.IsAny <FindApplicantDetailsConfig>(), new ApplicantDetailsConfig { ShouldAskCareQuestion = true, ShouldAskEducationQuestion = false, ShouldAskForNationalInsuranceNumber = true, }); var ajaxActions = response.Form <ApplicantDetails>(1) .OnChange(f => f.DateOfBirth, client); ajaxActions.Should().NotBeNull(); ajaxActions.Length.Should().Be(3); ajaxActions.ForFormGroup <ApplicantDetails>(f => f.PreviouslyLookedAfter).ShouldShowHide(response.Doc, true); ajaxActions.ForFormGroup <ApplicantDetails>(f => f.FullTimeEducation).ShouldShowHide(response.Doc, false); ajaxActions.ForFormGroup <ApplicantDetails>(f => f.NationalInsuranceNumber).ShouldShowHide(response.Doc, true); }); }